⚠️
Hi there.. thanks for coming to the forums. Exciting news! we’re now in the process of moving to our new forum platform that will offer better functionality and is contained within the main Dialog website. All posts and accounts have been migrated. We’re now accepting traffic on the new forum only - please POST any new threads at//www.xmece.com/support. We’ll be fixing bugs / optimising the searching and tagging over the coming days.
2 posts / 0 new
Last post
埃里克Scammell
Offline
Last seen:2 years 11 months ago
加入:2017-03-15 13:28
I2C DMA

Hi,

I am using I2C to communicate with a sensor, and need to use DMA for a high-bandwidth read operation.
I am able to get the sensor ready to send the data, and can see the data being transmitted if I write 0x0100 to I2C_DATA_CMD_REG (as is done in i2c_eeprom.c).
What I have not yet managed is to use the DMA to complete this exchange. I can queue several reads by writing to I2C_DATA_CMD_REG more than once, but I haven't worked out if I can
have the DMA automate the process.

Can anyone tell me what I need to do to get data out of an I2C slave by DMA?

Thank you,
埃里克

Keywords:
Device:
MT_dialog
Offline
Last seen:2 months 1 week ago
工作人员
加入:2015-06-08 11:34
Hi Eric,

Hi Eric,

There is no example for using the I2C with the DMA, in order to get this to work in a read for example you will need to write the address of the slave that you would like to read, manually, in order for the device to output the address of the slave and the slave's register, and the above should be done quick enough in order to the module not to send a STOP condition. So you will have to configure two DMA channels in order to write and read, you will need to set up a channel that will have as source the the I2C_DATA_CMD_REG and as a destination the buffer (use DMA_setup struct in order to pass the configurations). After setting up the receiving side you will need to setup a transmit channel in order to send from the DMA to the I2C module in order to generate the clocks by writing to the I2C_DATA_CMD_REG the value 0x100 set the bit for reading and generate the clock. So the source address of the second channel would be a variable with the value 0x100 and the destination address will be the I2C_DATA_CMD_REG. After you have set up the the channels initialize them via the dma_initialization_function() (should be invoked two times one for each channel) and then enable the DMA via the dma_channel_enable() (again two invokations one for each channel). So after completing with the setting up of the DMA's you will have to send manualy the write command, and after that enable the DMA by SetWord16(I2C_DMA_CR_REG,TDMAE+RDMAE);

Thanks MT_dialog