Hello,
I use SM470R1B1M and IAR Embedded Workbench 7.30.4.
My application uses I2C2 interface on SM470R1B1m to get real time stamp from RTC. Since I2C is a slow communication interface, I want to use DMA transfer to free CPU time. Before implement I2C2 DMA mode transfer, I have implemented an I2C2 polling mode device driver. Currently I have no problem to use polling mode device driver to access RTC on I2C2. That means I know how to configure I2C2 properly. However when I develop a DMA mode device driver to read RTC time stamp from I2C2, I have got all zeros in RX data buffer.
According to SM470R1B1M data sheet, I2C2 read uses DMAREQ[9]. There are 32 DMA packets. I assign packet 9 to I2C2 RX. When I use oscillate scope to monitor SCL and SDA, I can see both SCL and SDA signals. However I can tell SDA is not all zeros.
Before read a few bytes of RTC data, SM470 should send 1-byte starting address to RTC. From scope I can see 2-byte signals. The first byte is 7-bit I2C2 address plus 1-bit write signal. The second byte is the starting RTC register address. After that I start DMA read. Since my program will read 7-byte data from RTC through I2C2, I can see 8-byte SDA and SCL signals from scope. The first byte consists of 7-bit I2C2 address and 1-bit read signal. The rest of 7-byte is data from RTC.
The DMA0 interrupt is generated properly. DMA process can be repeated. When DMA0 interrupt is generated, I have checked DMASA09, DMADA09 and DMATC09 values. DMASA09 has I2C2DRR's address which is remain unchanged before and after DMA as expected. At the end of DMA, DMADA09 pointed to the next address of the end of RX data buffer. DMATC09 becomes to "0". For debugging purpose, I initialize RX data buffer with non-zero values. After DMA, the RX data buffer become all zeros.
I try to get help to diagnose what is wrong in my program. There is one place I can think of:
For DMA09 register configuration, I choose DSTMOD_2 and SRCMOD_15. This two bits are for memory selection. According to DMA Reference Guide, source peripheral I2C2 should be SRCMOD_15. The RX data buffer is in RAM. That means for destination, we should select either DSTMOD_2 or DSTMOD_3. I tried both of them and there is no luck.
Anybody has I2C DMA experience? What I did wrong? Thank you!
Lisa