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 CCS Technical Support

Forcing hardware UART

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



Joined: 07 May 2005
Posts: 28
Location: Campbell, CA

View user's profile Send private message

Forcing hardware UART
PostPosted: Sat May 21, 2005 11:53 am     Reply with quote

All the chips I use have a hardware UART, but how do I confirm that I'm using the hardware, rather than a software routine? In an 18F452 I have the following:

#use rs232(BAUD=9600,XMIT=PIN_C6,RCV=PIN_C7)


When I printf, I get output out the port, but when I invoke the
#int_RDA interrupt, I get nothing when I send characters TO the
UART.

I have C6 configured as an output, and C7 configured as an input.
What else do I need to do?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat May 21, 2005 12:48 pm     Reply with quote

It's likely a problem in your code somewhere. Post a small test
program and someone on this board (might not be me) will look at
it later today.
Ttelmah
Guest







PostPosted: Sat May 21, 2005 2:17 pm     Reply with quote

One problem might be that if the RS232 has 'idled' to an active state, the OERR bit will be set, which could hang the UART.
Add 'ERRORS' to the RS232 setup, make sure the interrupt is enabled, and the int_rda routine should be called when data arrives. Obviously also, if you are manually controlling TRIS, ensure the I/O bits are set correctly (there is an 'issue' here with the MicroChip ICD, where the bits have to be set as for the oder 16F877, for this to work, which differs from the data sheet recommendation for the 18F452...).

Best Wishes
Charles Linquist



Joined: 07 May 2005
Posts: 28
Location: Campbell, CA

View user's profile Send private message

PostPosted: Sat May 21, 2005 4:02 pm     Reply with quote

I got it running, I stupidly forgot the

enable_interrupts(INT_RDA);

line in main()

BUT... I still would like to know how I select hardware UARTs vs. software UARTS. If I include:

#use rs232(BAUD=9600,XMIT=PIN_C6,RCV=PIN_C7)

and my chip has a hardware UART, will it use it, and if it doesn't have a UART, will it just use the same pins for a bit-banged serial port?
dyeatman



Joined: 06 Sep 2003
Posts: 1933
Location: Norman, OK

View user's profile Send private message

PostPosted: Sat May 21, 2005 4:05 pm     Reply with quote

Thats essentially correct. If you specify the same pins (recv and xmit) used by the UART then the hardware will be used unless you specify otherwise using the FORCE_SW option.
treitmey



Joined: 23 Jan 2004
Posts: 1094
Location: Appleton,WI USA

View user's profile Send private message Visit poster's website

PostPosted: Mon May 23, 2005 8:02 am     Reply with quote

The way I understand it is,.. If you pick a valid HW pin it used hardware unless you use FORCE_SW. That being said, to check it go to the spec and the list file. See if it is using the address for the TX/RX data. ie 18F452 would use address 0xFAE for the RCREG for the recieve byte. page 42 of spec.
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