|
|
View previous topic :: View next topic |
Author |
Message |
ploana
Joined: 24 Jul 2006 Posts: 6
|
RS232 |
Posted: Thu Jul 27, 2006 9:44 am |
|
|
Hello
In this programm i work with UART. My poblem is that when is set FORCE_SW, putc() doesn't work right.
What can i do to enable the FORCE_SW at the ***************************************** begining in the program??
#include <18F458.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=25000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, FORCE_SW, BITS=8)
//FORCE_SW ... Will generate software serial I/O routines
// even when the UART pins are specified.
void main() {
unsigned char a=0;
// delay_us(650); //mind 600�s
output_bit( PIN_C5, 1); //CS-WAKE beim Transceiver
delay_ms(600);
output_bit( PIN_C6, 0);
delay_ms( 2 );
output_bit( PIN_C6, 1);
delay_ms( 130 );
output_bit( PIN_C6, 0);
delay_ms( 2 );
output_bit( PIN_C6, 1);
//************************************************************************
//#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, BITS=8)
putc(0x00);
putc(0xAA);
putc(0x01);
getc();
while (TRUE) {
output_high(PIN_D0);
delay_ms(500);
output_low(PIN_D0);
delay_ms(500);
}
}
friendly regards |
|
|
Ttelmah Guest
|
|
Posted: Thu Jul 27, 2006 10:11 am |
|
|
Why?.
If you are using the hardware UART pins, then the hardware UART, will give much better performance, both in terms of sampling incoming data at multiple points, rather than relying on a single sample point, and in terms of allowing other things to be done, while the I/O takes place.
That having been said, to do what you are showing with the software UART, you need a delay, between setting the serial line high, and the putc. You are presumably manually operating the line, to generate a 'break' condition. With the hardware UART, there will actually be a tiny delay, before it starts sending the first character, as it takes control, sets the TRIS register, and transfers the byte to send to the hardware. With the software UART, the start bit, will be almost immediate, so the line will go high for only a fraction of a uSec. Presumably the extra delay in the hardware, is just enough to let it work.
Best Wishes |
|
|
|
|
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
|