my code :
I just want to use spi without interrupt and dma.I can not recieve the data and stucked.
Is the spi configured ok?
gpio_pin_config_t pin_cfg;
spi_master_config_t spi_config;
uint32_t sourceclock;
//config the spi
SPI_MasterGetDefaultConfig(&spi_config);
sourceclock = CLOCK_GetBusClkFreq();
spi_config.outputMode = kSPI_SlaveSelectAsGpio;
SPI_MasterInit(SPI1,&spi_config,sourceclock);
SPI_EnableFIFO(SPI1,false);
//config the cs pin
pin_cfg.pinDirection = kGPIO_DigitalOutput;
pin_cfg.outputLogic = 1;
GPIO_PinInit(GPIOD,4U,&pin_cfg);
while(1){
SPI_WriteData(SPI1, 0x01);
while (0==(kSPI_RxBufferFullFlag&SPI_GetStatusFlags(SPI1))); //stop here ,never continue!!
}
Hi ren suiyi,
About the problem that you can't receive the SPI data, it may also relates to the slave, did you check the SPI wave from the slave?
Is the slave send back the SPI data?
About the SPI code without interrupt and dma, I have the spi driver for your reference, please check it in the attachment, it have the SPI initialization code, and the send receive code.
Please try my code on your side, whether it works on your side.
After testing, please let me know your test result, the attached code can work on my KL26 board.
Wish it helps you!
Have a great day,
Kerry
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------