|
|
View previous topic :: View next topic |
Author |
Message |
Will Guest
|
Software UART on hardware pins? |
Posted: Fri Dec 12, 2003 10:21 am |
|
|
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
|
|
Posted: Fri Dec 12, 2003 3:35 pm |
|
|
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
|
|
Posted: Sat Dec 13, 2003 5:17 am |
|
|
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 |
|
|
|
|
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
|