Hard Fault When config SPI1_C1 on MKL33

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

Hard Fault When config SPI1_C1 on MKL33

690 Views
brunoaguiam
Contributor I

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,

0 Kudos
Reply
2 Replies

588 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi Bruno,

SIM_SCGC4_SPI1(1); didn't enable the clock gate of SPI1 module.

You should use CLOCK_EnableClock function.

CLOCK_EnableClock.png

kCLOCK_Spi1.png

Best Regards,

Robin

 

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

588 Views
brunoaguiam
Contributor I

Hi Robin,

Thank's for your reply. It's exactly what's happening.

Best Regards,

0 Kudos
Reply