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

Measuring frequency with 'COUNT'

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



Joined: 10 Apr 2007
Posts: 4
Location: Desenvolvedor

View user's profile Send private message

Measuring frequency with 'COUNT'
PostPosted: Fri May 11, 2007 1:25 pm     Reply with quote

Somebody would have an example in CCS PIC for the function ' COUNT' according to code below:


define OSC 20

' set up portB and portC as all outputs except for portB.0 and portc.0:
TRISB = %00000001
TRISC = %00000001

' TCS230 connections:
OE VAR PORTB.0 ' Output Enable
S0 VAR PORTB.1 ' sensor channel 0 trigger
S1 VAR PORTB.2 ' sensor channel 1 trigger
S2 VAR PORTB.3 ' sensor channel 2 trigger
S3 VAR PORTB.4 ' sensor channel 3 trigger
nLED var PORTB.6 ' illuminating LED
OUT var PORTB.7 ' TCS230 output

tx VAR portc.6 ' serial transmit
rx VAR portc.7 ' serial receive
inv9600 con 16468
CR CON 13
LF CON 10

' counter divisors (miliseconds) for the respective colors.
pRED con 12
pGreen con 6
pBlue con 5

' variables to store color values
RED var word
GREEN var word
BLUE var word

main:
LOW OE
HIGH S0
HIGH S1
LOW nLED

gosub Color

serout2 tx, inv9600, ["R", DEC RED," G",dec GREEN," B",dec BLUE," ",CR,LF]
GoTo main

color:
low S2
low S3
count OUT, pRed, RED
high S3
count OUT, pBLUE, BLUE
high S2
count OUT, pGreen, GREEN
return
kevcon



Joined: 21 Feb 2007
Posts: 142
Location: Michigan, USA

View user's profile Send private message

PostPosted: Fri May 11, 2007 1:45 pm     Reply with quote

This is a pretty stright forward program, you should be able to convert this yourself in no time.
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