Flexio I2C issue on s32k116 develop board

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

Flexio I2C issue on s32k116 develop board

2,926 Views
eason_chen
Contributor I

Hi,

I use flexio act I2C to read a temperature sensor, but the transfer always fail.

The status is STATUS_I2C_TX_UNDERRUN.

From LA i see the slave address was transferred twice. You can see the screenshot that from LA as below

pastedImage_1.png

It cause transfer length from 4 bytes become 5 bytes, therefore a NAK is responded by slave after last data transfer.

The code flow is as below.

FLEXIO_DRV_DeinitDevice -> FLEXIO_DRV_InitDevice -> FLEXIO_I2C_DRV_MasterDeinit ->FLEXIO_I2C_DRV_MasterInit -> FLEXIO_I2C_DRV_MasterSendData

 

The related environment :

1. Platform : s32k116 develop board 

2. SDK : S32SDK_S32K116_EAR_1.8.7

3. Flexpin : PTA1(SDA), PTA0(SCL)

4. I2C speed : 400K

5. FLEXIO0_CLK : 40M(CLK_SRC_SOSC_DIV2)

 

Does anything i am missing or what has cause this?

Thanks.

BR,

Eason

0 Kudos
18 Replies

2,333 Views
eason_chen
Contributor I

Hi Diana,

Sorry for Inadvertently press to reply.

Does any else way i can download it?

Or could you attached the related source code?

Very thanks.

BR,

Eason

0 Kudos

2,333 Views
dianabatrlova
NXP TechSupport
NXP TechSupport

Hi Eason,

I looked at your code, could you try to select Round-robin arbitration instead of Fixed-priority?

In the RM rev 9.:

"Highly recommended to configure this bit field to round-robin mode before configuring any other
master, for example: DMA, ENET etc., as fixed arbitration may generate stalls or under runs on
low priority master."

Best Regards,

Diana

0 Kudos

2,333 Views
eason_chen
Contributor I

Hi Diana,

The LPUART can't work normally after i change the DMA mode from fixed-priority to round-robin.

But flexio i2c works normally.

Do i only modify edmaCfg.chnArbitration to round-robin in Board_Edma_Initialization?

Or something else i need to modify to?

Thanks.

BR,

Eason

0 Kudos

2,333 Views
eason_chen
Contributor I

Hi Diana,

As i describe above, if i configure the channel arbitration is around robin, the dma function of lpuart can't work normally.

So, i tried to configure the CBRR is around-robin in MCM->CPCR and the dma channel arbitration is fixed priority.

Unfortunately the issue still exist, you can see the picture is as below.

The slave address still is sent twice by flexio i2c.

pastedImage_1.png

If i am missing something, please kindly to let me know.

Thank you so much.

BR,

Eason

0 Kudos

2,333 Views
dianabatrlova
NXP TechSupport
NXP TechSupport

Hi Eason,

I have discussed with my colleagues, unfortunately, this issue should be debugged.

Have you tried to debug the code step by step?

What is the data flow (are the data after the second address correct)?

When the FlexIO I2C works normally in a round-robin mode and LPUART not... what does it mean "can't work normally" have you seen any error?

Best Regards,

Diana

0 Kudos

2,333 Views
eason_chen
Contributor I

Dear Diana,

First at all, thank you for your reply.

The data is correct after the second address.

My test case is uart, flexio i2c and i2c work at same time.

Test case :

Every 10ms, uart read eleven words then send the same eleven words

i2c read a temperature sensor every 10ms

flexio send 40 data to a scaler chip every 50ms

  

And now there are two conditions,

1. Flexio i2c fail and uart work normally

2. Flexio i2c work normaly but uart fail

Above two conditions usually are presented between 2-5 hours after.

The related error separately as below.

Condition one(Flexio i2c fail and uart work normally)

* Slave address is sent twice

* DMA channel fail

Condition two(Flexio i2c work normaly but uart fail)

* Rx overRun

 

Do you have any idea?

Thank you so much.

BR,

Eason

0 Kudos

2,333 Views
dianabatrlova
NXP TechSupport
NXP TechSupport

Hi Eason,

Thank you for your details. Regarding the second condition, have you tried to decrease baudrate of LPUART, use FIFO? 

