Question
STM32F3 SPI HAL-Driver Problem
Posted on February 01, 2016 at 17:58
Hi
A while ago we developed a simple application in which data from an ADC (MCP3910) was read via SPI. The SPI-HAL (stm32f3xx_hal_spi.c) driver was version V1.1.1 (from 19-June-2015) Example:void MCP3910_ReadData(SPI_HandleTypeDef *hspi,MCP3910REGS *adc){
uint32_t i; uint8_t adcbuf[6]; adc->ctrlbyte.control_bit.devID = 0x01; // Device ID adc->ctrlbyte.control_bit.regadd = REG_CHANNEL0; // Start register to read adc->ctrlbyte.control_bit.rw = 0x01; // read memset(adcbuf,0,sizeof(adcbuf)); // init buffer HAL_NVIC_EnableIRQ(EXTI3_IRQn); // Enable interrupt for DR-Signal adc->DataReadyFlag = 0; // Init DataReady flag for (i = 0; i < BufferLen; i++){ // read 128 values (24bit) while(!adc->DataReadyFlag); adc->DataReadyFlag = 0; MCP3910_Select(); HAL_SPI_Transmit(hspi,&(adc->ctrlbyte.value),1,1000); // Send control-byte HAL_SPI_Receive(hspi,adcbuf,6,1000); // receive two values (6 bytes) MCP3910_DeSelect(); // merge values adc->raw_I[i] = ( (adcbuf[0] << 16) | (adcbuf[1] << 8) | (adcbuf[2]) ); adc->raw_V[i] = ( (adcbuf[3] << 16) | (adcbuf[4] << 8) | (adcbuf[5]) ); memset(adcbuf,0,sizeof(adcbuf)); } HAL_NVIC_DisableIRQ(EXTI3_IRQn); } Everything worked fine... Now, we updated the STM32CubeF3 Firmware Package to version V1.4.0 / November 13, 2015stm32f3xx_hal_spi.c = V1.2.0 (13-November-2015) In this new configuration, we receive wrong data from the ADC (totally garbage). Has anyone an idea how to fix this issue? Note: If we overwrite the new SPI-HAL driver with the previews one, everything works fine. Thanks for your help Kind regard Martin