|
|
View previous topic :: View next topic |
Author |
Message |
soundscu
Joined: 29 Jun 2007 Posts: 62 Location: Raleigh, NC
|
RS232_ERRORS for multiple hardware uarts |
Posted: Sun Sep 07, 2008 9:32 am |
|
|
I'm using both hardware uarts on an 18F6722 for 2 separate high-speed serial streams. My application requires detection of framing errors for each port individually.
Is there a separate RS232_ERRORS variable for each uart, or do I need to write my own code to directly access RCSTA1 and RCSTA2 separately?
Thanks for your help,
Jim |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Sun Sep 07, 2008 2:21 pm |
|
|
For questions like this the easiest thing to do is to write a small test program. Code: | .................... #use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS, stream=UART1)
.................... fgetc(UART1);
00004: BTFSS PIR1.RC1IF
00006: BRA 0004
00008: MOVFF RCSTA1,rs232_errors
0000C: MOVFF RCREG1,01
00010: BTFSS rs232_errors.1
00012: BRA 0018
00014: BCF RCSTA1.CREN
00016: BSF RCSTA1.CREN
00018: GOTO 0070 (RETURN)
.................... #use rs232(baud=9600, xmit=PIN_G1, rcv=PIN_G2, ERRORS, stream=UART2)
.................... fgetc(UART2);
0001C: BTFSS PIR3.RC2IF
0001E: BRA 001C
00020: MOVFF RCSTA2,rs232_errors
00024: MOVFF RCREG2,01
00028: BTFSS rs232_errors.1
0002A: BRA 0030
0002C: BCF RCSTA2.CREN
0002E: BSF RCSTA2.CREN
00030: GOTO 0072 (RETURN) |
What you see is that both UART1 and UART2 write the status data to the same rs232_errors variable. This implies that the status in rs232_errors will be overwritten as soon as getc is called for either of the two serial ports. |
|
|
soundscu
Joined: 29 Jun 2007 Posts: 62 Location: Raleigh, NC
|
|
Posted: Sun Sep 07, 2008 3:33 pm |
|
|
Agreed, and thank you for the examples.
After finding that RS232_ERRORS does not produce the desired results when both ports are receiving simultaneously, I used #BYTE to declare RCSTA1 and RCSTA2 at their hardware addresses, then tested them instead of RS232_ERRORS for the framing error flag.
This works perfectly.
Jim |
|
|
|
|
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
|