Part Number: TM4C1294NCPDT
Gents,
Just came across a "demand" that I assumed was possible but now I'm not so sure: I'd like to use a Timer to capture 4 events that take longer than 16-bits count would suffice.
My signal is wired into TxCCP0. The typical period is ~1ms. Image below shows the PWM signal which is being measured, and a 16-bit timer below it, with system clock set at 120MHz.
The transitions are automatically transferred to an array via DMA - which is the less invasive method to read the timers. However, this particular signal spans more than two timer roll-overs, hence I can't use the solution with just one 16-bit timer.
Some ideas below (I'm reading the datasheet while writing the question, so it is likely that an answer will come up in the meantime... but let's keep this for the sake of confirmation or suggestions!)
- If I call TimerConfigure() without TIMER_CFG_SPLIT_PAIR, using just TIMER_CFG_A_CAP_TIME, will the "B" part of the timer decrease 1 unit for every roll of part "A", while still having the CCP active?
(No, interrupts/DMA's are not executed when transitions occur).
- Use prescaler: use of prescaler is not really that clear when checking both the datasheet plus the driverlib user guide. Apparently, there is no function to "enable" it - so I wonder if the mere fact of writing a value with TimerPrescaleSet() enables it? What if the value is 0x00? The function does nothing other than writing into ONE register...
Can we take the opportunity to properly explain what each of the Prescale registers do?
- GPTMTAPR (simple called Prescale): modified by TivaWare with TimerPrescaleSet() and read with TimerPrescaleGet();
What does it do, in human-English?
- GPTMTAPMR (Prescale Match): modified with TimerPrescaleMatchSet() and read with TimerPrescaleMatchGet();
What does it do?
- GPTMTAPS (Prescale snapshot): no TivaWare function.
What does it do?
Registers are hardcoded for TimerA for clarity/search convenience.
Just for the record, I also followed this link for help, but then a TAPV register is mentioned on the post to make things more challenging, as it does not appear in the datasheet registers table...
e2e.ti.com/.../354038
ANYWAY, the real nice feature is that the documentation is confusing but the use is easy: I added a non-zero value to the prescaler after the timer configuration, and as per GPTM chapter on the datasheet, Register Descriptions, entry 18 (GPTMTAR), the value of the prescaler when the capture event occurred is automatically transported to bits 23-16 of that register! So I simply had to do nothing to read it, the timer is now a 24 bits.
TimerConfigure(TIMER0_BASE,(TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_CAP_TIME_UP));
TimerPrescaleSet(TIMER0_BASE, TIMER_A, 4);
Sorry for the meandering post, as it was written during research - there are a few unanswered questions here, mostly due to misleading documentation - help/insight most welcome! - but there are some useful conclusions as well.
Regards
Bruno