Best Regards,

Diana

0 Kudos

2,333 Views
eason_chen
Contributor I

Hi Diana,

Yes. I had tried to decrease baudrate, but the error still exist.

I am not sure the FIFO of LPUART if is enabled.

About driver layer, it is base on SDK RTM3.0.0 and i don't modify it.

BTW, if i don't run flexio i2c, the lpuart can work over 100 hours doesn't fail.

Thank you so much for your support.

BR,

Eason

0 Kudos

2,333 Views
eason_chen
Contributor I

Hi Diana,

I don't know why, i try all the way of the website(include online and offline) but I still can't download RTM3.0.1.

It tell me the repository error or nothing to download.

Does any else way i can download 

0 Kudos

2,333 Views
eason_chen
Contributor I

Hi Diana,

First at all, thank you for the information.

Yes, i am using interrupt mode. 

By i understand, the flexio irq number only one that is FLEXIO_IRQn, how do i set the priority of TX higher?

And i tried use DMA mode, flexio i2c works normally when DMA only exist flexio i2c.

If DMA exist more than one device(ex : uart + flexio), this issue still is presented.

Thanks.

BR,

Eason

0 Kudos

2,333 Views
dianabatrlova
NXP TechSupport
NXP TechSupport

Hi Eason,

I'm not sure if I understand clearly of your description.

Do you mean LPUART or FlexIO UART + FlexIO I2C?

Do you use interrupts also for the UART?

Could you please share your code?

Thank you.

Best Regards,

Diana

0 Kudos

2,333 Views
eason_chen
Contributor I

Hi Diana,

The issue occurs when using Flexio I2C and LPUART.

They all using DMA mode with a transmission interval of 100ms.

Running for a while, problem occurs randomly.

My test condition is as below,

1. Config Flexio I2C with DMA mode and speed is 400KHZ for temperature sensor

2. Config LPUART with DMA mode and baud rate is 115200 for console

3. Send temperature sensor commands every 100ms

4. Every 100ms, read a string from PC and output the string to PC.

The LPUART, EDMA and FIEXIO I2C initialization source codes are as below

void Board_Lpuart1_Initialization(void)
{
lpuart_user_config_t lpuartCfg;

lpuartCfg.baudRate = LPUART1_CONSOLE_BAUDRATE;
lpuartCfg.parityMode = LPUART1_PARITY_DISABLED;
lpuartCfg.stopBitCount = LPUART1_ONE_STOP_BIT;
lpuartCfg.bitCountPerChar = LPUART1_8_BITS_PER_CHAR;
lpuartCfg.transferType = LPUART1_OPERATE_MODE;  //DMA mode
lpuartCfg.rxDMAChannel = EDMA_LPUART1_RX_CH1;
lpuartCfg.txDMAChannel = EDMA_LPUART1_TX_CH0;
LPUART_DRV_Deinit(LPUART_CONSOLE_INSTANCE);
LPUART_DRV_Init(LPUART_CONSOLE_INSTANCE, &lpuart1State, &lpuartCfg);
}

static void Board_Edma_Channel_Initialization(void)
{
edma_channel_config_t edmaCfg;

edmaCfg.channelPriority = EDMA_LPUART1_RX_PRORITY;
edmaCfg.virtChnConfig = EDMA_LPUART1_RX_CH1;
edmaCfg.source = EDMA_REQ_LPUART1_RX;
edmaCfg.callback = NULL;
edmaCfg.callbackParam = NULL;
EDMA_DRV_ChannelInit(&lpuartRxEdmaState, &edmaCfg);

edmaCfg.channelPriority = EDMA_LPUART1_TX_PRORITY;
edmaCfg.virtChnConfig = EDMA_LPUART1_TX_CH0;
edmaCfg.source = EDMA_REQ_LPUART1_TX;
edmaCfg.callback = NULL;
edmaCfg.callbackParam = NULL;
EDMA_DRV_ChannelInit(&lpuartTxEdmaState, &edmaCfg);

edmaCfg.channelPriority = EDMA_FXIOI2C0_RX_PRORITY;
edmaCfg.virtChnConfig = EDMA_FXIOI2C0_RX_CH3;
edmaCfg.source = EDMA_REQ_FLEXIO_SHIFTER0;
edmaCfg.callback = NULL;
edmaCfg.callbackParam = NULL;
EDMA_DRV_ChannelInit(&fxioI2CRxEdmaState, &edmaCfg);

edmaCfg.channelPriority = EDMA_FXIOI2C0_TX_PRORITY;
edmaCfg.virtChnConfig = EDMA_FXIOI2C0_TX_CH2;
edmaCfg.source = EDMA_REQ_FLEXIO_SHIFTER1;
edmaCfg.callback = NULL;
edmaCfg.callbackParam = NULL;
EDMA_DRV_ChannelInit(&fxioI2CTxEdmaState, &edmaCfg);
}

