This simple program causes a bus fault?!?
int main(void){ uint32_t tmp; tmp = PORTD_PCR14; // <-- Causes HardFault or BusFault?!? // SCB_HFSR = 0x40000000 // SCB_CFSR = 0x8200 return 0;}
TWR-K60, Baremetal project.
Any Ideas what happened?
Solved! Go to Solution.
You have to enable clock to modules before you access them, otherwise fault will happen.
Example:
/* Enable clock gate to used ports */
SIM_SCGC5 |= SIM_SCGC5_PORTE_MASK | SIM_SCGC5_PORTB_MASK | SIM_SCGC5_PORTC_MASK;
You have to enable clock to modules before you access them, otherwise fault will happen.
Example:
/* Enable clock gate to used ports */
SIM_SCGC5 |= SIM_SCGC5_PORTE_MASK | SIM_SCGC5_PORTB_MASK | SIM_SCGC5_PORTC_MASK;