S32k I2C DMA

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

S32k I2C DMA

1,751 Views
hajianik
Senior Contributor I

Hi,

I'm trying to transmit 32 bytes on I2C bus using DMA and I'm using PE to configure this.

This is not working for me.

It works only if I place a break point on the CALL  to LPI2C_DRV_MasterSendData(0,tx_buff1,34,1);  in main and do a step over. That way I can see the CLK and DATA on the scope . I can't get it to work any other way.

I should mention that I could send and read back to the same slave device using PE in none blocking interrupt configuration with no issues at all .

I decided to go with DMA JUST TO REDUCE the CPU LOAD.

I started to this in 2 phases : DMA_TX and then DMA_RX however I'm stuck on1st phase.

I stepped through the code and looked at relevant registers, everything seems ok.

So at this point I need more eyes on this.

By the way I noticed that PE does not or incorrectly initializes DMAMUX. I DON'T KNOW IF THIS IS ABUG OR I MISSED SOMETHING, anyways I do initialize DMAMUX in project.

The project is attached, sorry for all the comment outs.

Thanks  

Tags (1)
3 Replies

1,115 Views
AlinaB
NXP Employee
NXP Employee

Hello Koorosh, 

What version of SDK are you using?

For lpi2c driver one DMA channel can be used to receive and transmit data (you don't need one for transmitting data and another one to receive), the request for DMA channel is changed at runtime. You should remove LPI2C_DRV_MasterSetDmaChannel from the project.

What do you observe if you don't put a break point at LPI2C_DRV_MasterSendData, no data is sent at all, not even the address? 

Best regards, 
Alina 

1,115 Views
hajianik
Senior Contributor I

Hi Banica,

Thank you for your response.

I followed your comment regarding needing only one DMA channel for both I2C_TX/I2C_RX  , Thank you for that.

AND REGARDING THE ISSUE WITH BREAKPOINT :

When I do:

LPI2C_DRV_MasterSendData(0,tx_buff1,34,1);

 without the breakpoint nothing goes out(DMA is used)

However when I do this:

LPI2C_DRV_MasterSendData(0,tx_buff1,34,1);

while ( LPI2C_DRV_MasterGetTransferStatus(INST_LPI2C1, NULL) == STATUS_BUSY) {}; (DMA is used)

It appears it is working.

I have 2 questions about this:

  • what is the point of using DMA , if I still have to wait in a while loop?
  • what if I need to send  back to back SENDS/RECEIVES using DMA? is DMA need to be reinitialized in the Major loop complete interrupt?

 

Thanks

0 Kudos

1,115 Views
AlinaB
NXP Employee
NXP Employee

Hi Koorosh,

 

MasterSendData it’s a non-blocking function, even if you use DMA or interrupts you have to ensure that master ended the transfer. The difference between DMA and interrupts mode is the CPU usage. If your application has other things to do besides sending/receiving data, using the DMA mode could be an advantage.

 

You could also use blocking functions (MasterSendDataBlocking/MasterReceiveDataBlocking) if you only wait to send/receive data in your application.

 

The DMA don’t have to be reinitialized, the LPI2C driver does internally all the configurations for DMA channel, you just have to call again receive/send function.

 

Regards,

Alina

0 Kudos