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 support@ccsinfo.com

Software UART on hardware pins?

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







Software UART on hardware pins?
PostPosted: Fri Dec 12, 2003 10:21 am     Reply with quote

Hi,
Is it possible to set up a software UART using the hardware UART pins? I would like to use the "invert" option but this isn't available using the hardware UART. I can't see how to tell the compiler not to use the hardware USART.

Will
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Dec 12, 2003 3:35 pm     Reply with quote

Quote:
Is it possible to set up a software UART using the hardware UART pins?

After some experimentation, I found that by using two separate
#use rs232 statements, you can force the compiler to generate
software USART code on the hardware pins. Example:

#include <16F877.h>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 4000000)
#use rs232(baud = 9600, xmit=PIN_C6, INVERT)
#use rs232(baud = 9600, rcv=PIN_C7, INVERT)

main()
{
char c;
putc(0x55);
c = getc();
while(1);
}

This was tested with PCM vs. 3.180. I checked the .LST file
to verify that software USART code has been generated.
Will
Guest







PostPosted: Sat Dec 13, 2003 5:17 am     Reply with quote

Superb. The only slight problem is I am using streams, but this I have solved myself by assigning an OUT and IN stream to the two #use commands:

#use rs232(baud=9600,parity=N,xmit=PIN_C6,bits=8,stream=OUT,INVERT)
#use rs232(baud=9600,parity=N,rcv=PIN_C7,bits=8,stream=IN,INVERT)
#use rs232(baud=38400,parity=N,xmit=PIN_C1,rcv=PIN_C0,bits=8,stream=VFD)

works a dream, thanks. It’s a shame I hadn’t got the hardware the right way as now I have to work in software without the nice hardware buffer/interrupt! Nothing like a software fix to a hardware problem J

Thanks again,

Will
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