Hello guys,
I am having a problem getting SPI1 as Slave, on PORTD, to work on a MKL33Z128VHL4.
When I try to configure the SPI Control Register 1 (SPI1_C1) , HardFault happens imediatly.
In first BOARD_InitPins();
// Config SPI1
SIM_SCGC4_SPI1(1);
PORT_SetPinMux(PORTD,4u, kPORT_MuxAlt2);
PORT_SetPinMux(PORTD,5u, kPORT_MuxAlt2);
PORT_SetPinMux(PORTD,6u, kPORT_MuxAlt2);
PORT_SetPinMux(PORTD,7u, kPORT_MuxAlt2);
Late I'm trying to config SPI Control Register 1 (SPI1_C1)
SPI1->C1=~SPI_C1_SPE_MASK; (In this instruction HardFault happens imediatly)
SPI1->C2=0;
SPI1->C1=SPI_C1_CPHA_MASK;
...
I can't understand this HardFault happens, since exist clock on SPI1 module, and the pins are configurable.
I'm using KDS 3.2.0, SDK 2.0 and FreeRTOS V9.0.0 on the project.
Can semeone help me.
Best Regards,
Hi Bruno,
SIM_SCGC4_SPI1(1); didn't enable the clock gate of SPI1 module.
You should use CLOCK_EnableClock function.
Best Regards,
Robin
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Robin,
Thank's for your reply. It's exactly what's happening.
Best Regards,