LPC1768 - pulse counter not work

Guest #1822944
Rate this post
• ▲ useful
▼ not useful
Hi, I have to count pulses by LPC1768. I try to use port P0.24 with 
function CAP3.1 to driving Timer3 as counter.

Example of timer3 configuration:
1
//   counter 3
2
   const unsigned long TCR_COUNT_RESET = 2, TCR_COUNT_ENABLE = 0x01;
3
   LPC_SC->PCONP |= (1 << 23);
4
   LPC_TIM3->TCR = TCR_COUNT_RESET;
5
   LPC_TIM3->CTCR = 0x101;
6
   LPC_TIM3->TCR = TCR_COUNT_ENABLE;
And port definition:
1
   LPC_PINCON->PINSEL1 |= (1 << 17) | (1 << 16); // set pin P0.24 as CAP3.1
2
   LPC_GPIO0->FIODIR &=~(1<<24);         // set pin P0.24 as input
And LPC_TIM3->TC not change.
If I configure Timer3 with PCLK as source is OK. When i use P0.24 as 
input pin is also ok. I can count level changes in main loop. But why 
not work counting pulses by timer/counter functionality?
Maybe I have to match any register more?

Regards
Guest #1824350
Rate this post
• ▲ useful
▼ not useful
>LPC_TIM3->CTCR = 0x101;
0x101 is 0b100000001, but bits 31:4 in CTCR are reserved. You probably 
wanted 0b101, which is 0x5. With that configuration you use CAP3.0 and 
not CAP3.1 as input. If I'm right with my assumption this is a good 
example why one shouldn't use magic numbers in sourcecode and use easy 
readable defines instead (or use bit shifts). Mixing this in one file is 
also a dangerous thing ...
#2012356
Rate this post
• ▲ useful
▼ not useful
Hi,

i want to count external pulses on my LPC1768 board. I configured CTCR 
Register for TIMER 0 on CAP0.0. but my TIMER is not working as a COUNTER 
but its working as TIMER only. i.e. it is taking PCLK as the source & TC 
incrimenting by considering PCLK only. can anybody suggest any solution.

Reply

Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.

Formatting
  • [c]C-Code[/c]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.