S32K144EVB LPI2C_master_s32k144 issue modifying to add data to the send packets

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

S32K144EVB LPI2C_master_s32k144 issue modifying to add data to the send packets

Jump to solution
587 Views
RML_SPARKY
Contributor I

Hello all.

I have the lpi2c_master-s32k144 example compiled and running, i have added an infinite loop to keep sending a packet out on ID 0x01 which i can see on my picoscope fine, but i have tried to add some data to the buffer to send and regardless of how try to load the buffer up, i still get no data in the buffer.

Modified code below if someone can point me in the right direction please.

Thanks
Rich

#define TRANSFER_SIZE (8u)

/*!
\brief The main function for the project.
\details The startup initialization sequence is the following:
* - __start (startup asm routine)
* - __init_hardware()
* - main()
* - PE_low_level_init()
* - Common_Init()
* - Peripherals_Init()
*/
int main(void)
{
/* Allocate memory for the LPI2C driver state structure */
lpi2c_master_state_t lpi2c1MasterState;

/* Declaration of the LPI2C transfer buffer */
uint8_t buffer[TRANSFER_SIZE];
uint8_t data[8];

/* Variable used for the loop that initializes the data buffer */
uint16_t i;

/*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
#ifdef PEX_RTOS_INIT
PEX_RTOS_INIT(); /* Initialization of the selected RTOS. Macro is defined by the RTOS component. */
#endif
/*** End of Processor Expert internal initialization. ***/

/* Initialize and configure clocks
* - Configure system clocks and dividers
* - Configure LPI2C clock gating
* - see clock manager component for details
*/
CLOCK_SYS_Init(g_clockManConfigsArr, CLOCK_MANAGER_CONFIG_CNT,
g_clockManCallbacksArr, CLOCK_MANAGER_CALLBACK_CNT);
CLOCK_SYS_UpdateConfiguration(0U, CLOCK_MANAGER_POLICY_AGREEMENT);

/* Initialize pins
* - Configure LPI2C pins
* - See PinSettings component for more info
*/
PINS_DRV_Init(NUM_OF_CONFIGURED_PINS, g_pin_mux_InitConfigArr);

/* Initialize LPI2C Master configuration
* - Slave address 0x01
* - Fast operating mode, 400 KHz SCL frequency
* - See LPI2C components for configuration details
*/
LPI2C_DRV_MasterInit(INST_LPI2C1, &lpi2c1_MasterConfig0, &lpi2c1MasterState);
// Set I2C Address to 0x01
LPI2C_DRV_MasterSetSlaveAddr(INST_LPI2C1,0x01,false);

/* Initialize the data buffer */
for (i = 0u; i < TRANSFER_SIZE; i++)
{
buffer[i] = i;
}

/* Send a packet of data to the bus slave */
LPI2C_DRV_MasterSendData(INST_LPI2C1, buffer, TRANSFER_SIZE, true);

/* Clear the buffer to prepare it for the next operation */
// for (i = 0u; i < TRANSFER_SIZE; i++)
// {
// buffer[i] = 0u;
// }

for(;;) // MAIN LOOP
{

uint8_t data[] = {1,2,3,4,5,6,7,8};
// LPI2C_DRV_MasterSendData(INST_LPI2C1, buffer, TRANSFER_SIZE, true);
LPI2C_DRV_MasterSendData(INST_LPI2C1, data, 8, true);
}

/* Request data from the bus slave */
//LPI2C_DRV_MasterReceiveDataBlocking(INST_LPI2C1, buffer, TRANSFER_SIZE, true, OSIF_WAIT_FOREVER);

/* End of the driver example */

/*** Don't write any code pass this line, or it will be deleted during code generation. ***/
/*** RTOS startup code. Macro PEX_RTOS_START is defined by the RTOS component. DON'T MODIFY THIS CODE!!! ***/
#ifdef PEX_RTOS_START
PEX_RTOS_START(); /* Startup of the selected RTOS. Macro is defined by the RTOS component. */
#endif
/*** End of RTOS startup code. ***/
/*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/
for(;;) {
if(exit_code != 0) {
break;
}
}
return exit_code;
/*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/
} /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/

/* END main */
/*!
** @}
*/
/*
** ###################################################################
**
** This file was created by Processor Expert 10.1 [05.21]
** for the Freescale S32K series of microcontrollers.
**
** ###################################################################
*/

0 Kudos
Reply
1 Solution
354 Views
VaneB
NXP TechSupport
NXP TechSupport

Hi @RML_SPARKY 

The I2C protocol requires a receiver and transmitter to archive a successful communication. 

The acknowledgment takes place after every byte. The acknowledge bit lets the receiver signal to the transmitter that the byte was successfully received and another byte may be sent. So, as you are not configuring the slave the master remains waiting for the missing acknowledge of the slave. 

View solution in original post

0 Kudos
Reply
6 Replies
574 Views
VaneB
NXP TechSupport
NXP TechSupport

Hi @RML_SPARKY 

Looks like you are using an older version of the S32K1 SDK, please verify if, with the latest SW release, you have the same behavior. Also, could you share your project so we can test it from our side?

 

B.R.

VaneB

0 Kudos
Reply
462 Views
RML_SPARKY
Contributor I

 

Hi VaneB, have you had any success on this? 

I have also simplified the i2c PAL example to just a master using the LPI2C pins .

I see the address being sent over the i2c bus on my picoscope, but no date being sent with it.

I have attached the project here.

Thanks

Rich

0 Kudos
Reply
437 Views
VaneB
NXP TechSupport
NXP TechSupport

Hi @RML_SPARKY 

As the SDK version used is an old version, could you please test with the latest SDK version (v4.0.3 supported by S32DS 3.4) or with the Real-Time Drivers for S32K1 (v2.0.0 supported by S32DS 3.5)? 

0 Kudos
Reply
370 Views
RML_SPARKY
Contributor I

Hi, 

I have been doing some further testing with the i2C_pal_s32k144 on S32DS 3.4 and latest SDK, 

If i comment out the i2c slave initialization line as shown below i get the exact behaviour i am observing, where the master will only send the address and not what is in the transmit buffer.

Unfortunately i cannot use LPI2C as master because FLEXIO does not support the slave feature.

Why does the I2C Master code require the slave to be configured?

Thanks
Rich

 

RML_SPARKY_0-1716979066717.png

 

0 Kudos
Reply
355 Views
VaneB
NXP TechSupport
NXP TechSupport

Hi @RML_SPARKY 

The I2C protocol requires a receiver and transmitter to archive a successful communication. 

The acknowledgment takes place after every byte. The acknowledge bit lets the receiver signal to the transmitter that the byte was successfully received and another byte may be sent. So, as you are not configuring the slave the master remains waiting for the missing acknowledge of the slave. 

0 Kudos
Reply
382 Views
RML_SPARKY
Contributor I

Hi 

I have now downloaded S32DS 3.4, installed the SDK 4.0.3 and re written the example , i still get no data being sent over I2C, only the address appears on the picoscope.

Project attached, 

Thanks
Rich

0 Kudos
Reply