|
|
View previous topic :: View next topic |
Author |
Message |
mshearer
Joined: 12 Jan 2009 Posts: 33
|
USART - setting parity |
Posted: Wed Jan 28, 2009 4:32 am |
|
|
Hi,
with regards to setting parity for outgoing messages.
if
Code: | #use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, parity=O, bits=8) |
is used. then is there no need to implement your own code for generating the correct TX9D bit?
cheers,
Matt |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Jan 28, 2009 12:16 pm |
|
|
Make a test program:
Code: | #include <16F877.h>
#fuses XT, NOWDT, BROWNOUT, PUT, NOLVP
#use delay(clock=8000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, parity=O, bits=8)
//========================
void main()
{
char c;
putc(c);
while(1);
} |
Set the project build options to "Symbolic" mode for the List file format.
Compile it.
Then look at the .LST file. Look at the code that handles the putc():
Quote: | 000E: GOTO 00A
000F: BTFSS PIR1.TXIF
0010: GOTO 00F
0011: MOVLW FE // Clear bit D0
0012: BSF STATUS.RP0
0013: ANDWF TXSTA,F // Bit D0 is the TX9D bit
0014: BCF STATUS.RP0
0015: BTFSS @@23.0
0016: GOTO 01A
0017: BSF STATUS.RP0
0018: BSF TXSTA.TX9D // Set it
0019: BCF STATUS.RP0
001A: MOVF ??65535,W
001B: MOVWF TXREG |
Consult the Special Function Register bit map in the PIC data sheet to
see which bit in TXSTA is the TX9D bit. (As shown in comments above)
You can answer most questions about code generation by making a
test program and consulting the data sheet. |
|
|
|
|
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
|