hello,
use LPIIC,
I want to read IMU(BMI160) device info on IIC bus,device addr is 0x68,The register address is 0x0,
how to do ?
thanks
Hello,
You may download the SDK for the S32K14x. Here you will find many examples using the I2C module. You can use these as a reference to connect your device via I2C.
To download the SDK please use this link.
Best Regards,
Sabina
hello,
no use freeRTos,
sta=LPI2C_DRV_MasterSendDataBlocking(INST_LPI2C1, buffer, 1, true, 0xFFFFFFFF);
sta=LPI2C_DRV_MasterReceiveDataBlocking(INST_LPI2C1, buffer, 1, true, 0xFFFFFFFF);
can read device ID,
but add freeRTos,
cannot read ID,return sta is busy.
Hi,
Do you try to send date outside of you tasks? If yes, please modify your code to do not call any function which can trigger interrupts before vTaskStartScheduler().
Best regards,
Razvan
hello,
i konw,
i try to it before vTaskStartScheduler().but it failure,
Best regards,
Grayli
Can you send a snippet of code to understand how do you use I2C and freeRtos?
hello,
sorry,i try to it before vTaskStartScheduler().it ok today.
but , i want to read after vTaskStartScheduler();
how to do? into taskENTER_CRITICAL(); it failure,
Best regards,
Grayli
Hi,
I don't know how your application works, but I would try to move that I2C code inside your task.
If you need that I2C call for one time initialization purpose you can create a task which is run only one time and after that you can remove it.
Probably your problem is similar to what is discussed here: What is normal method for running initialization code in FreerTOS? - FreeRTOS .
Best regards,
Razvan
thanks,
Are there any examples of GPIO emulating the IIC bus?
I used PTA-0/1 to simulate IIC on s32k146-64pin
Hi,
We do not have this type of driver for S32K1xx parts because there a lot of peripherals which can be used for I2C ( LPI2C and FlexIO).
I don't recommend to use bit-banging because it will rise many issues.
Best regards,
Razvan
hello,
Did you get my mail?
Best regards,
Grayli
Hi,
I didn't get anything from your side. If is possible please share your project here.
Best regards,
Razvan
发件人: bounces+210748-7d9b-grayli.wang=cdskysoft.com@jiveon.jivesoftware.com 代表 razva_tilimpea
发送时间: 2020年1月13日 16:49
收件人: WANG LI
主题: Re: - Re: S32K14 IIC
<https://community.freescale.com/resources/statics/1000/35400-NXP-Community-Email-banner-600x75.jpg> NXP Community
Re: S32K14 IIC
reply from Razvan-nicolae Tilimpea <https://community.nxp.com/people/razva_tilimpea?et=watches.email.thread> in S32K - View the full discussion <https://community.nxp.com/message/1254389?commentID=1254389&et=watches.email.thread#comment-1254389>
Hi,
The main problem with this application is that state structure (lpi2c1MasterState) is overwrite by some internal calls of the FreeRTOS. I don't understand exactly why this is happening (probably FreeRTOS suppose that you don't need to use again variables from main stack), but the easy fix is to move this state structure outside of stack by declaring it as global. In this way you won't have any overlap between main stack and other tasks tasks.
Also, please add INT_SYS_SetPriority(LPI2C0_Master_IRQn, 2); before starting scheduler to match maximum system call interrupt priority restriction.
Best regards,
Razvan
hello,
lpi2c_master_state_t *master; Is it defined as a global variable?
but it is failure.
Have you tested your method?
Please specify the specific operation steps, or you know to help modify the code!
The way you said above is too abstract for me to understand.
lpi2c_master_state_t *master;
status_t LPI2C_DRV_MasterSendDataBlocking(uint32_t instance,const uint8_t * txBuff,uint32_t txSize,bool sendStop,uint32_t timeout)
{
DEV_ASSERT(instance < LPI2C_INSTANCE_COUNT);
DEV_ASSERT(txBuff != NULL);
DEV_ASSERT(txSize > 0U);
master = g_lpi2cMasterStatePtr[instance];
DEV_ASSERT(master != NULL);
/* Check if driver is busy */
if(!master->i2cIdle)
{
return STATUS_BUSY;
}
/* mark transfer as blocking */
master->blocking = true;
/* Dummy wait to ensure the semaphore is 0, no need to check result */
(void)OSIF_SemaWait(&(master->idleSemaphore), 0);
(void)LPI2C_DRV_MasterSendData(instance, txBuff, txSize, sendStop);
/* Wait for transfer to end */
return LPI2C_DRV_MasterWaitTransferEnd(instance, timeout);
}
thanks
Don't know how to add files
hello,
There is a real problem with your SDK. I created a new RTOS today, and only two tasks are running, that is, 1S reads the IIC once, both of which are wrong.
Send the code to your mailbox.
please review.
thanks