|
|
View previous topic :: View next topic |
Author |
Message |
Ringo42
Joined: 07 May 2004 Posts: 263
|
how to use streams |
Posted: Fri Jul 15, 2011 1:23 pm |
|
|
I'm missing something with the streams parameter in use232
This works
Code: | #include <18F2221.h>
#fuses HS,NOWDT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=115200, xmit=PIN_c6, rcv=PIN_c7,errors,bits=8,parity=N,)
//#use rs232(baud=115200, xmit=PIN_c6, rcv=PIN_c7,errors,bits=8,parity=N, stream=lidar)
//#use rs232(baud=115200, xmit=PIN_c0, rcv=PIN_c1,errors,bits=8,parity=N, stream=debug)
#include <stdlib.h>
void main ()
{ int i=0;
while(1)
{
// printf(lidar,"test %u\r\n",i++);
printf("test %u\r\n",i++);
delay_ms(1000);
}
} |
but this does not
Code: | #include <18F2221.h>
#fuses HS,NOWDT,NOLVP
#use delay(clock=20000000)
//#use rs232(baud=115200, xmit=PIN_c6, rcv=PIN_c7,errors,bits=8,parity=N,)
#use rs232(baud=115200, xmit=PIN_c6, rcv=PIN_c7,errors,bits=8,parity=N, stream=lidar)
//#use rs232(baud=115200, xmit=PIN_c0, rcv=PIN_c1,errors,bits=8,parity=N, stream=debug)
#include <stdlib.h>
void main ()
{ int i=0;
while(1)
{
printf(lidar,"test %u\r\n",i++);
// printf("test %u\r\n",i++);
delay_ms(1000);
}
} |
for this simple test shouldn't they work the same? did I miss a step? _________________ Ringo Davis |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Jul 15, 2011 1:33 pm |
|
|
Look in the CCS manual at fprintf, fputc, fgetc, etc. |
|
|
Ringo42
Joined: 07 May 2004 Posts: 263
|
|
Posted: Fri Jul 15, 2011 1:47 pm |
|
|
ok I get it, you have to do fprintf when you use a stream.
Next question, I don't see this addressed in the manual. If you have 2 streams defined and one of them uses the Hardware Rx and TX pins. Does int_rda always fire on the stream that uses the hardware pins? I think it does but I want to make sure there is not something else that happens when using streams. _________________ Ringo Davis |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Jul 15, 2011 1:50 pm |
|
|
Code: | Does int_rda always fire on the stream that uses the hardware pins? |
That's correct. #int_rda only works with the hardware UART.
If you want an interrupt on a software UART, you could use pin B0 for the
Rx, and use #int_ext to detect the start of a char and receive it using
fgetc inside the isr. |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
exception |
Posted: Thu Jul 21, 2011 3:55 pm |
|
|
with the appropriate pic and hardware design -
you can do an #INT mediated RX function
using a B port edge trigger INT and
the matching pin as your soft RX input -
i have code somewhere that shows how
it does have limits however in that
it CAN mess up a synchronous XMIT on the soft uart |
|
|
|
|
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
|