Why do I need to enable clock for a port?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Why do I need to enable clock for a port?

1,387 Views
jnbattaglia
Contributor I

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#

Tags (1)
1 Reply

1,254 Views
danielmartynek
NXP TechSupport
NXP TechSupport

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.

pastedImage_1.png

Regards,

Daniel