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

Serial stream of data

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



Joined: 29 Dec 2003
Posts: 3

View user's profile Send private message

Serial stream of data
PostPosted: Mon Dec 29, 2003 2:42 pm     Reply with quote

Hi

I've a task for my self. I need to read a stream of serial data and when a special/unique number of charaters are present - lets say turn on a led.

Eg. 00 0D 45 56 78 = LED ON

Can that be done?

The serial stream is 9600 baud

Do I need to use interrupt (input on B0 on a 18f452)

Rgds

Jesper
dyeatman



Joined: 06 Sep 2003
Posts: 1933
Location: Norman, OK

View user's profile Send private message

Serial Stream
PostPosted: Mon Dec 29, 2003 3:14 pm     Reply with quote

Yes, it can be done very easily. You can use the UART or bit bang in software as you choose. For a simple application like this either should work.

As the characters come in (I assume you know what the first char of the desired string is) compare each char to one you define as the start char. Once you see it set a start_char_seeen flag then compare each succeeding char until you complete the desired sequence. If you get a mismatch in the middle of the sequence you reset the start_char_seen flag and then sit and wait for the begining char to show again.

There are several examples of receive routines in the CCS examples you can use for getting started. Search on the word "queue" in this forum for a lot of good info as well.

Good Luck,
Dave
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