Problem with LCD inicialization and USART

Status
Not open for further replies.

ykornx

New Member
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.
   }

Here is the USART inicialization:
Code:
OpenUSART(USART_TX_INT_OFF &
		  USART_RX_INT_OFF &
		  USART_ASYNCH_MODE &
		  USART_EIGHT_BIT &
		  USART_CONT_RX &
		  USART_BRGH_HIGH,
		  103);

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.

Thanks!
 

Attachments

  • img1_1.jpg
    131.9 KB · Views: 161
  • img2_2.jpg
    125.7 KB · Views: 160
hola !

i would like to view the hole program ... especially the configuration part !... which compiler do you use !?
 
hola !

i would like to view the hole program ... especially the configuration part !... which compiler do you use !?

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??

Thanks for reply!
 

Attachments

  • rs485.zip
    156.6 KB · Views: 114
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…