|
|
View previous topic :: View next topic |
Author |
Message |
vasanthan
Joined: 18 Feb 2012 Posts: 3
|
RS-232 and LCD |
Posted: Tue Mar 13, 2012 2:50 am |
|
|
Hi everyone,
I am using PIC 16F887 and CCS-C compiler(version 4.093) plugin in MPLAB IDE ... i simulated the design in proteus and .. its working perfectly.. now i am implementing the same design in hardware ... RS232 module is working separately but does not work when LCD is initialised .. in the code i have disabled two lines .. without these lines code is working .. when these codes are made active there is no output in hardware(computer-hyperterminal). LCD connections are in port D rs232 connections use RC6 and RC7.. where is the problem ? why is RS232 not working when LCD is initialised ?
can you please help me ?
#include <16f887.h>
#device ADC=10
#use delay(clock=16000000)
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use RS232(baud =9600, xmit = PIN_C6, rcv = PIN_C7)
#include <lcd.c>
void main(void)
{
setup_adc(ADC_CLOCK_DIV_8);
while(1)
{
//lcd_init();
//printf( lcd_putc, "Battery Status\n" );
delay_ms(100);
printf ("Battery discharge monitoring \n\r" );
putc('c');
puts("\n\rtemperature measurement");
delay_ms(100);
}
} |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19513
|
|
Posted: Tue Mar 13, 2012 4:04 am |
|
|
Comments first:
ADC_CLOCK_DIV_8, is too fast for 16MHz operation. You need DIV_32.
Add ERRORS to your RS232 declaration. This _must_, repeat _must_ be present when using the hardware UART, unless you add your own error handling code. It is not optional, but _required_.
Without this, the receive UART can become 'hung', if data is arriving and not being read.
Now, post your pin connections for the LCD, and triple check the settings you are using. I'd guess, that you have a problem here, and the status line from the LCD is not being seen by the PIC. It therefore hangs, waiting for the LCD...
Switch the the flex_lcd driver, set it up to match your connections, and try it with 'USE_LCD_RW' disabled. If the serial starts working, then this proves what is happening, and it'll just be a matter of finding 'why'.
Alternatively, I'd be looking for a wiring problem. Possibly a wire whisker somewhere.
Best Wishes |
|
|
dezso
Joined: 04 Mar 2010 Posts: 102
|
|
Posted: Tue Mar 13, 2012 9:41 am |
|
|
Code: | #include <16f887.h>
#device ADC=10
#use delay(clock=16000000)
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use RS232(baud =9600, xmit = PIN_C6, rcv = PIN_C7)
#include <lcd.c>
void main(void)
{
lcd_init(); // You only need to init LCD once !!
setup_adc(ADC_CLOCK_DIV_8);
while(1)
{
printf( lcd_putc, "Battery Status\n" );
delay_ms(100);
printf ("Battery discharge monitoring \n\r" );
putc('c');
puts("\n\rtemperature measurement");
delay_ms(100);
}
} |
_________________ I'm could be wrong many time's, at least I know what I'm doing |
|
|
vasanthan
Joined: 18 Feb 2012 Posts: 3
|
RS232 and LCD PIC16F887 |
Posted: Wed Mar 14, 2012 4:03 am |
|
|
Thanks for your support ...its working now
Thanks and Regards
vasanth |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|