2021-08-20 05:43 PM
Hi, I have a custom board based on the STM32H745 and I'm trying to understand an issue I'm experiencing with the SPI Interface. I have a BMP280 attached to SPI1 on the M4 coreand I've successfully written a driver for it both using DMAs and Interrupt. However, I have a strange issue with DMA.
I initially configure my sensor using the following code:
void ConfigSensors(void)
{
// Configure BMP280
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, GPIO_PIN_SET); // NCS Pin
uint8_t baro_res = CheckBMP280ChipID();
if(baro_res == HAL_OK)
{
uint8_t reset_chip_ok = ResetBMP280();
HAL_Delay(1000);
uint8_t set_config_ok = setConfig(&baro);
ReadCalibCoefficients(&baro);
}
}
Function is simple enough. It basically checks the chip ID, resets the sensor, sets the configuration and reads the calibration coefficients.
In my main I have a function that just gets the sensor data and I check it using the debugger.
void BaroTask(void)
{
if(HAL_GetTick() - baro_timer >= BARO_SAMPLE_TIME)
{
ReadTemp(&baro);
ReadPressure(&baro);
ReadAltitude(&baro);
baro_timer+=BARO_SAMPLE_TIME;
}
}
However to get this to work using DMA, I have to set a breakpoint before the CheckBMP280ChipID() function, step through the whole configuration process manually and then click run. Only then am I able to get my sensor readings from the chip.
If I run using interrupt, everything works as expected. If I simply run the code, well baro_res fails and the chip doesn't get setup. However, if I set a breakpoint in the HAL_SPI_TxRxCpltCallback function, the debugger stops at the breakpoint so I know even then the SPI interface and DMA are working.
I'm guessing it's delay or speed issue?? But I'm not quite sure how to resolve this. Any tips are appreciated.
2021-08-23 12:12 AM
I don't see you using DMA anywhere in the code you posted.
Be aware you need to manage the cache appropriately on the STM32H7 when using DMA.
2021-08-23 04:32 AM
Hello @DB.7abatunde ,
Please have a look at this article DMA is not working on STM32H7 devices, which explains the memory layout of the platform and the cache that have an impact on the DMA usage.
Hope this helps you!
When your question is answered, please close this topic by choosing Select as Best. This will help other users find that answer faster.
Imen