Hi, i'm trying to do rs485 communication between 2 PIC18f6585 using the USART. I've made simple communication - PIC1 sends message, PIC2 reads the message and send it back to PIC1. This thing works well. I'm trying to connect an LCD to visualize the message from PIC2 but when i put the lcd inicialization function in the main program the comunication doesn't work. I'm posting 2 images to show how this all is connected and sample of the functions. I'm trying to simulate this in Proteus.
The first image is with lcd_init() in main program and puts text on the LCD , and the second without the lcd_init().
Here is my LCD initialization function:
Code:
void lcd_init ()
{
Delay10TCYx(110);
TRISD = PORTD = 0xFF; // inicializirane kato vhodove
wrcmd(LCD_SETFUNCTION); // 4-bit mode - 2 line - 5x7 font.
wrcmd(LCD_SETVISIBLE+0x04); // Display on, no cursor - no blink.
wrcmd(LCD_SETMODE+0x03); // Automatic Increment - No Display shift.
wrcmd(LCD_SETDDADDR+0x0F); // Address DDRAM with 0 offset 80h.
}
When i put the lcd_init() in the main function where the USART initialization and the send/recieve routines are the communication doesn't work. But if i send something to the LCD it's OK.
Hi, the problem is solved! I've moved the lcd_init function down below the code for transferring data and it's work. Then i put it back on top and it works again. I can't understand all this thing with the initialization...maybe it was something with the compiler, i don't know. I am using the C18 compiler.
I'm posting the whole project.
Now i have problems displaying the returned from PIC2 message on the PIC1's LCD
If you can help??