I’m trying to write program that generates PWM output on PTD2 (J2-4) and RED LED is continually blinking .
My problem is with FlexIO register access. On the first “FLEXIO->…” instruction the program corrupts probably with unsupported NMI.
Sample program
// ========== RED LED Configuration
SIM->SCGC5 |= 0x2000; // enable clock to Port E
PORTE->PCR[31] = 0x100; // make PTE31 pin as GPIO for RED LED
PTE->PDDR |= 0x80000000; // make PTE31, output pin
PTE->PDOR |= 0x80000000; // turn off LED
// ========== FlexIO Configuration
FLEXIO->CTRL |= 0x0; // FlexIO disable
SIM->SCGC5 |= 0x80000000; // enable FLEXIO clock
PORTD-> PCR[2] = 0x600; // make PTD2 FXIO0 D2 (Alt. #6)
// PTD->PDDR |=0x4 ; // ???
FLEXIO->TIMCTL[0] |= 0x430202;
// Timer CTL: TRGSEL=0, TRIGPOL=0, TRGSRC=1,PINCGG=3, PINSEL=2, PINPOL=0, TIMOD=2
FLEXIO->TIMCFG[0] |= 0x0; // Timer 0 Config.
FLEXIO->TIMCMP[0] |= 0x58;
FLEXIO->CTRL |= 0x1;