CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Problem with constant data table in ROM

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Marco C.
Guest







Problem with constant data table in ROM
PostPosted: Fri Jun 04, 2004 9:11 am     Reply with quote

Hello everybody,

Just a simple question on a little piece of code:

Code:

int const Genome[10]={1,10,9,10,2,1,9,10,2,1};

void build(int genomeBuffer[]) {
printf("Hello World \n\r");
}

void main () {
build(Genome);
}

the result on a terminal is 64X "Hello World" like this:
Hello World
Hello World
Hello World
....
....
Hello World

Why ?

Thank you for answering ! Very Happy
Marco.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jun 04, 2004 11:07 am     Reply with quote

The most likely cause of your problem is:

You have the Watchdog Timer enabled in your #fuses statement,
but you're never re-starting it. So it times out and resets the PIC,
which causes the message to be displayed over and over again.

Your fuses statement might look like this:
#fuses XT, NOPROTECT, WDT, BROWNOUT, PUT, NOLVP

Change it to be this:
#fuses XT, NOPROTECT, NOWDT, BROWNOUT, PUT, NOLVP

-----------------------------------------------------
An additional note:
You are letting your program fall off the end of main().
The compiler puts a hidden Sleep statement there.
If you're using a hardware USART, the Sleep instruction will
put the PIC to sleep before the last two characters in your
text string are transmitted. The last 2 chars will be not be displayed.

Fix this by putting a while(1) statement at the very end of main():

main()
{
build(Genome);

while(1); // Add this line
}
------------------------------------------------
Some tips on asking for help on this board:

When you post a program, you should always post all
of the CCS directives, such as the #fuses statement,
the #use delay statement, etc. It helps us to solve
your problem for you. If you don't post it, we have
to do "mind reading". We have to do that a lot on
this board. Also, your post subject could be better.
More like: "My program displays same message over and over".
Or: "My program constantly re-starts"
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group