Hello!
But, In Simulation it doesn't satisfy the condition and not displaying the value.
It depends on what your simulator does, but from my experience, especially for low cost
processors, the simulator is often a very simple program that allows to simulate the processor core.
As it has no peripheral like an ADC, there is no way to get either an interrupt or a flag and it will
wait forever. So your program is possibly fine and it's better to work with the real processor.
Beside this, a general remark: you should learn about interruptions.
You have written a function waiting for n milliseconds. But if you go through a function like
this, your processor will just spend power pedaling for nothing. That wouldn't be a problem if
it didn't prevent the processor from doing anything else. Instead of this, you should consider programming
a timer and use this timer interrupt.
Advantages:
- You don't need the processor to work in an empty loop, and you will save power.
- You will have this processing power for other tasks.
Next. I adviced to make a lcd.h and lcd.c files. But you have written everything in the main file.
The result is a risk that you modify a lcd function that already works. If you keep the lcd in a separate
file.h file.c pair, then there is low risk of breaking what works.
Another point. Your code is better than last time becaust it has comments. However it's still full
of obscure and cryptic functions.
Example:
Code:
IO1SET |= 0x00400000; /* EN = 1 */
IO1CLR |= 0x01800000; /* RS = 0, RW = 0 */
Why wouldn't you use #defines instead of these hard-coded numbers?
In your lcd.h, you would write:
#define LCD_ENABLE 0x04000000
#define LCD_RS 0x01000000
#define LCD_RW 0x00800000
NB: I haven't checked which is RW and which is RS. Please check the documentation,
it might be inverted.
And then your code would become:
Code:
IO1SET |= LCD_ENABLE;
IO1CLR |= LCD_RS | LCD_RW;
Advantages:
- The code is self explanatory, you don't even need to explain what you do.
- If you have to reuse the code on another hardware, you can just modify the #define.
Dora