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

PIN input read at a certain frequency

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



Joined: 18 Jun 2010
Posts: 3

View user's profile Send private message Yahoo Messenger

PIN input read at a certain frequency
PostPosted: Thu Aug 19, 2010 11:21 pm     Reply with quote

Hy,

It is the first that I'm working with PICC Compiler and I need some help.

I want to read the input signal on C7 PIN of PIC18F452 at a certain frequency using rs232. Can anyone help me with some example code.

Thanks.

Ela
_________________
Ela
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Fri Aug 20, 2010 7:56 am     Reply with quote

Are you trying to read a serial byte with the usual Start & Stop bits, or do you want to read an arbitrary string of bits?
_________________
The search for better is endless. Instead simply find very good and get the job done.
Wayne_



Joined: 10 Oct 2007
Posts: 681

View user's profile Send private message

PostPosted: Fri Aug 20, 2010 8:03 am     Reply with quote

Not sure what you want to do:-

Do you want to read pin C7 every second via RS232 or do you want to read the frequency of the signal on pin C7 via RS232 ?
pmuldoon



Joined: 26 Sep 2003
Posts: 218
Location: Northern Indiana

View user's profile Send private message

PostPosted: Fri Aug 20, 2010 10:03 am     Reply with quote

The design specs seem a little vague.
ela_vasiliu



Joined: 18 Jun 2010
Posts: 3

View user's profile Send private message Yahoo Messenger

PostPosted: Mon Aug 23, 2010 2:24 am     Reply with quote

So, I want to read the signal on C7 Pin via rs232. My signal has the frequency of 1200Hz and i want to make 16 or 32 readings in each period of the signal.

Sorry if I'm not that explicit but as I've said before I'm a beginner.

Thanks
_________________
Ela
pmuldoon



Joined: 26 Sep 2003
Posts: 218
Location: Northern Indiana

View user's profile Send private message

PostPosted: Mon Aug 23, 2010 5:17 am     Reply with quote

You will need to find out the RS232 properties (baud-parity-stop bits) of the device that is sending the data so you can set up the PIC properly.

You also must match the devices electrical specs. Usually to communicate with an RS232 device you will need something like a MAX232 chip to match signal voltage levels, unless the other device is putting out a TTL level signal.

Then you need to interpret the data coming in. Is it one byte? two bytes? 100 bytes?

Start by looking up the #USE RS232 directive in your manual. Then you can ask more specific questions.
ela_vasiliu



Joined: 18 Jun 2010
Posts: 3

View user's profile Send private message Yahoo Messenger

PostPosted: Mon Aug 23, 2010 6:09 am     Reply with quote

My signal is serial bus of bits, they come in groups of 9 or 18 bits
_________________
Ela
collink



Joined: 08 Jan 2010
Posts: 137
Location: Michigan

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

PostPosted: Mon Aug 23, 2010 6:50 am     Reply with quote

ela_vasiliu wrote:
My signal is serial bus of bits, they come in groups of 9 or 18 bits


So, still use #USE RS232 and set bits=9

And, like pmuldoon said, make sure you match the electrical specs of the other device. RS232 is +- 15V typically where as TTL is 0-5V. A MAX232 chip can solve this.
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Mon Aug 23, 2010 9:18 am     Reply with quote

ela_vasiliu wrote:
My signal is serial bus of bits, they come in groups of 9 or 18 bits

That is a rather odd signal. Can you give a link to the datasheet of the source of this signal, or a scope shot of several examples?
_________________
The search for better is endless. Instead simply find very good and get the job done.
pmuldoon



Joined: 26 Sep 2003
Posts: 218
Location: Northern Indiana

View user's profile Send private message

PostPosted: Mon Aug 23, 2010 9:33 am     Reply with quote

It may not even be a valid RS232 signal. It may just be a string of bits.
Maybe it randomly determines whether to send 9 or 18 bits. Maybe they're half-bits with positive or negative spin. See what happens when I'm left to my imagination!
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Mon Aug 23, 2010 11:26 am     Reply with quote

It should work, if you set the USART to synchronous Master Mode with continuous reception. Consult the PIC18F452 datasheet for details.

From the CCS doc, it can be expected that #use rs232 with SYNC_MASTER_CONT option is supporting the intended operation.
pmuldoon



Joined: 26 Sep 2003
Posts: 218
Location: Northern Indiana

View user's profile Send private message

PostPosted: Mon Aug 23, 2010 11:39 am     Reply with quote

Quote:
It should work, if you set the USART to synchronous Master Mode with continuous reception.


That would require a clock line, also. Wouldn't it? I don't know that there is one in this design.
collink



Joined: 08 Jan 2010
Posts: 137
Location: Michigan

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

PostPosted: Mon Aug 23, 2010 11:52 am     Reply with quote

pmuldoon wrote:
Quote:
It should work, if you set the USART to synchronous Master Mode with continuous reception.


That would require a clock line, also. Wouldn't it? I don't know that there is one in this design.


Yes, it does require a clock line.

We really need the OP to clarify what hardware they're working with.
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