Hi friends,i must have you help for this Cereous problum,
i have a code about a digital thermometer using the proc baord. I have compiled this code in microvision ide And the code is compiled and Built with some warnings and it works very Well.
The point is that i have built the circuit in time and it works perfectly.
the code isthis
int wait_1second ( void) delay { int delay_count ; delay_count = 100000; label: delay_count = --delay_count; if ( delay_count > 1 ) goto label; end_label: } }
I burn the proc whith the .hex generated and my LCD just show squares and charactors .
I have written the same code using other one and it works perfectly, i don't use assembler, thats the reason why i'm here asking for help. I put this circuit in files .asm & .hex for you to see.
Thanks in advance
Hello Spur Sohel,
You are putting too big a number into the int variable. The biggest is 32000 and you are putting in 100000.
Change the int to long and it will work.
Janice
Where to start? There are lots of potential problems here.
Your delay_count variable is only a 16 bit integer.
Your code achieves nothing, so the optimiser might optimise it out.
The function declaration is wrong.
delay_count = --delay_count; : Why not just delay_count--;
Labels have no place here, (use a while loop.)
Your function is declared as returning an int, but doesn't.
1) Get a book about the C programming language.
2) Stop using labels and goto to create loops.
3) Don't use a counted loop, but instead use a timer to keep track of the time.
4) "I have written the same code using other one and it works perfectly" - what is "other one"?
View all questions in Keil forum