w_arm
Joined: 10 Apr 2007 Posts: 4 Location: Desenvolvedor
|
Measuring frequency with 'COUNT' |
Posted: Fri May 11, 2007 1:25 pm |
|
|
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 |
|