cancel
Showing results for 
Search instead for 
Did you mean: 

Transferring Bytes to I2C DR register via DMA.

lonnie
Associate II
Posted on September 24, 2009 at 14:32

Transferring Bytes to I2C DR register via DMA.

3 REPLIES 3
lonnie
Associate II
Posted on May 17, 2011 at 13:24

Does anyone know if it is possible to transmit a single byte (constant value) multiple times to the I2C data register via DMA? I have an EEPROM device connected to the I2C bus. I can successfully write and read to and from the EEPROM using DMA, but I can't write a single value multiple times.

Basic setup includes setting the memory base address for a DMA channel to point to a byte and set the buffer size greater than 1, but don't set memory increment. During a test once the DMA channel is configured and enabled, only 1 byte seems to be transferred to the destination. A code snippet is shown below minus the code.

Code:

//Initialization code

unsigned char cValue = 0xAA;

DMAInitStructure.DMA_MemoryBaseAddr = (tUINT32)&cValue;

DMAInitStructure.DMA_BufferSize = 25;

sDmaInitStructure.DMA_DIR = DMA_DIR_PeripheralSRC;

DMA_Init(DMA1_Channel7,&sDmaInitStructure);

/*After establishing communications with I2C device, transfer bytes to the I2C DR register.

*/

DMA_Cmd(DMA1_Channel7, ENABLE);

jvaque
Associate II
Posted on May 17, 2011 at 13:24

If I'm not wrong, to use I2C+DMA, one should at least transmit 2 bytes.

Check STM32F10xx4 and STM32F10xx6 Errata sheet, where it says

use the I2C with DMA in general, except when the Master is receiving a single byte

It tells you about receiving a single byte, but I guess it also applies for receiving.

lonnie
Associate II
Posted on May 17, 2011 at 13:24

jvaque I have resolved the issue. If the DMA channel's memory increment flag isn't set then it will transmit the same byte for however many times is specified.

The errata says that you shouldn't use DMA to receive 1 byte, but it doesn't mention anything about transmitting 1 byte with DMA. During my testing I2C seems to work without complications transmitting 1 or more bytes received via DMA.

[ This message was edited by: lonnie.walker on 24-09-2009 18:03 ]