|
|
View previous topic :: View next topic |
Author |
Message |
Jody
Joined: 08 Sep 2006 Posts: 182
|
Stream not working |
Posted: Mon Dec 07, 2015 7:06 am |
|
|
Hello,
I have two uarts and two stream outputs...
when I want to send something over the Port2 output nothing happened.
When I disable (the #use rs232 line removed) there is data at the output port.
The same happened when I do this for port1...
What am I doing wrong with the stream assignment or use??
Test code:
main.c
Code: |
#include <main.h>
void main()
{
setup_adc_ports(sAN15);
setup_timer_4(T4_DISABLED,0,1);
while(1)
{
printf(PORT1"Port1\n");
printf(PORT2,"Port2\n");
}
}
|
main.h
Code: |
#include <18F87J50.h>
#device adc=16
#use delay(oscillator=40MHz, clock=48MHz)
#use rs232(uart1,baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,stream=PORT1)
#use rs232(uart2,baud=9600,parity=N,xmit=PIN_G1,rcv=PIN_G2,bits=8,stream=PORT2)
|
Regards,
Jody |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19551
|
|
Posted: Mon Dec 07, 2015 7:58 am |
|
|
Syntax, syntax, syntax......
The printf that talks to streams is _fprintf_.
Code: |
#include <main.h>
void main()
{
setup_adc_ports(sAN15);
setup_timer_4(T4_DISABLED,0,1);
while(1)
{
fprintf(PORT1,"Port1\n"); //also ',' missing here
fprintf(PORT2,"Port2\n");
}
}
|
printf has the ability to work with named output functions as the first parameter, so the compiler does not complain - just doesn't work. It routes to the default port. |
|
|
Jody
Joined: 08 Sep 2006 Posts: 182
|
|
Posted: Mon Dec 07, 2015 8:08 am |
|
|
Aaaah THANKS!!!!!!
And still no I know what to do I can't find it in the manual that you has to use the frpintf if you use different streams..
But we got a forum!!!!!!
REALLY thanks!!!
Regards,
Jody |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19551
|
|
Posted: Mon Dec 07, 2015 8:13 am |
|
|
Manual entry for printf:
Code: |
Syntax:
printf (string)
or
printf (cstring, values...)
or
printf (fname, cstring, values...)
fprintf (stream, cstring, values...)
Parameters:
String is a constant string or an array of characters null terminated.
Values is a list of variables separated by commas, fname is a function
name to be used for outputting (default is putc is none is specified.
Stream is a stream identifier (a constant byte). Note that format
specifies do not work in ram band strings.
|
Which one uses 'stream'...... |
|
|
Jody
Joined: 08 Sep 2006 Posts: 182
|
|
Posted: Mon Dec 07, 2015 9:10 am |
|
|
:oops: :oops: :oops: :oops:
Your right!!!
I just saw it.....
Sorry, I am really ashamed...
Regards,
Jody |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19551
|
|
Posted: Mon Dec 07, 2015 11:34 am |
|
|
Unfortunately though, I feel the manual should actually show it in the samples. However the examples do.
The manuals for CCS are not as good as they were when the compiler first started, and some things are designed to encourage head scratching....
Have fun. |
|
|
|
|
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
|