This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Timer2 won't run?

Guru 15580 points

I am trying to use Timer2 (1:2) in 32-bit unchained mode to do a one-time count up to the period register value, after which I want to generate a hardware interrupt to the DSP. However, as soon as I release the counter from reset the PRDINTSTAT12 triggers and the TIM12 counter never increments from 0x00000000. What could I be doing wrong?

Here's my code.

void MyTIMER_trigger(uint32_t in_time)

{

CLRBIT(TMR2->TGCR, TIM12RS); //hold timer in reset

SETBIT(TMR2->INTCTLSTAT, PRDINTSTAT12); //clear prd int status

   SETBIT(TMR2->TCR, ENAMODE12_ONETIME); //enable timer for one-time

   TMR2->TIM12 = 0x00000001; //clear timer counter

   TMR2->PRD12 = TICKS23_12_PER_US * in_time; //load timer period

   TMR2->INTCTLSTAT = 1;  //enable PRD12 interrupt

   SETBIT(TMR2->TGCR, TIM12RS); //release from reset

}

And here is a snapshot of the timer registers immediately after the last step above.

TIMER64P2DSP

REVID = 0x4472020C

EMUMGT = 0x00000003

GPINTGPEN = 0x00000000

GPDATGPDIR = 0x00000000

TIM12 = 0x00000000

TIM34 = 0x10406A4E

PRD12 = 65400

PRD34 = 0xFFFFFFFF

TCR = 0x00800040

_RSVD = **

CAPEVTMODE34 = RISE (0x0)

CAPMODE34 = DISABLE (0x0)

READRSTMODE34 = CONTINUE (0x0)

TIEN34 = NOTGATED (0x0)

CLKSRC34 = INTERNAL (0x0)

ENAMODE34 = EN_CONT (0x2)

PWID34 = ONE_CLK (0x0)

CP34 = PULSE (0x0)

INVINP34 = NON_INVERTED (0x0)

INVOUTP34 = NON_INVERTED (0x0)

TSTAT34 = LOW (0x0)

_RSVD = **

CAPEVTMODE12 = RISE (0x0)

CAPMODE12 = DISABLE (0x0)

READRSTMODE12 = CONTINUE (0x0)

TIEN12 = NOTGATED (0x0)

CLKSRC12 = INTERNAL (0x0)

ENAMODE12 = EN_ONCE (0x1)

PWID12 = ONE_CLK (0x0)

CP12 = PULSE (0x0)

INVINP12 = NON_INVERTED (0x0)

INVOUTP12 = NON_INVERTED (0x0)

TSTAT12 = LOW (0x0)

TGCR = 0x0000AF07

_RSVD = ****************

TDDR34 = 0xa

PSC34 = 0xf

_RSVD = ***

PLUSEN = DISABLE (0x0)

TIMMODE = 32BIT_UNCHAIN (0x1)

TIM34RS = NO_RESET (0x1)

TIM12RS = NO_RESET (0x1)

WDTCR = 0x00000000

REL12 = 0x00000000

REL34 = 0x00000000

CAP12 = 0x00000000

CAP34 = 0x00000000

INTCTLSTAT = 0x00000003

_RSVD = *

_RSVD = *

_RSVD = **********

EVTINTSTAT34 = NOPEND (0x0)

EVTINTEN34 = DISABLE (0x0)

PRDINTSTAT34 = NOPEND (0x0)

PRDINTEN34 = DISABLE (0x0)

_RSVD = *

_RSVD = *

_RSVD = **********

EVTINTSTAT12 = NOPEND (0x0)

EVTINTEN12 = DISABLE (0x0)

PRDINTSTAT12 = PEND (0x1)

PRDINTEN12 = ENABLE (0x1)

CMP0 = 0xFFFFFFFF

CMP1 = 0xFFFFFFFF

CMP2 = 0xFFFFFFFF

CMP3 = 0xFFFFFFFF

CMP4 = 0xFFFFFFFF

CMP5 = 0xFFFFFFFF

CMP6 = 0xFFFFFFFF

CMP7 = 0xFFFFFFFF

Suggestion appreciated.............
Thx,
MikeH