hhhsssmmm
Member level 1
hello
I have successfully interfaced a PIC18F4423 and DS1307 via I2C interface using C18. For now I can read the seconds ticking away and can partailly dispay them on a 20x2 LCD.
Now let me explain my problem.
I can not get the 'units' (right most digit of the second) to roll over back to '0' after it passes '9'. I know i have to break the byte variable in to two nibbles but i try and i get garbage with 'units' after the count passes 9....it starts showing HEX numbers A to F and then random ASCII characters. The left most digit ('tens') I can display perfectly and they even roll over after passing '5' ... (0 - 5).
Below is my code segment where im breaking the 'seconds' byte variable into two nibbles...plz can someone take a look at it and kindly sugget a fix for this problem.
Thank you
hhhsssmmm
I have successfully interfaced a PIC18F4423 and DS1307 via I2C interface using C18. For now I can read the seconds ticking away and can partailly dispay them on a 20x2 LCD.
Now let me explain my problem.
I can not get the 'units' (right most digit of the second) to roll over back to '0' after it passes '9'. I know i have to break the byte variable in to two nibbles but i try and i get garbage with 'units' after the count passes 9....it starts showing HEX numbers A to F and then random ASCII characters. The left most digit ('tens') I can display perfectly and they even roll over after passing '5' ... (0 - 5).
Below is my code segment where im breaking the 'seconds' byte variable into two nibbles...plz can someone take a look at it and kindly sugget a fix for this problem.
Thank you
hhhsssmmm
Code:
//DISPLAYING the 'TENS' of the second
HIGH_nibble = seconds;
HIGH_nibble = HIGH_nibble >> 4;
//convert ASCII
HIGH_nibble += '0';
SendLCD(0x80,0); //activate LCD line 1 ... Column 1
//display on LCD
SendLCD(HIGH_nibble,1);
//DISPLAYING the 'UNITS' of the second
seconds = seconds << 4;
//convert ASCII
seconds += '0';
SendLCD(0x81,0); //activate LCD line 1 ... Column 2
//display on LCD
SendLCD(seconds,1);