i made a program for rfid reader. but i test the program with mikroc terminal program. my lcd constantly showing the same message and my terminal program reads weird characters.
Hardware = pic18f452
software = mikroc terminal program
here is my program
Code: Select all
// LCD module connections
sbit Lcd_RS at RA0_bit;
sbit Lcd_EN at RA2_bit;
sbit Lcd_D7 at RB7_bit;
sbit Lcd_D6 at RB6_bit;
sbit Lcd_D5 at RB5_bit;
sbit Lcd_D4 at RB4_bit;
sbit Lcd_D3 at RB3_bit;
sbit Lcd_D2 at RB2_bit;
sbit Lcd_D1 at RB1_bit;
sbit Lcd_D0 at RB0_bit;
sbit Lcd_RS_Direction at TRISA0_bit;
sbit Lcd_EN_Direction at TRISA2_bit;
sbit Lcd_D7_Direction at TRISB7_bit;
sbit Lcd_D6_Direction at TRISB6_bit;
sbit Lcd_D5_Direction at TRISB5_bit;
sbit Lcd_D4_Direction at TRISB4_bit;
sbit Lcd_D3_Direction at TRISB3_bit;
sbit Lcd_D2_Direction at TRISB2_bit;
sbit Lcd_D1_Direction at TRISB1_bit;
sbit Lcd_D0_Direction at TRISB0_bit;
// End LCD module connections
void main()
{
char rcard[16];
char uart_rd;
int n=0;
int cnt=0;
ADCON1 |= 0x07;
INTCON = 0;
INTCON1 = 0;
INTCON2 = 0;
CCP1CON = 0;
CCP2CON = 0;
TRISA = 0;
TRISB = 0;
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear display
// Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
Lcd_Out(1, 1, "show the card");
UART1_Init(9600); // Initialize UART module at 9600 bps
Delay_ms(100); // Wait for UART module to stabilize
while (n<12) { // Endless loop
if (UART1_Data_Ready()) { // If data is received,
uart_rd = UART1_Read(); // read the received data,
UART1_Write(uart_rd);
n = n+1;
rcard[n] = uart_rd;
}
}
n=n+1;
rcard[n] = 0;
Lcd_out(2,1, rcard); // and send data via UART
}
what is the mistake in the program. nothing received in lcd except "show the card" and my terminal receives weird characters.