S32K142: lpi2c is not working with freeRTOS integration.

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

S32K142: lpi2c is not working with freeRTOS integration.

7,913件の閲覧回数
danielcarlquist
Contributor II

Hello Team,

As per our project requirement we configured flex_i2c and lpi2c with FreeRTOS by using S32 Design studio.

From debugging we got to know once run the LPI2C_DRV_MasterSendDataBlocking(INST_LPI2C1, Data, sizeof(Data), true, 10UL);  function the software will always stuck at at the  DefaultISR: " startup_S32K_.S" file as mentined in below image. The software will not come out from DefaultISR

pastedImage_3.png

lpi2c configuration:

pastedImage_5.png

FlexIO i2c configuration:

pastedImage_6.png

Please help me to resolve this issue.

Regards

Ningapa C

11 返答(返信)

6,102件の閲覧回数
cheoljin
Contributor III

Hi, 

Now I'm checking I2C on Freertos but it do not work as I expected. 

My test project is as below. 

1. Make new freertos project from freertos example.  

2. Add I2c pin assign and peripheral setting to FAST. 

3. Add I2C Clock setting and master drive init routine 

4. Add I2C Prioirty level same as SYSCALL. 

/* Initialize Interrupt priority for LP I2C driver as bus master */
INT_SYS_SetPriority(LPI2C0_Master_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );

5. Add I2C data send routine in prvQueueSendTask as below.  

static void prvQueueSendTask( void *pvParameters )
{

...

/* Send a packet of data to the bus slave */
masterTxBuffer[0]=0x00;
masterTxBuffer[1]=0xAF;
LPI2C_DRV_MasterSendDataBlocking(INST_LPI2C0, masterTxBuffer, 2, true, OSIF_WAIT_FOREVER);

xQueueSend( xQueue, &ulValueToSend, mainDONT_BLOCK );

}
}

6. Compile and Start bebug ==>  LED shoud be blink but does not caused by LPI2C_DRV_MasterSendDataBlocking function.   

==> LPI2C_DRV_MasterSendDataBlocking(INST_LPI2C0, masterTxBuffer, 2, true, OSIF_WAIT_FOREVER);

==> When I change OSIF_WAIT_FOREVER to 500 then LED start blinking. 

Please check attached project file. 

0 件の賞賛
返信

7,030件の閲覧回数
danielcarlquist
Contributor II

Hi

Issue got resolved !!!!!!!

Solution:

When your software integrated with FreeRTOS need to handle the interrupt priority properly. i used following functions  during the i2c initialization  to set the i2c  interrupt.

/* Initialize Interrupt priority for LP I2C driver as bus master */
INT_SYS_SetPriority( LPI2C0_Master_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );

/* Initialize Interrupt priority for FlexIO I2C driver as bus master */
INT_SYS_SetPriority( FLEXIO_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );

Note

After RTOS configuration Don't run any infinite loop to test like toggle pins before start the scheduler.

Thanks for the NXP team for Quick response.

Regards

Ningu

0 件の賞賛
返信

7,030件の閲覧回数
sandeepsandeepk
Contributor II

#freertos # lpspi

i also have a problem with spi in s32k144 with freetos. here i used 2 spi one as slave and other as master and it works fine without freertos but freertos it stuck in the vPortRaiseBASEPRI please give some solution for this. i think its with giving priority. if so please show how to give priority to lpspi with the initialization.

0 件の賞賛
返信

7,030件の閲覧回数
razva_tilimpea
NXP Employee
NXP Employee

Hi,

Clock sources for these 2 modules are enabled?

Before calling LPI2C_DRV_MasterSendDataBlocking do you call Init function?

Razvan

0 件の賞賛
返信

7,030件の閲覧回数
danielcarlquist
Contributor II

Hi

Clock sources for these 2 modules are enabled?

Ans:  Yes, clock sources are enabled.

Before calling LPI2C_DRV_MasterSendDataBlocking do you call Init function?

Ans: Yes, Init function called before calling LPI2C_DRV_MasterSendDataBlocking function.

I2C is working for 400KHz frequency, But lower frequency like 20KHz, 50KHz, 100KHz, is not working. for lower frequency i selected Operating mode  Standard mode and Higher frequency Fast mode.

If it is posible will discuss over a skype call for this issue ?

Regards

Ningappa C

0 件の賞賛
返信

7,030件の閲覧回数
razva_tilimpea
NXP Employee
NXP Employee

Hi,

I can't support you on skype.

Please share here the project and we will try to get the root-cause.

Best regards,

Razvan

0 件の賞賛
返信

7,030件の閲覧回数
raresvasile
NXP Employee
NXP Employee

Hi,

Are you starting the scheduler before using LPI2C driver? As the driver uses FreeRTOS API, the driver must be initialized and used inside a FreeRTOS task after the scheduler is started.

Let me know if it was helpful.

BR,

Rares

7,030件の閲覧回数
danielcarlquist
Contributor II

Hi,

Please find the the attached, its having information regariing how we initializing Drivers and Creating task using FreeRTOS.

Stuck in startup code issue is resolved but One more issue is observed !!

When start the software it always stuck at    configASSERT( ucCurrentPriority >= ucMaxSysCallPriority );  in port.c file.

 i suspect with improper  priority handling between RTOS and I2C protocol, But i'm unable to resolve this issue.  Please help me to resolve this.

Regads

Ningappa C

0 件の賞賛
返信

7,030件の閲覧回数
jorge_a_vazquez
NXP Employee
NXP Employee

Hi Daniel

The above assertion will fail if a service routine (ISR) for an interrupt that has been assigned a priority above configMAX_SYSCALL_INTERRUPT_PRIORITY calls an ISR safe FreeRTOS API function.  ISR safe FreeRTOS API functions must be called from interrupts that have been assigned a priority at or below configMAX_SYSCALL_INTERRUPT_PRIORITY.

So, what priority do you have defined in configMAX_SYSCALL_INTERRUPT_PRIORITY and what priority do you define in the I2C task?

Regards

7,030件の閲覧回数
danielcarlquist
Contributor II

Hi,

In S32 Desing studio there is no configuration to set  I2C interrupt priority, Just i enabled interupt configuration.

Please find the attached images for I2C and Os Configuration..

Could you please let me know where i can change the interrupt priority for I2C.

Regards

0 件の賞賛
返信

7,030件の閲覧回数
razva_tilimpea
NXP Employee
NXP Employee

Hi,

In SDK interrupt priority can be changed just by calling INT_SYS_SetPriority in your source code, otherwise the SDK will use default priorities of the hardware.

Best regards,

Razvan