sarah.sanchez
Junior Member level 2
![Junior Member level 2](/styles/images/ranks/clevel2.gif)
Hi,
There seems to be a problem in our code because whenever we use PIC18, the LCD doesn't display anything but when we used PIC16, there is a display BUT to our dismay, it is displayed in ASCII.
Can someone please help me debug my code so that I can display the results (hopefully not in ASCII anymore) in our LCD using PIC18?
By the way, we're using MikroC Pro to code this.
Thank you and would really appreciate any help.
// LCD module connections
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
// End LCD module connections
unsigned int temp_h1; temp_h2, temp_h3, , temp_c2, temp_c3;
float battery_voltage;
unsigned int tempdiff1; tempdiff2, tempdiff3;
unsigned int *min_tempdiff = 0x50; //0101 0000
void main()
{
ADCON1 = 0x00; //Configure ADC pins as analog
TRISA = 0xFF; //PORTA is input
TRISE = 0x0F; //PORTE bits 4-0 are input
temp_h1 = ADC_Read(0);
temp_h2 = ADC_Read(1);
temp_h3 = ADC_Read(2);
temp_c1 = ADC_Read(3);
temp_c2 = ADC_Read(4);
temp_c3 = ADC_Read(5);
battery_voltage = ADC_Read(7);
TRISB = 0x00;
TRISC = 0xFF;
TRISD = 0x00;
TRISE = 0x00;
tempdiff1 = temp_h1 - temp_c1;
tempdiff2 = temp_h2 - temp_c2;
tempdiff3 = temp_h3 - temp_c3;
PORTB = temp_h1;
temp_h1 = temp_h1 + 48;
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
Lcd_Out(1,1,temp_h1);
PORTC = temp_c1;
PORTD = tempdiff1;
}
There seems to be a problem in our code because whenever we use PIC18, the LCD doesn't display anything but when we used PIC16, there is a display BUT to our dismay, it is displayed in ASCII.
Can someone please help me debug my code so that I can display the results (hopefully not in ASCII anymore) in our LCD using PIC18?
By the way, we're using MikroC Pro to code this.
Thank you and would really appreciate any help.
// LCD module connections
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
// End LCD module connections
unsigned int temp_h1; temp_h2, temp_h3, , temp_c2, temp_c3;
float battery_voltage;
unsigned int tempdiff1; tempdiff2, tempdiff3;
unsigned int *min_tempdiff = 0x50; //0101 0000
void main()
{
ADCON1 = 0x00; //Configure ADC pins as analog
TRISA = 0xFF; //PORTA is input
TRISE = 0x0F; //PORTE bits 4-0 are input
temp_h1 = ADC_Read(0);
temp_h2 = ADC_Read(1);
temp_h3 = ADC_Read(2);
temp_c1 = ADC_Read(3);
temp_c2 = ADC_Read(4);
temp_c3 = ADC_Read(5);
battery_voltage = ADC_Read(7);
TRISB = 0x00;
TRISC = 0xFF;
TRISD = 0x00;
TRISE = 0x00;
tempdiff1 = temp_h1 - temp_c1;
tempdiff2 = temp_h2 - temp_c2;
tempdiff3 = temp_h3 - temp_c3;
PORTB = temp_h1;
temp_h1 = temp_h1 + 48;
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
Lcd_Out(1,1,temp_h1);
PORTC = temp_c1;
PORTD = tempdiff1;
}