SPI Driver Not working Arm M0+ MKL15Z128VFT4

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

SPI Driver Not working Arm M0+ MKL15Z128VFT4

828 次查看
jonathan_guinta
Contributor I

I'm in the process of debugging a SPI peripheral I'm using with the ARM M0+ uC MKL15Z128VFT4. The OS is BareMetal and the SysTick is at 1ms. The clock speed for the SPI peripheral is 23.405714 kHz. I keep running into an issue where an exception is thrown when the hit the SPI_HAL_SetIntMode(base, kSpiRxFullAndModfInt) and then the debugger jumps to DefaultISR. I have the instruction set in Thumb mode and the debug level at Default -g. Also I do initialize the peripheral driver before this with:

 

//Install interrupt handler for SPI comm

    OSA_InstallIntHandler(SPI0_IRQn, SPI_COM1_IRQHandler);

    //Initialize SPI to Master control

    if(SPI_DRV_MasterInit(*m_instance, &SPI_COM1_MasterState) == kStatus_SPI_Success)

    {

//Configure the SPI bus
SPI_DRV_MasterConfigureBus(*m_instance, &SPI_COM1_MasterConfig0, &SPI_COM1_calculatedBaudRate);
return true;

    }

    return false;

 

So I can't imagine it's the proper initialization of the peripheral that's the cause of this exception being thrown, but I won't rule it out. Any pointers/ideas to help solve this would be much appreciated. BTW, if I manually step through the code with the debugger, the exception isn't thrown, since the debugger is controlling the execution. I've seen this issue arise in the past with the SysTick timer, or the debugger symbol file not being aligned. I'm not sure.

标签 (1)
0 项奖励
回复
1 回复

659 次查看
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Jonathan,

Regarding your question, it seems that there is problem for the following function, pls check.

SPI_DRV_MasterInit(*m_instance, &SPI_COM1_MasterState);

SPI_DRV_MasterConfigureBus(*m_instance, &SPI_COM1_MasterConfig0, &SPI_COM1_calculatedBaudRate);

I do not know what you define the m_instance, if you define it as:

#define m_instance 1 //if you use SPI1

#define m_instance 0 //if you use SPI0

#define m_instance 2 //if you use SPI2

In the case, you should omit the * when you call the API function.

SPI_DRV_MasterInit(m_instance, &SPI_COM1_MasterState);

SPI_DRV_MasterConfigureBus(m_instance, &SPI_COM1_MasterConfig0, &SPI_COM1_calculatedBaudRate);

Hope it can help.

BR

Xiangjun Rong

0 项奖励
回复