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 support@ccsinfo.com

How to know if I'm using serial com?
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Marttyn



Joined: 06 Mar 2015
Posts: 28
Location: Spain

View user's profile Send private message Visit poster's website

PostPosted: Thu Jan 30, 2020 6:05 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Jan 30, 2020 6:58 am     Reply with quote

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: 9097
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Jan 30, 2020 8:13 am     Reply with quote

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.....
Smile
Marttyn



Joined: 06 Mar 2015
Posts: 28
Location: Spain

View user's profile Send private message Visit poster's website

PostPosted: Thu Jan 30, 2020 9:32 am     Reply with quote

Noted! Put ERRORS in the #use RS232 Very Happy
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 Sad
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Jan 30, 2020 10:36 am     Reply with quote

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

View user's profile Send private message Visit poster's website

PostPosted: Fri Jan 31, 2020 4:26 am     Reply with quote

PCM programmer wrote:
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.


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

View user's profile Send private message Visit poster's website

PostPosted: Wed Feb 05, 2020 6:42 am     Reply with quote

Thanks for all the help provided!
This is one of my libraries that will benefit from the lessons learned here Smile
http://www.ccsinfo.com/forum/viewtopic.php?p=228035
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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