Bus Fault

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

Bus Fault

Jump to solution
963 Views
PeterFromSweden
Contributor III

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?

0 Kudos
1 Solution
644 Views
Dekiru
Contributor IV

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;

View solution in original post

0 Kudos
1 Reply
645 Views
Dekiru
Contributor IV

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;

0 Kudos