Please, Check my Lin Communication Code, how can I do?

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

Please, Check my Lin Communication Code, how can I do?

1,074 Views
skb
Contributor II

I'm testing the lin_master_s32k116 example.
In this example, the temperature of the motor is read through LIN communication.
It also controls the motor speed according to the temperature.

How is g_lin_frame_data_buffer defined in lin_cfg created through this project?
I didn't quite understand.

And I changed the example and made the code as below.

void lin_master_task(void)
{
/* Initialize LIN network interface */
l_sys_init();
l_ifc_init(LI0);
/* Set Schedule table to Normal */
l_ifc_wake_up(LI0);
l_sch_set(LI0, LI0_Normal_Schedule, 0u);
/* Infinite loop */
for (;;) {
/* Check if information about the Motor1 Temp has been received */
if (l_flg_tst_LI0_MOTOR_byTemperature_flag()) {
/* Clear this flag... */
l_flg_clr_LI0_MOTOR_byTemperature_flag();

/* Store temperature data */
Motor1_Temp = l_u8_rd_LI0_MOTOR_byTemperature();
//debugConsolePrintf(Motor1_voltage);
}
/* Check node state */
if (LIN_NODE_STATE_SLEEP_MODE == lin_lld_get_state(LI0)) {
/* Turn off all LEDs */
l_ifc_wake_up(LI0);
l_sch_set(LI0, LI0_Normal_Schedule, 0u);
PINS_DRV_TogglePins(LED0_GPIO_PORT, PORT_LED0_INDEX);
}
}

}

When I debugged it,
LIN_NODE_STATE_IDLE,
LIN_NODE_STATE_SEND_BREAK_FIELD
LIN_NODE_STATE_RECV_DATA
It appears as these three states change, and the flag check of the if statement does not even pass. (if (l_flg_tst_LI0_MOTOR_byTemperature_flag()) )

The order of Lin communication is
1. flag check
2. flag clear
3. read data
Is this correct?

please check.

thank you.

0 Kudos
Reply
3 Replies

991 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

lin_cfg.c and lin_cfg.h are generated by Processor Expert from given LDF file.
Seems you are using different file from one given in the demo example. Or you just rename signals etc?
If using your code modification for demo project but using default ldf, it behaves similarly, frames are sent.
If you have slave connected (second board with slave demo running) then you should pass the flag checking (if MOTOR_byTemperature_flag is indicating this).

BR, Petr 

0 Kudos
Reply

986 Views
skb
Contributor II

Hi @PetrS 

I deleted the LDF file provided in the demo example.
And I added the LDF file created by me. Likewise, the names of signals and the like have been corrected.
If the demo example works only with the existing LDF file, how can I properly configure lin_cfg.c and lin_cfg.h by applying the new LDF file?

 

BR, skb

0 Kudos
Reply

982 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

if you changed LDF, then we cannot check/test your code directly, so please share it.
lin_cfg.c and lin_cfg.h are generated automatically from uploaded LDF file.

BR, Petr

0 Kudos
Reply