I'm trying to get data from an I2C sensor (BNO055) using DMA, but I can't start DMA transmission. I've found plenty of examples for F1, F3 adn F4 STM microcontrollers, but nothing helpful for F0. What I do is:
- I initialize sensor using poll method and it works fine.
- I initialize DMA using this code:
`
void I2C1_DMA_Init(uint8_t *BNO055_DMA_buffer)
{
RCC->AHBENR |= (RCC_AHBPeriph_DMA1);#
DMA_InitTypeDef DMA_str;
DMA_StructInit(&DMA_str);
DMA_str.DMA_PeripheralBaseAddr = (uint32_t)I2C1->RXDR;
DMA_str.DMA_MemoryBaseAddr = (uint32_t)BNO055_DMA_buffer;
DMA_str.DMA_DIR = DMA_DIR_PeripheralSRC;
DMA_str.DMA_BufferSize = 32;
DMA_str.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
DMA_str.DMA_MemoryInc = DMA_MemoryInc_Enable;
DMA_str.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;
DMA_str.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;
DMA_str.DMA_Mode = DMA_Mode_Normal;
DMA_str.DMA_Priority = DMA_Priority_VeryHigh;
DMA_str.DMA_M2M = DMA_M2M_Disable;
DMA_Init(DMA1_Channel3, &DMA_str);
}
`
- I set proper address of sensor memory to be read from using poll method.
- Now I'd like to read 32 bytes using DMA. Do I have to send sensor address using
I2C_TransferHandling()
function? What other parameters should be sent then? What have I missed in DMA initialization that after executing:
I2C_DMACmd(I2C1, I2C_DMAReq_Rx, ENABLE);
DMA_Cmd(DMA1_Channel3, ENABLE);
Nothing happens on the bus (I check it using logic analyzer).