S32k I2C Over DMA Using Tresos

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

S32k I2C Over DMA Using Tresos

1,067 Views
AhmedAnwar
Contributor I

Hello NXP,

 

I'm using AutoSar V4.4 MCAL, want to test I2C Over DMA using Tresos, I've configured an I2C channel as master, chose async mode as LPI2C_USING_DMA and referenced a DMA channel in both DMA RX Channel Ref and DMA TX Channel Ref.

 

I've also configured the referenced DMA channel as follows:

AhmedAnwar_0-1645087561170.png

And the Global config as follows:

AhmedAnwar_1-1645087586886.png

Now my question is, in my code, i have to do the following:

 

Mcu_Init& and the rest of Mcu_init sequence

Port_Init

Mcl_Init

I2C_init

 

and then for example, use  /* Master send data */
I2c_AsyncTransmit(0U, &pRequestSend); to send data

 

 

is there anything else that I need to configure? for example the major loop & minor loop settings or are they auto configured and this example is ready to go?

 

Also, in case I want the master to receive data, how is that acheived over DMA, Do I need to fill a dma interrupt or something? Also can the same DMA channel be used for sending/Receiving?

 

Thanks.

 

 

0 Kudos
Reply
1 Reply

970 Views
cuongnguyenphu
NXP Employee
NXP Employee

Hi @AhmedAnwar ,
In your case, you need to create and assign DMA channel for Tx and Rx of both Master and Slave too

cuongnguyenphu_0-1647426098957.png


After that, in your Main application, you also need to enable ISR handler for DMA channels:
Platform_InstallIrqHandler(DMA0_IRQn, &Dma0_Ch0_IRQHandler, NULL_PTR);
Platform_InstallIrqHandler(DMA1_IRQn, &Dma0_Ch1_IRQHandler, NULL_PTR);
Platform_InstallIrqHandler(DMA2_IRQn, &Dma0_Ch2_IRQHandler, NULL_PTR);
Platform_InstallIrqHandler(DMA3_IRQn, &Dma0_Ch3_IRQHandler, NULL_PTR);

cuongnguyenphu_2-1647426876835.png

 



You can also add Interrupt Callback function to get notification when transmit is done:
For DMA0: FlexIO_I2c_Ip_DmaTransferCompleteNotificationShifter0 
For DMA1: FlexIO_I2c_Ip_DmaTransferCompleteNotificationShifter1 
For DMA2: FlexIO_I2c_Ip_DmaTransferCompleteNotificationShifter2 
For DMA3: FlexIO_I2c_Ip_DmaTransferCompleteNotificationShifter3 


For your 2nd question: If you want to sent data from Slave to Master, you should create a "receive request", which can be refer from pRequestSend in example.

cuongnguyenphu_1-1647426830114.png

 



Remember that 'DataDirection' and 'DataBuffer' should be changed to Receive and receive buffer. For more information, you can check my attached example file. This example is modified by S32DS to config S32K144 using FlexIO and I2C0 channel to send and receive data for both Master and Slave

0 Kudos
Reply