View previous topic :: View next topic |
Author |
Message |
Charles Linquist
Joined: 07 May 2005 Posts: 28 Location: Campbell, CA
|
Forcing hardware UART |
Posted: Sat May 21, 2005 11:53 am |
|
|
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
|
|
Posted: Sat May 21, 2005 12:48 pm |
|
|
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
|
|
Posted: Sat May 21, 2005 2:17 pm |
|
|
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
|
|
Posted: Sat May 21, 2005 4:02 pm |
|
|
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: 1934 Location: Norman, OK
|
|
Posted: Sat May 21, 2005 4:05 pm |
|
|
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
|
|
Posted: Mon May 23, 2005 8:02 am |
|
|
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. |
|
|
|