In the s32 example code there is this line of code I don't understand:
PCC-> PCCn[PCC_PORTD_INDEX] = PCC_PCCn_CGC_MASK; /* Enable clock for PORT D */
//followed by this
PTD->PDDR |= 1<<0; /* Port D0: Data Direction= output */
PORTD->PCR[0] = 0x00000100; /* Port D0: MUX = ALT1, GPIO (to blue LED on EVB) */
Why must you enable the clock for port d? What does this do? I have never seen this done on other micros?
thanks#
Hi John,
Most of the peripherals have their bus interface clock gated off by default.
The clock must be enabled before the PORT registers are accessed otherwise it would trigger a bus fault exception.
Regards,
Daniel