S32K146 LPI2C Receive Example

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

S32K146 LPI2C Receive Example

488 Views
Nibesh
Contributor III

Hello @VaneB the S32Design Studio didn't have LPI2C Receive example code for S32K146EVB.

If you can provide any example code for LPI2C or MRDR Receive that will be helpful for me.

Thank You

0 Kudos
10 Replies

467 Views
Nibesh
Contributor III

Hello @VaneB I am searching for S32 SDK for LPI2C not for RTM project..
I am not interested in any RTOS project.
If you can help me any hardcoded file with MRDR or Master Receive function that will be helpful for me.

Thank You

0 Kudos

460 Views
VaneB
NXP TechSupport
NXP TechSupport

Hi @Nibesh 

RTM means "ready to market". It is not the name of the software. We have available two different software for S32K1 devices. These are the S32 SDK for S32K1xx, and the other one is Real-Time Drivers (RTD)

Regarding the examples previously provided, the first one was implemented using the registers as the S32K1xx Series Cookbook and the other two were implemented using the SDK. Any of these uses RTOS. 

Could you please help me clarify if you are using any of the mentioned software or if you are working with the registers? 

0 Kudos

458 Views
Nibesh
Contributor III

Hello @VaneB The examples in S32DS in S32Design Studio for S32K146EVB only function for Transmit.
It is not at all performing Receiving function @VaneB 
For you kind reference I have attached the example code. I hope you will check it.

0 Kudos

445 Views
VaneB
NXP TechSupport
NXP TechSupport

Hi @Nibesh 

Please check the Example_S32K144_I2C_Master_MPL3115A2 I shared before. It was implemented using the registers as your project.

0 Kudos

470 Views
VaneB
NXP TechSupport
NXP TechSupport

Hi @Nibesh 

Check the following examples. These are some implementations for I2C using different software. It might be a good reference for your project. 

Example_S32K144_I2C_Master_MPL3115A2

LPI2C MASTER and LPI2C SLAVE (S32 SDK for S32K1xx examples)

 

B.R.

VaneB

365 Views
Nibesh
Contributor III

Hello @VaneB  will you please check my code once, LPI2C_read is not working.
I have attached my project zip file.
I hope you will check and provide quick response.

Thank You

0 Kudos

359 Views
VaneB
NXP TechSupport
NXP TechSupport

Hi @Nibesh 

I am reviewing your code, in the meantime, as I do not have the same setup, could you share an image of the I2C signals? The purpose of this is to observe the behavior of it. 

357 Views
Nibesh
Contributor III

Thank you very much @VaneB .
I have attached the logic analyzer image for your kind reference.
I am trying to set 0x60 as a slave address too, it is changing by default.
I hope you will help me to sort out by debugging with my code.

Thank You @VaneB 

0 Kudos

328 Views
Nibesh
Contributor III
Hello @VaneB can I expect any positive reply from you ?
0 Kudos

321 Views
VaneB
NXP TechSupport
NXP TechSupport

Hi @Nibesh 

Sorry for the delay. I have some observations about your code.

If we refer to the code used as a reference for your project, we can see that two addresses were defined for the slave. 

#define MPL3115A2_W           0xC0
#define MPL3115A2_R           0xC1

In these, a 1-bit shift to the left was made, and the bit that identifies whether you want to do a read or writing was added (we go from a 7-bit to an 8-bit address). Therefore, when you are calling the read or write functions, the same direction is taken as if a write were being done all the time.

Additionally, I could see that in your write function, you are sending an array, but when you call it in the function, you are only sending the address of the array, not a pointer to it.

use &uartRxBuff instead of uartRxBuff

Additionally, in this function, when sending data, you would not be traveling through the array, because you always send the same data.

uint8_t LPI2C0_write(uint8_t s_w_address, uint8_t * byte, uint8_t size)
{
    if(bus_busy()) return (error |= (1 << BUSY));
    generate_start_ACK(s_w_address);
    for(int i=0;i<size;i++)
    	transmit_data(byte[i]);
    if(generate_stop()) return error;
    else return OK;
}

Please let me know if I misunderstood any of the above observations.

0 Kudos