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

rs232 with 7bit 2stop bit

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



Joined: 15 Jul 2005
Posts: 1

View user's profile Send private message

rs232 with 7bit 2stop bit
PostPosted: Fri Jul 15, 2005 10:15 am     Reply with quote

help! how can you use the integratet UART with 7bit and 2stop bit?
PIC18F4550. I did not find any information to any PIC with UART.
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Fri Jul 15, 2005 10:36 am     Reply with quote

http://www.ccsinfo.com/forum/viewtopic.php?t=20501&highlight=rs232+stop

Best wishes,

Humberto
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Fri Jul 15, 2005 11:01 am     Reply with quote

There is no direct support for 7N2, both in hardware or software UART. It is easy to simulate when you realise that a stop bit equals a databit with a logic high level. Data is transmitted with the least significant bit first. The trick is to configure RS-232 for 8N1 and make sure to set the most significant bit (MSB) for every byte sent.

Code:
#use rs232(baud=9600, xmit=PIN_TX, rcv=PIN_RX, parity=N, bits=8)

// Function to send data as 7 bits, 2 stop bits.
void Put7N2(int8 Databyte)
{
  bit_set(DataByte, 7);  // Simulate an extra stop bit by setting the MSB
  putc(DataByte);
}

void main()
{
  printf(Put7N2, "Hello world.\n\r");
 
  while(1)  ;   // Loop forever, prevent the processor going to sleep
}


Note: I haven't tested this code, but you get the idea.
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