|
|
View previous topic :: View next topic |
Author |
Message |
Marco C. Guest
|
Problem with constant data table in ROM |
Posted: Fri Jun 04, 2004 9:11 am |
|
|
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 !
Marco. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Jun 04, 2004 11:07 am |
|
|
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" |
|
|
|
|
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
|