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

Timer0 doesn’t seem to count external pulses

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



Joined: 09 Aug 2004
Posts: 768
Location: Silicon Valley

View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger

Timer0 doesn’t seem to count external pulses
PostPosted: Mon Jul 27, 2015 2:19 pm     Reply with quote

Folks,

I’m trying to use the Timer0 as a tachometer to keep track of a fan. I can see the square wave on the RA4/T0CKI pin with the oscilloscope. But the counter doesn’t seem to be incrementing.

Fuses:
Code:
#FUSES INTRC_IO                 //Internal RC Osc, no CLKOUT

Timer0 setup
Code:
setup_timer_0(RTCC_EXT_H_TO_L | RTCC_DIV_1);    // Fan tachometer
setup_timer_1(T1_INTERNAL | T1_DIV_BY_8);       // control loop pace
setup_timer_2(T2_DISABLED,0,1);                 // PWM will be derived from Timer2
setup_oscillator(OSC_8MHZ);

Timer0 interrogation
Code:
output_high(FAN_ON);                      // turn on the fan
delay_ms(1000);                           // give some time for the fan to spin up
set_timer0(0);                            // zero the counter
delay_ms(1000);                           // allow time to accumulate counts
output_low(FAN_ON);                       // turn off the fan
if ( get_timer0() == 0 ) {
   return FAN_STUCK;                      // the code gates here when fan is spinning and tachometer is pulsing (approx 120 - 130 Hz)
}

No ISR for Timer0 .

Am I missing something?

Cheers,
- Nick

PIC18F4550
4.081
_________________
Read the label, before opening a can of worms.
kender



Joined: 09 Aug 2004
Posts: 768
Location: Silicon Valley

View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger

PostPosted: Mon Jul 27, 2015 2:28 pm     Reply with quote

Nevermind. It was a hardware problem. Nothing wrong with my timer code.

You, folks, are always an inspiration.
_________________
Read the label, before opening a can of worms.
Ttelmah



Joined: 11 Mar 2010
Posts: 19369

View user's profile Send private message

PostPosted: Mon Jul 27, 2015 2:31 pm     Reply with quote

More to the point, I suspect your 'posting the question', made you look again. This has been mentioned recently. It's surprising how often it works!.

At least for you it did. Laughing
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