Hard Fault When config SPI1_C1 on MKL33

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Hard Fault When config SPI1_C1 on MKL33

693件の閲覧回数
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,

ラベル(2)
0 件の賞賛
返信
2 返答(返信)

591件の閲覧回数
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!
-----------------------------------------------------------------------------------------------------------------------

591件の閲覧回数
brunoaguiam
Contributor I

Hi Robin,

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

Best Regards,

0 件の賞賛
返信