My Counter wont count!

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
SaWa_284216
Level 4
Level 4

So I have a simple program, as soon as a GPIO goes high it fires an interrupt which reloads a counter, when the GPIO goes low again it firest another interrupt which reads the counter.

   

 

   

I have checked using a logic analyser that the interrupts are firing correctly but for some reason the counter value never changes, I am feeding it an 11ms signal and a 1MHZ clock so I am expecting the counter to read 65535-11000 = 54535 but it is reading zero. Help

   

 

   

Bundle is attached

0 Likes
5 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked
0 Likes
SaWa_284216
Level 4
Level 4

I clicked very by accident there, the answer is blank 😕

0 Likes
lock attach
Attachments are accessible only for community members.
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Datasheet states that the timer should be stopped.

   

I sketched an alternative solution. at capture interrupt read the captured value and stop the timer.

   

 

   

Bob

0 Likes
SaWa_284216
Level 4
Level 4

I was stopping the timer originally before I went the reload way, oh I like your method with it all in hardware.

   

 

   

So when the capture interrupt fires do I read the counter and do nothing else as the hardware will reload it and whatnot? This is what I was trying to do at first have it all in hardware but I couldnt understand the TCPWM documentation

0 Likes
lock attach
Attachments are accessible only for community members.
SaWa_284216
Level 4
Level 4

Thanks Bob it is working fine now, one thing was missing was that you didnt set "interrupt on capture" in the timer options. I have attached the new updated project for anyone who needs it.

0 Likes