I am new to MCUXpresso and I am learning with two FRDM boards. I have an FRDM-KL25 board and an FRDM-KW41Z board.
I started by downloading the GPIO_LED_OUTPUT driver project for each board. Both work as expected.
I then decided to assign a new GPIO pin as an INPUT using the Pins config tool.
In both cases, I chose the same pin.
So, for the FRDM-KL25 board, I chose pin no. 33 (GPIOA) which is labelled as J2[2]/D8.
And for the FRDM-KW41Z board, I chose pin no. 1 (GPIOA) which is labelled as J2[1]/J9[2]/D8/SWD_DIO
Attributes were as follows:
- Direction: INPUT
- GPIO Interrupt: Interrupt on Falling edge
- Slew Rate: FAST
- Pull Select: Pullup
- Pull Enabled: Enabled
I use the same Identifier "NEW_IO" for both cases and I then click on "Update Project".
I return to the development page and build the projects. All is fine so far.
Now, this is where it diverges in terms of success.
When clicking on DEBUG, the FRDM-KL25 works perfectly.
When clicking on DEBUG, the FRDM-KW41Z board crashes when trying to run the BOARD_InitPins(void) function.
The code for that function appears the same in each case.
Here is code for FRDM-KL25 board
void BOARD_InitPins(void)
{
CLOCK_EnableClock(kCLOCK_PortA);
CLOCK_EnableClock(kCLOCK_PortB);
gpio_pin_config_t NEW_IO_config = {
.pinDirection = kGPIO_DigitalInput,
.outputLogic = 0U
};
GPIO_PinInit(BOARD_INITPINS_NEW_IO_GPIO, BOARD_INITPINS_NEW_IO_PIN, &NEW_IO_config);
PORT_SetPinMux(BOARD_INITPINS_DEBUG_UART_RX_PORT, BOARD_INITPINS_DEBUG_UART_RX_PIN, kPORT_MuxAlt2);
const port_pin_config_t NEW_IO = {
kPORT_PullUp,
kPORT_SlowSlewRate,
kPORT_PassiveFilterDisable,
kPORT_LowDriveStrength,
kPORT_MuxAsGpio};
PORT_SetPinConfig(BOARD_INITPINS_NEW_IO_PORT, BOARD_INITPINS_NEW_IO_PIN, &NEW_IO);
PORT_SetPinInterruptConfig(BOARD_INITPINS_NEW_IO_PORT, BOARD_INITPINS_NEW_IO_PIN, kPORT_InterruptFallingEdge);
PORT_SetPinMux(BOARD_INITPINS_DEBUG_UART_TX_PORT, BOARD_INITPINS_DEBUG_UART_TX_PIN, kPORT_MuxAlt2);
PORT_SetPinMux(BOARD_INITPINS_LED_RED_PORT, BOARD_INITPINS_LED_RED_PIN, kPORT_MuxAsGpio);
SIM->SOPT5 = ((SIM->SOPT5 &
(~(SIM_SOPT5_UART0TXSRC_MASK | SIM_SOPT5_UART0RXSRC_MASK)))
| SIM_SOPT5_UART0TXSRC(SOPT5_UART0TXSRC_UART_TX)
| SIM_SOPT5_UART0RXSRC(SOPT5_UART0RXSRC_UART_RX));
}
and here is the code for the FRDM-KW41Z board
void BOARD_InitPins(void)
{
CLOCK_EnableClock(kCLOCK_PortA);
CLOCK_EnableClock(kCLOCK_PortC);
gpio_pin_config_t NEW_IO_config = {
.pinDirection = kGPIO_DigitalInput,
.outputLogic = 0U
};
GPIO_PinInit(BOARD_INITPINS_NEW_IO_GPIO, BOARD_INITPINS_NEW_IO_PIN, &NEW_IO_config);
const port_pin_config_t NEW_IO = {
kPORT_PullUp,
kPORT_FastSlewRate,
kPORT_PassiveFilterDisable,
kPORT_LowDriveStrength,
kPORT_MuxAsGpio};
PORT_SetPinConfig(BOARD_INITPINS_NEW_IO_PORT, BOARD_INITPINS_NEW_IO_PIN, &NEW_IO);
PORT_SetPinInterruptConfig(BOARD_INITPINS_NEW_IO_PORT, BOARD_INITPINS_NEW_IO_PIN, kPORT_InterruptFallingEdge);
PORT_SetPinMux(PORTC, 1U, kPORT_MuxAsGpio);
PORT_SetPinMux(BOARD_INITPINS_DEBUG_UART_RX_PORT, BOARD_INITPINS_DEBUG_UART_RX_PIN, kPORT_MuxAlt4);
PORT_SetPinMux(BOARD_INITPINS_DEBUG_UART_TX_PORT, BOARD_INITPINS_DEBUG_UART_TX_PIN, kPORT_MuxAlt4);
SIM->SOPT5 = ((SIM->SOPT5 &
(~(SIM_SOPT5_LPUART0TXSRC_MASK | SIM_SOPT5_LPUART0RXSRC_MASK)))
| SIM_SOPT5_LPUART0TXSRC(SOPT5_LPUART0TXSRC_LPUART_TX)
| SIM_SOPT5_LPUART0RXSRC(SOPT5_LPUART0RXSRC_LPUART_RX));
}
It throws an exception on this line:
PORT_SetPinConfig(BOARD_INITPINS_NEW_IO_PORT, BOARD_INITPINS_NEW_IO_PIN, &NEW_IO);
So, where have I gone wrong with the FRDM-KW41Z board?