Sent from Mail for Windows 10
I am trying to get the FIRC out to pb5 the following code compiles but traps on the highlighted statement when I try to right the pin mux.
/ port setup
PTB -> PDDR |= 0b10000; //Set PORT B5 to an output register
PORTB-> PCR[0b100000] |= 0b10100000000; //set port function to 5 for clkout function
SCG ->FIRCDIV |= 0b100000000; //Set CLKDIV2 to Divide by 1
SCG-> FIRCCSR |= 0b1001; //Enable FIRC regulator and FIRC
SIM->CHIPCTL |= SIM_CHIPCTL_CLKOUTSEL(0b0110); // select FIRC for input to clkout multiplexor
SIM->CHIPCTL |= SIM_CHIPCTL_CLKOUTDIV(0b101); // set clkout divisor to 6 for 8MHz output
SIM->CHIPCTL |= SIM_CHIPCTL_CLKOUTEN(0b1); // enable clkout
int counter = 0;
for (;;) {
counter++;
counter %= COUNTER_LIMIT;
}
Any suggestions on how to modify this line of code
Jim
Hi,
try to use below code for B5 pin setting
PCC-> PCCn[PCC_PORTB_INDEX] = PCC_PCCn_CGC_MASK; /* Clock for PORT B */
PORTB->PCR[5] = PORT_PCR_MUX(5); /* Port B5: MUX = ALT5, CLKOUT */
BR, Petr
Here is the trap statement I get when single stepping through the code
Target has been RESET and is active.
BusFault: A precise (synchronous) data access error has occurred.
Possible BusFault location: 0x4004A014.
HardFault: A fault has been escalated to a hard fault.
I am using a s32k144 evb board