void Board_FlexioI2C_Initialization(void)
{
flexio_i2c_master_user_config_t cfg;

FLEXIO_DRV_DeinitDevice(FLEXIO_I2C_INSTANCE);
FLEXIO_DRV_InitDevice(FLEXIO_I2C_INSTANCE, &flexioDevState);

cfg.slaveAddress = 0x48;
cfg.driverType = FLEXIO_I2C_OPERATE_MODE;  //DMA mdoe
cfg.baudRate = FLEXIO_I2C_BAUDRATE;
cfg.sdaPin = FLEXIO_I2C_SDA_PIN;
cfg.sclPin = FLEXIO_I2C_SCL_PIN;
cfg.callback = Board_FlexioI2C_Callback;
cfg.callbackParam = UNDEFINEED_VALUE;
cfg.rxDMAChannel = EDMA_FXIOI2C0_RX_CH3;
cfg.txDMAChannel = EDMA_FXIOI2C0_TX_CH2;

FLEXIO_I2C_DRV_MasterDeinit(&flexioI2CState);
FLEXIO_I2C_DRV_MasterInit(FLEXIO_I2C_INSTANCE, &cfg, &flexioI2CState);

flexioI2CCallback = NULL;
}

Thank you.

BR,
Eason

0 Kudos

2,333 Views
dianabatrlova
NXP TechSupport
NXP TechSupport

Hi Eason,

It seems there should be enough time for the transfer.

Please, use the newest SDK version.

https://community.nxp.com/docs/DOC-343020 

Best Regards,

Diana

0 Kudos

2,333 Views
eason_chen
Contributor I

Hi Diana,

First at all, thank you for the support.

I use S32SDK_S32K116_EAR_1.8.7.

I download it on 4/29.

Is it the newest one?

If yes, the newest SDK can't solve this issue.

BR,

Eason

0 Kudos

2,333 Views
dianabatrlova
NXP TechSupport
NXP TechSupport

Hi Eason,

Unfortunately not, the new version is S32 SDK S32K1xx RTM 3.0.1 and it can be downloaded from the link below:

https://www.nxp.com/support/developer-resources/run-time-software/s32-design-studio-ide/s32-design-s... 

I hope it helps.

Best Regards,

Diana

0 Kudos

2,333 Views
eason_chen
Contributor I

Hi Diana,

Although I can't download RTM3.0.1 but RTM3.0.0 is downloaded complete.

And i tried RTM3.0.0, unfortunately this issue still exist.

pastedImage_1.png

BR,

Eason

0 Kudos

2,333 Views
dianabatrlova
NXP TechSupport
NXP TechSupport

Hi Eason,

Unfortunately, I do not know why you cannot download version 3.0.1. 

In that case, I would like to ask you can you share your whole project with SDK RTM 3.0.0?

Thank you.

Best Regards,

Diana

0 Kudos

2,333 Views
dianabatrlova
NXP TechSupport
NXP TechSupport

Hi Eason,

From the RM we know that " SMOD=Transmit, indicates Shifter was ready to load new data from SHIFTBUF before new data had been written into SHIFTBUF (SHIFTBUF Underrun). "

Do you use interrupts? If yes, could you try to set the interrupt priority of the I2C Tx higher?

Also, you can refer to "flexio_i2c_s32k116" example which is available in the S32DS in the menu File - > New -> Project from example.

The SDK updates are available on the link below:

https://www.nxp.com/support/developer-resources/run-time-software/s32-design-studio-ide/s32-design-s... 

I hope it helps,

Best Regards,

Diana

0 Kudos