rt1170 i2c dma transfer

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

rt1170 i2c dma transfer

1,569 Views
vladimirchernin
Contributor III

Hi!

I have a problem to launch I2c6 by using DMA i dont see what a problem but trasnmit is fail if i dont use DMA everything works in blocking mode. what is wrong in code below?

thanks 

void BOARD_LPI2C_Init_DMA(LPI2C_Type *base, uint32_t clkSrc_Hz)
{
lpi2c_master_config_t lpi2cConfig = {0};

CLOCK_EnableClock(kCLOCK_Lpi2c6);
LPI2C_MasterGetDefaultConfig(&lpi2cConfig);

lpi2cConfig.debugEnable = false;
lpi2cConfig.ignoreAck = false;
lpi2cConfig.pinConfig = kLPI2C_2PinOpenDrain;
lpi2cConfig.baudRate_Hz = 1000000U;
lpi2cConfig.busIdleTimeout_ns = 0;
lpi2cConfig.pinLowTimeout_ns = 0;
lpi2cConfig.sdaGlitchFilterWidth_ns = 0;
lpi2cConfig.sclGlitchFilterWidth_ns = 0;
LPI2C_MasterInit(base, &lpi2cConfig, clkSrc_Hz);
//LPI2C_MasterInit(base, &lpi2cConfig, CLOCK_GetFreq(kCLOCK_Lpi2c6));
// LPI2C_DMAMUX_Init();
// Create EDMA handle
edma_handle_t edmaHandle;
EDMA_CreateHandle(&g_edma_tx_handle, DMA0, 0);

LPI2C_MasterCreateEDMAHandle(base, &g_edma_handle, &g_edma_tx_handle, &g_edma_tx_handle,lpi2c_master_edma_transfer_callback,NULL);
}

status_t BOARD_LPI2C_Send_DMA(LPI2C_Type *base,
uint8_t deviceAddress,
uint32_t subAddress,
uint8_t subAddressSize,
uint8_t *txBuff,
uint8_t txBuffSize)
{

lpi2c_master_transfer_t transfer;
transfer.slaveAddress = deviceAddress;
transfer.direction = kLPI2C_Write;
transfer.subaddress = subAddress;
transfer.subaddressSize = subAddressSize;
transfer.data = txBuff;
transfer.dataSize = txBuffSize;
transfer.flags = kLPI2C_TransferDefaultFlag;

status_t status = LPI2C_MasterTransferEDMA(base, &g_edma_handle, &transfer);
return status;
}

status_t BOARD_LPI2C_Receive_DMA(LPI2C_Type *base,
uint8_t deviceAddress,
uint32_t subAddress,
uint8_t subAddressSize,
uint8_t *rxBuff,
uint8_t rxBuffSize)
{
lpi2c_master_transfer_t transfer;
transfer.slaveAddress = deviceAddress;
transfer.direction = kLPI2C_Read;
transfer.subaddress = subAddress;
transfer.subaddressSize = subAddressSize;
transfer.data = rxBuff;
transfer.dataSize = rxBuffSize;
transfer.flags = kLPI2C_TransferDefaultFlag;
status_t status = LPI2C_MasterTransferEDMA(base, &g_edma_handle, &transfer);
return status;
}

 

 

Tags (1)
0 Kudos
9 Replies

1,382 Views
Pavel_Hernandez
NXP TechSupport
NXP TechSupport

Hello, I'm following your case, let me review more information, when I have more details, I will contact you.

Best regards,
Pavel

0 Kudos

1,403 Views
vladimirchernin
Contributor III

hi!

Its still doesnt  work may be i need to set specific DMA channel for i2c6? 

its fails to write to i2c with 

thanks

#define EXAMPLE_LPI2C_DMAMUX_BASEADDR (DMAMUX0)
#define EXAMPLE_LPI2C_DMA_BASEADDR (DMA0)

