Hi all, I'm using Kinetis controller and ihave a question for lpt(low power timer). I'm using LPT as counter(counter and compare registers are 16-bit wide) and i need to count 32 bit value instead of 16 bit. can i cascaded the LPT?
Or, If you have only one LPTMR avaliable, you can set prescaler to 65536, count the upper 16 bits and then disable prescaler and count the lower 16 bits.
Hi martin,
I dint get your answer exactly. After i set prescaler, how to count? can you briefly tell us; it will be helpuful.
Hi!
Let's say you have uint32_t count value. What you need to do is to split counting in two steps:
In the first step you configure LPTMR to run 65536 times slower to count (count & 0xFFFF0000) clock cycles. Then you disable prescaler to count the remaining time - the lower 16 bits of your count value.
Thank you martin. its a helpful answer.
Hi Sujai,
It is possible. You can configure both timers, start one timer at any moment and then start the second timer inside the interrupts of the first timer. E.g.
int main(void)
{
init_LPTMR0 ();
init_LPTMR1 ();
LPTMR0_CSR |= LPTMR_CSR_TEN_MASK; //Turn on LPT and start counting
while(1)
{
}
return 0;
}
void LPTimer0_IRQHandler(void)
{
LPTMR1_CSR |= LPTMR_CSR_TEN_MASK; //Turn on LPT and start counting
}
Best regards,
Carlos
Technical Support Engineer
Hi Carlos,
Thank you for your reply. Yeah i was using same method in a different approach. i was trying to cascade it in hardware. Now im using same method and is working.
thank you carlos.
Hi Sujai,
I am glad your problem was solved.
If you find our responses useful I encourage you to mark them as helpful or correct answer. This will help other members find the best answers as well.
Best regards,
Carlos
Technical Support Engineer