Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Problem with LCD inicialization and USART

Status
Not open for further replies.

ykornx

Newbie level 4
Joined
Jun 17, 2010
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,319
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(img1_1) is with lcd_init() in main program and puts text on the LCD , and the second(img2_2) 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!
 
Last edited by a moderator:

it is tough to help you if you make helping you that difficult.
 

millwood said:
it is tough to help you if you make helping you that difficult.
ok, maybe i couldn't explain exactly what the problem is, and didn't post the whole code but the problem is fixed. I didn't understand exactly where was the problem, but in time i've changed the lcd_init() place in the code and in one moment it starts to work. Now wherever i place the lcd_init() it works!

Thanks for reply!
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top