AnsweredAssumed Answered

LPI2C comunication query

Question asked by Lesmes Daniel Peña Blanco on Apr 17, 2018
Latest reply on May 14, 2018 by Lesmes Daniel Peña Blanco

Hi, Im triying to configure a LPI2C comunication in a S32K144EVB-Q100 with S32 Design Studio but i don´t know how to do it.

The thing that i want to do is:

 

Master sends one byte (0x00) to the register 0x03 of one Slave with adress 0x6C.

 

The steps that i followed were: 

 

-I create a new Proyect.

 

-I run the Processor Expert and i add the driver of LPI2C.

 

-I configured LPI2C driver:

   *Slave adress: 0x6C 

   *Operating Mode:  Standard

   *Baud rate (Hz): 100000

   *Transfer Type: Interrupts

   

 

-I configured pins in the pin _mux

      PTA 2 -> SDA

      PTA3 -> SCL

 

- I use this code:

#include "Cpu.h"
#include "pin_mux.h"
#include "clockMan1.h"
#include "lpi2c1.h"
#include "dmaController1.h"
#include "osif1.h"
#include "lpi2c_driver.h"
#include "lpi2c1.h"

volatile int exit_code = 0;

 

 

lpi2c_master_state_t MasterState0={};
/*!

 

void disable_WDOG (void){
WDOG->CNT=0xD928C520; /*Unlock watchdog*/
WDOG->TOVAL=0x0000FFFF; /*Maximum timeout value*/
WDOG->CS = 0x00002100; /*Disable watchdog*/
}

 

void init_clock(void){
CLOCK_SYS_Init(g_clockManConfigsArr, CLOCK_MANAGER_CONFIG_CNT, g_clockManCallbacksArr, CLOCK_MANAGER_CALLBACK_CNT);
CLOCK_SYS_UpdateConfiguration(0U, CLOCK_MANAGER_POLICY_AGREEMENT);

}


void init_pins(void){
PINS_DRV_Init(NUM_OF_CONFIGURED_PINS, g_pin_mux_InitConfigArr);
}

void lpi2c1_MasterCallback0(uint8_t instance,lpi2c_master_event_t masterEvent,void *userData){};

 

int main(void)
{
/* Write your local variable definition here */

/*** 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. ***/
/* Write your code here */
disable_WDOG();
init_clock();
init_pins();

 

for(;;){

LPI2C_DRV_MasterInit(INST_LPI2C1,&lpi2c1_MasterConfig0,&MasterState0);


LPI2C_DRV_MasterSendData(INST_LPI2C1,0x00,1U,1);

 

LPI2C_DRV_MasterSendData(INST_LPI2C1,0x00,1U,1);

 

LPI2C_DRV_MasterDeinit(INST_LPI2C1);

}
/* For example: for(;;) { } */

/*** 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!!! ***/

 

 

-I connect to the SDA and SCL pins a osciloscope to see the signal and i dont receive nothing.

 

What i'm doing wrong?

 

Regards 

Outcomes