2014-02-11 05:00 AM
Hi all,
I'm trying to use the SPI interface on a STM32F207 with CMSIS. Below you my sample code can be seen. The problem there is that within the function drv_Info->SendData(...) the function waits for the semaphore_busy but it somewhere hold and never released and therfore the function waits there forever. How can I make the SendData(..) function work? Is my code correct? Every hint is very welcome Benjaminvoid th_SPI (void const *argument){
ARM_SPI_STATUS status;
ARM_DRV_VERSION version;
ARM_SPI_CAPABILITIES drv_capabilities;
uint32_t busSpeed;
uint8_t sendData[3];
uint32_t cr1;
sendData[0] = 16;
sendData[1] = 24;
sendData[2] = 144;
drv_info = &Driver_SPI1;
status = drv_info->Initialize(spiSignalCB);
status = drv_info->PowerControl(ARM_POWER_FULL);
SPI1->CR2 |= SPI_CR2_SSOE; //enable SlaveSelect
SPI1->CR1 |= SPI_CR1_MSTR; //necessary to enable Master Mode
status = drv_info->Configure(ARM_SPI_CPOL1_CPHA1,ARM_SPI_MSB_LSB); //clk polarity and phase see Reference manual and ad7794 datasheet
busSpeed = drv_info->BusSpeed(1e4);
drv_info->SlaveSelect(ARM_SPI_SS_ACTIVE);
status = drv_info->SendData(sendData,3);
if(status == ARM_SPI_ERROR){
status ++;
}
}
#spi #cmsis #stm32
2014-02-11 05:05 AM
I don't know anything about the CMSIS drivers, but if the peripheral is non-responsive, I'd start by checking if it's clock is correctly enabled.
2014-02-12 01:40 AM
I would make sure too look at the status variable for any errors.
Also, try and initialize it like they do:http://www.keil.com/pack/doc/CMSIS/Driver/html/index.htmlRegards,/rygelxvi2014-02-13 04:45 AM
Thank you for your comments.
I have checked the registers and saw that SPI1EN on APB2ENR and GPIOAEN on AHB1ENR has been set. Has there anything more to be set? I think the problem aren't the registers, it's more the mentioned semaphore which doesn't get released.2014-02-17 07:25 AM
I'm having the exact same problem, and I'm connected to an Aardvark SPI emulator device (slave mode). I get stuck on the same semaphore busy flag.
I tried instead calling the TransferByte(byte) command to just send a single byte, which doesn't appear to use that semaphore. In the spi code, this function places the data in the outgoing data register then waits for a response, which it never receives. However, when I debug and step through each line, the line where the data is placed in the outgoing register: ptr_spi->spi->DR = out;The ''DR'' remains 0x0000, whereas ''out'' is 0x41 (''A''). Since the ''DR'' doesn't appear to even change, the SPI subsystem doesn't send anything and thus doesn't receive anything. I encourage you to try this TransferByte function instead and see what you get.2015-02-12 03:08 AM
Hi All
i'm stuck with the same problem.Did anyone solve it?thanksDavide