Hard Fault When config SPI1_C1 on MKL33

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Hard Fault When config SPI1_C1 on MKL33

690 次查看
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 项奖励
回复
2 回复数

588 次查看
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 次查看
brunoaguiam
Contributor I

Hi Robin,

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

Best Regards,

0 项奖励
回复