AnsweredAssumed Answered

Getting a Hard Fault when accessing PIT (FRDM-KE04Z)

Question asked by Mike Silva on Sep 12, 2017
Latest reply on Sep 12, 2017 by Mike Silva

I'm guessing I've just missed something in the data sheet, but I keep getting a hard fault when accessing PIT_MCR.  I've reduced the code to a bare minimum:


void main(void)
    PIT->MCR = 0;         // enable PIT
    } while (1);


This compiles fine (I left out the necessary includes here), and the accesses to PTA work (I've gotten the RGB LED changing colors), but the hard fault happens on the access to PIT->MCR, or any other PIT register.  Here is the generated machine code:


PIT->MCR = 0; // enable PIT
     2200        movs r2, #0
     4B03        ldr r3, =0x40037000
     601A        str r2, [r3] ---- hard fault happens here

As seen, the address for PIT->MCR is correct, 0x40037000.  The toolset is Segger Embedded Studio.  If I do a RMW to change the PIT_MCR bit, the hard fault happens on the read access:


PIT->MCR &= ~2; // enable PIT
     4A04        ldr r2, =0x40037000
     6813        ldr r3, [r2] ---- hard fault happens here
     438B        bics r3, r1
     6013        str r3, [r2] 

Any ideas?