Trap when executing peripheral registers

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

cross mob
User17615
Level 2
Level 2
First like received
Hi,

I am trying to get the GPT (General Purpose Timer) to run, by writing to T3CON (the configuration register for timer T3), and to register T3 (which, according to the datasheet, would reset the value of the timer, if it were working). No matter what value I write to these registers, when running the code on the board, the execution falls into some sort of trap. The program doesn’t crash, it just goes into a ‘DEBUG’ Assembly instruction and doesn’t do anything else. I’ve tried putting the write operations between unlock_safety_wdtcon() and lock_safety_wdtcon(), but that made no difference at all.

Do you have any ideas about what I could try to get GPT T3 to work, or what I am doing wrong at the moment? Do you perhaps have some sample code that I could work from?


#8042000 11601
0 Likes
1 Reply
User17612
Level 4
Level 4
First like received
Hi,

By default, the clock to all peripherals in the AURIX is disabled and so before you can access any of the registers within a peripheral, you need to enable the clock. In addition, as you have found, some of the special function registers are either ENDINIT or Safety ENDINIT protected and so you have to run through the unlock sequence. The Clock Control registers (CLC) is one of these. So, the full sequence of code to enable the clock is contained below, including a line to run T3. I have checked this on a board and the timer does seem to be running.
*
Example Code:
void InitGpt12(void)
{
*** uint16 endinitPw;
*
*** endinitPw = IfxScuWdt_getCpuWatchdogPassword ();
*** IfxScuWdt_clearCpuEndinit (endinitPw);
*
*** /* If the module is disabled then re-enable it */
*** while(GPT120_CLC.B.DISS == (boolean) 1u)
*** {
******* /* Enable GTM */
*** GPT120_CLC.B.DISR = (boolean) 0u;
*** }
*
*** IfxScuWdt_setCpuEndinit (endinitPw);
*
***** GPT120_T3CON.B.T3R = 1;
{color:#000000}}
0 Likes