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

how to use streams

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



Joined: 07 May 2004
Posts: 263

View user's profile Send private message

how to use streams
PostPosted: Fri Jul 15, 2011 1:23 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Jul 15, 2011 1:33 pm     Reply with quote

Look in the CCS manual at fprintf, fputc, fgetc, etc.
Ringo42



Joined: 07 May 2004
Posts: 263

View user's profile Send private message

PostPosted: Fri Jul 15, 2011 1:47 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Jul 15, 2011 1:50 pm     Reply with quote

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

View user's profile Send private message AIM Address

exception
PostPosted: Thu Jul 21, 2011 3:55 pm     Reply with quote

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
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