View previous topic :: View next topic |
Author |
Message |
Marttyn
Joined: 06 Mar 2015 Posts: 28 Location: Spain
|
|
Posted: Thu Jan 30, 2020 6:05 am |
|
|
I don't understand this:
Code: | #define RS232 definedinc(STDOUT) |
Benefits of define this instead of directly using it?
And also its not needed ERRORS:
#use rs232(UART1, baud=9600, ERRORS)
Problem occur when a stream identifier is used:
#use rs232(UART1, baud=9600, stream=MY_COM) |
|
 |
Ttelmah
Joined: 11 Mar 2010 Posts: 19730
|
|
Posted: Thu Jan 30, 2020 6:58 am |
|
|
Good.
However you should have ERRORS.
Basically ERRORS should always be used with a hardware UART, unless your
own code implements error checking. If you don't have it, the UART can
become hung. Treat it as something that should always be there.
In fact I'd prefer it is CCS made the default behaviour to have this, and
instead you had to use 'NOERRORS' if you did not want it. It'd be a better
implementation..... |
|
 |
temtronic
Joined: 01 Jul 2010 Posts: 9426 Location: Greensville,Ontario
|
|
Posted: Thu Jan 30, 2020 8:13 am |
|
|
I agree with Mr. T, put ERRORS in !
It saves a LOT of hair pulling wondering WHY doesn't it work now ? PIC, PC, USB dongle ???
It should be the default, then again, I think 'all digital I/O pins' should be default as that's all PICs had 3 decades ago.....
 |
|
 |
Marttyn
Joined: 06 Mar 2015 Posts: 28 Location: Spain
|
|
Posted: Thu Jan 30, 2020 9:32 am |
|
|
Noted! Put ERRORS in the #use RS232
Anyway, ive never found any problems with it. But next time could be "the one".
As said in previous post, checking for "STDOUT" works with default stream, but if using other stream ID, then this wont work  |
|
 |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Jan 30, 2020 10:36 am |
|
|
Marttyn wrote: | I dont understand this:
Code: | #define RS232 definedinc(STDOUT) |
Benefits of define this instead of directly using it?
|
In your post earlier in this topic, you showed an example using 'RS232'.
http://www.ccsinfo.com/forum/viewtopic.php?t=58490&start=5
I was just trying to give you what you wanted.
Marttyn wrote: |
Problem occur when a stream identifier is used:
#use rs232(UART1, baud=9600, stream=MY_COM) |
That's because if no stream is put in, the default stream is STDOUT.
You put in your own stream name of MY_COM. The CCS manual says:
Quote: |
putc() or putchar() or / fputc() - Puts a character over the transmit pin
(on the specified stream in the case of fputc, stdout by default). |
and
Quote: |
If fprintf() is used then the specified stream is used where printf()
defaults to STDOUT (the last USE RS232). |
|
|
 |
Marttyn
Joined: 06 Mar 2015 Posts: 28 Location: Spain
|
|
Posted: Fri Jan 31, 2020 4:26 am |
|
|
Oh, i was using an example. I was trying to find if there was some define i could check. As i said: "Of course, 'RS232' is not a real define".
In this case, "definedinc(STDOUT)" is the best bet. I will stick with that.
PCM programmer wrote: | That's because if no stream is put in, the default stream is STDOUT.
You put in your own stream name of MY_COM. The CCS manual says: |
I've read documentation, but i was curious if there was any other variable or constant that was always used, even if a custom stream was declared.
Thanks! |
|
 |
Marttyn
Joined: 06 Mar 2015 Posts: 28 Location: Spain
|
|
 |
|