AnsweredAssumed Answered

Crash on configuring the ADC pin

Question asked by Gaurav Banyal on Sep 7, 2017
Latest reply on Sep 10, 2017 by Mark Butcher

Hello,

 

I am using this device MKL03Z32VFG4. Everything else that I want to use on the MCU works but as soon as I add the following line to the pin-mux setting, the system always crashes at this line.

==========

PORT_SetPinMux(PORTA, PIN0_IDX, kPORT_PinDisabledOrAnalog); /* PORTA0 (pin 14) is configured as ADC0_SE15 */

=================

 

Please help me. I need to use this pin as the analog pin.

 

The function where this line is added is given below. (all the settings are done using the pins tool)

===========

void BOARD_InitPins(void) {
CLOCK_EnableClock(kCLOCK_PortA); /* Port A Clock Gate Control: Clock enabled */
CLOCK_EnableClock(kCLOCK_PortB); /* Port B Clock Gate Control: Clock enabled */

#if defined(BATT_MEASUREMENT_IMPLEMENTED) && BATT_MEASUREMENT_IMPLEMENTED == 1
PORT_SetPinMux(PORTA, PIN0_IDX, kPORT_PinDisabledOrAnalog); /* PORTA0 (pin 14) is configured as ADC0_SE15 */
#endif
PORT_SetPinMux(PORTA, PIN3_IDX, kPORT_PinDisabledOrAnalog); /* PORTA3 (pin 3) is configured as EXTAL0 */
PORT_SetPinMux(PORTA, PIN4_IDX, kPORT_MuxAsGpio); /* PORTA4 (pin 4) is configured as PTA4 */
PORT_SetPinMux(PORTA, PIN5_IDX, kPORT_MuxAsGpio); /* PORTA5 (pin 5) is configured as PTA5 */
PORT_SetPinMux(PORTA, PIN6_IDX, kPORT_MuxAsGpio); /* PORTA6 (pin 6) is configured as PTA6 */
PORT_SetPinMux(PORTA, PIN7_IDX, kPORT_MuxAsGpio); /* PORTA7 (pin 7) is configured as PTA7 */

PORT_SetPinMux(PORTB, PIN0_IDX, kPORT_MuxAsGpio); /* PORTB0 (pin 8) is configured as LLWU_P4 */
PORT_SetPinMux(PORTB, PIN1_IDX, kPORT_MuxAlt2); /* PORTB1 (pin 13) is configured as LPUART0_TX */
PORTB->PCR[1] = ((PORTB->PCR[1] &
(~(PORT_PCR_PE_MASK | PORT_PCR_ISF_MASK))) /* Mask bits to zero which are setting */
| PORT_PCR_PE(PCR_PE_ENABLED) /* Pull Enable: Internal pullup or pulldown resistor is enabled on the corresponding pin, if the pin is configured as a digital input. */
);
PORT_SetPinMux(PORTB, PIN2_IDX, kPORT_MuxAlt2); /* PORTB2 (pin 14) is configured as LPUART0_RX */
PORT_SetPinMux(PORTB, PIN3_IDX, kPORT_MuxAlt2); /* PORTB3 (pin 11) is configured as I2C0_SCL */
PORT_SetPinMux(PORTB, PIN4_IDX, kPORT_MuxAlt2); /* PORTB4 (pin 12) is configured as I2C0_SDA */
PORT_SetPinMux(PORTB, PIN5_IDX, kPORT_MuxAsGpio); /* PORTB5 (pin 13) is configured as PTB5 */
SIM->SOPT5 = ((SIM->SOPT5 &
(~(SIM_SOPT5_LPUART0RXSRC_MASK))) /* Mask bits to zero which are setting */
| SIM_SOPT5_LPUART0RXSRC(SOPT5_LPUART0RXSRC_LPUART_RX) /* LPUART0 Receive Data Source Select: LPUART_RX pin */
);
}

 

===========

 

Best regards,

Gaurav.

Outcomes