View previous topic :: View next topic |
Author |
Message |
mcad
Joined: 25 Nov 2007 Posts: 48
|
About the LCD display again |
Posted: Wed Dec 05, 2007 11:39 am |
|
|
Hello all,
I ve a question to you about LCD Display again.
Code: |
lcd_init();
While(...)
{
if(condition)
lcd_gotoxy(1,1)
if(condition)
lcd_gotoxy(1,2)
}
|
the first row display a A value, and the second row display B value. however, I can not see both of the value in the LCD screen. I just see the A value on the first row.
Would you please help me for this? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Dec 05, 2007 11:52 am |
|
|
You have not displayed anything with that code. You need to call
the lcd_putc() function to display the text. Or, you can use printf()
and re-direct the output of printf to the lcd_putc() function. But at
some point, you must call lcd_putc(). Your code above only sets
the cursor position. |
|
|
mcad
Joined: 25 Nov 2007 Posts: 48
|
|
Posted: Wed Dec 05, 2007 11:55 am |
|
|
Sir, of course I used them to display. But, I can only manage to display one row at a time.
I began to consider whether it is legal to change the cursor within the same iteration or not. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Dec 05, 2007 11:59 am |
|
|
Post a test program that shows what you want to do.
Put in the lines of code for lcd_putc(). |
|
|
mcad
Joined: 25 Nov 2007 Posts: 48
|
|
Posted: Wed Dec 05, 2007 12:06 pm |
|
|
Code: |
taken out for a while
|
Last edited by mcad on Wed Dec 05, 2007 1:35 pm; edited 3 times in total |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Dec 05, 2007 12:33 pm |
|
|
Quote: | #int_TIMER2
void INCREASE_CLOCKCYCLE_VALUE(void)
{
if(dec =! 0)
{dec--;}
else
{
check=1;
}
} |
The line in bold is not correct. There is no "=!" operator in C.
Your code just sets 'dec' equal to !0, so dec = 1. |
|
|
mcad
Joined: 25 Nov 2007 Posts: 48
|
|
Posted: Wed Dec 05, 2007 12:38 pm |
|
|
Thanks very much sir for this.
I am correcting it.
would you please tell me any other error you would observe ?
Thanks again |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Dec 05, 2007 12:58 pm |
|
|
Quote: |
int dec;
int speed;
int check;
int val = 70;
dec = ( 3276800 /(4 * val) );
|
This code won't work. The intended result is 11702. But 'dec' is
declared as an 'int'. In CCS, an 'int' is an unsigned 8-bit integer.
It can only hold from 0 to 255. It can't hold 11702.
Also, the expression (4 * val) is equal to 280. This result requires a
16-bit integer to hold it. The compiler will not automatically promote
the result to 16-bits. You have to tell the compiler to do it by casting
'val' to 16 bits. See the changes shown below:
Quote: |
int16 dec;
int speed;
int check;
int val = 70;
dec = ( 3276800 /(4 * (int16)val) ); |
|
|
|
mcad
Joined: 25 Nov 2007 Posts: 48
|
|
Posted: Wed Dec 05, 2007 1:05 pm |
|
|
Thanks and thanks again sir.
I wold really appreciate you for your all clarifications.
I now traced the code and I think that there is no any more error in the code, is there ?
Regards |
|
|
|