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

USART - setting parity

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



Joined: 12 Jan 2009
Posts: 33

View user's profile Send private message

USART - setting parity
PostPosted: Wed Jan 28, 2009 4:32 am     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Jan 28, 2009 12:16 pm     Reply with quote

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.
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