CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

RS-232 and LCD

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
vasanthan



Joined: 18 Feb 2012
Posts: 3

View user's profile Send private message Send e-mail

RS-232 and LCD
PostPosted: Tue Mar 13, 2012 2:50 am     Reply with quote

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: 19436

View user's profile Send private message

PostPosted: Tue Mar 13, 2012 4:04 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Mar 13, 2012 9:41 am     Reply with quote

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 Smile
vasanthan



Joined: 18 Feb 2012
Posts: 3

View user's profile Send private message Send e-mail

RS232 and LCD PIC16F887
PostPosted: Wed Mar 14, 2012 4:03 am     Reply with quote

Thanks for your support ...its working now


Thanks and Regards
vasanth
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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