void BOARD_LPI2C_Init_DMA(LPI2C_Type *base, uint32_t clkSrc_Hz)
{
lpi2c_master_config_t lpi2cConfig = {0};

CLOCK_EnableClock(kCLOCK_Lpi2c6);
LPI2C_MasterGetDefaultConfig(&lpi2cConfig);

lpi2cConfig.debugEnable = false;
lpi2cConfig.ignoreAck = false;
lpi2cConfig.pinConfig = kLPI2C_2PinOpenDrain;
lpi2cConfig.baudRate_Hz = 1000000U;
lpi2cConfig.busIdleTimeout_ns = 0;
lpi2cConfig.pinLowTimeout_ns = 0;
lpi2cConfig.sdaGlitchFilterWidth_ns = 0;
lpi2cConfig.sclGlitchFilterWidth_ns = 0;
LPI2C_MasterInit(base, &lpi2cConfig, clkSrc_Hz);

DMAMUX_Init(EXAMPLE_LPI2C_DMAMUX_BASEADDR);
edma_config_t edmaConfig = {0};
EDMA_GetDefaultConfig(&edmaConfig);
EDMA_Init(EXAMPLE_LPI2C_DMA_BASEADDR, &edmaConfig);

edma_handle_t edmaHandle;
EDMA_CreateHandle(&g_edma_tx_handle, DMA0, 0);

LPI2C_MasterCreateEDMAHandle(base, &g_edma_handle, &g_edma_tx_handle, &g_edma_tx_handle,lpi2c_master_edma_transfer_callback,NULL);


}

please see the code

void BOARD_LPI2C_Init_DMA(LPI2C_Type *base, uint32_t clkSrc_Hz)
{
lpi2c_master_config_t lpi2cConfig = {0};

CLOCK_EnableClock(kCLOCK_Lpi2c6);
LPI2C_MasterGetDefaultConfig(&lpi2cConfig);

lpi2cConfig.debugEnable = false;
lpi2cConfig.ignoreAck = false;
lpi2cConfig.pinConfig = kLPI2C_2PinOpenDrain;
lpi2cConfig.baudRate_Hz = 1000000U;
lpi2cConfig.busIdleTimeout_ns = 0;
lpi2cConfig.pinLowTimeout_ns = 0;
lpi2cConfig.sdaGlitchFilterWidth_ns = 0;
lpi2cConfig.sclGlitchFilterWidth_ns = 0;
LPI2C_MasterInit(base, &lpi2cConfig, clkSrc_Hz);

DMAMUX_Init(EXAMPLE_LPI2C_DMAMUX_BASEADDR);
edma_config_t edmaConfig = {0};
EDMA_GetDefaultConfig(&edmaConfig);
EDMA_Init(EXAMPLE_LPI2C_DMA_BASEADDR, &edmaConfig);

edma_handle_t edmaHandle;
EDMA_CreateHandle(&g_edma_tx_handle, DMA0, 0);

LPI2C_MasterCreateEDMAHandle(base, &g_edma_handle, &g_edma_tx_handle, &g_edma_tx_handle,lpi2c_master_edma_transfer_callback,NULL);


}

0 Kudos

1,371 Views
Pavel_Hernandez
NXP TechSupport
NXP TechSupport

Hello, I recommend using the example of the RT1050 in the driver files and migrating this to the RT1170 there are examples of I2C with DMA. This will be more familiar with the NXP driver configuration.

Best regards,
Pavel

 

0 Kudos

1,019 Views
vladimirchernin
Contributor III

hi!

i dont see examples in 1176 sdk can you send me  how to work with edma i2c rt1176 i dont have access on nxp site

thanks

0 Kudos

1,017 Views
vladimirchernin
Contributor III
 
0 Kudos

1,020 Views
vladimirchernin
Contributor III

rt1050 not availible 

0 Kudos

1,548 Views
Pavel_Hernandez
NXP TechSupport
NXP TechSupport

Hello,

I review your code seems good in the configuration of the driver, but you are missing the configuration of the DMA, I suggest reviewing the example of the SDK forget more details,

Pavel_Hernandez_0-1673651297756.png

If you have more related questions, please let me know.

Best regards,
Pavel

0 Kudos

1,541 Views
vladimirchernin
Contributor III

hi!

There is nxp driver fsl_lpi2c_edma what  else  i need  to config for DMA ?

please explain

thank you

 

 

0 Kudos

1,515 Views
Pavel_Hernandez
NXP TechSupport
NXP TechSupport

Hello,

There is some configuration for the DMA, please review the example.

DMAMUX_Init(EXAMPLE_LPI2C_DMAMUX_BASEADDR);
edma_config_t edmaConfig = {0};
EDMA_GetDefaultConfig(&edmaConfig);
EDMA_Init(EXAMPLE_LPI2C_DMA_BASEADDR, &edmaConfig);

Best regards,
Pavel 

0 Kudos