Clarification on LIN Master Baremetal Example for S32K148: ID/PID Transmission and Master Send Heade

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

Clarification on LIN Master Baremetal Example for S32K148: ID/PID Transmission and Master Send Heade

2,410 Views
Shivaprasad_sp
Contributor II

I am using the S32K148 LIN Master baremetal example and I have a couple of questions:

  1. In this example, is the ID/PID being sent across the LIN bus?
  2. Can someone explain what exactly the Master_SendHeader function is doing? Specifically, I would like to understand if it handles the ID/PID transmission or if additional steps are needed.
  3. Actually i want to send a frame and see the frame in the logic analyzer, I have modified the main.c of baremetal example. I am just using  
  4. status_t status;
    uint8_t txBuff[TX_FRAME_SIZE] = {0x34, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0};

    // 1. Send Break (handled by the LIN driver when sending the header)

    LIN_DRV_Init(INST_LIN1);
    LIN_DRV_MasterSendHeader(INST_LIN1, FRAME_ID);
    status=LIN_DRV_SendFrameDataBlocking(INST_LIN1,txBuff,8,TIMEOUT);
Tags (2)
0 Kudos
Reply
3 Replies

2,385 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

1) PID is sent on the bus. 

2-4) LIN_DRV_MasterSendHeader function sends LIN Break field, sync field then the ID with correct parity. It is non-blocking function that returns immediately, so you should wait till PID is sent, then you can either send or receive frame data using LIN_DRV_SendFrameData or LIN_DRV_ReceiveFrameData. Ideally use driver Callback and based on lin1_State->currentEventId do desired call. Simply refer to demo example, which shows that.

BR, Petr

0 Kudos
Reply

2,369 Views
Shivaprasad_sp
Contributor II

LIN_DRV_MasterSendHeader(INST_LIN1, 0x02);

if this is my function call with id 0x02 then 

status_t LIN_LPUART_DRV_MasterSendHeader(uint32_t instance,
uint8_t id)
{
/* Assert parameters. */
DEV_ASSERT(instance < LPUART_INSTANCE_COUNT);

status_t retVal = STATUS_SUCCESS;

/* Get the current LIN user config structure of this LPUART instance. */
const lin_user_config_t * linUserConfig = g_linUserconfigPtr[instance];

/* Get base address of the LPUART instance. */
LPUART_Type * base = g_linLpuartBase[instance];

/* Get the current LIN state of this LPUART instance. */
lin_state_t * linCurrentState = g_linStatePtr[instance];

/* Check whether current mode is sleep mode */
bool checkSleepMode = (LIN_NODE_STATE_SLEEP_MODE == linCurrentState->currentNodeState);

/* Check if the current node is slave or id is invalid or node's current
* state is in SLEEP state */
if ((linUserConfig->nodeFunction == (bool)SLAVE) || (0x3FU < id) || checkSleepMode)
{
retVal = STATUS_ERROR;
}
else
{
/* Check if the LIN bus is busy */
if (linCurrentState->isBusBusy)
{
retVal = STATUS_BUSY;
}
else
{
linCurrentState->currentId = id;

/* Make parity for the current ID */
linCurrentState->currentPid = LIN_DRV_ProcessParity(id, MAKE_PARITY);

/* Set LIN current state to sending Break field */
linCurrentState->currentNodeState = LIN_NODE_STATE_SEND_BREAK_FIELD;
linCurrentState->currentEventId = LIN_NO_EVENT;
linCurrentState->isBusBusy = true;

/* Set Break char detect length as 13 bits minimum */
LPUART_SetBreakCharDetectLength(base, LPUART_BREAK_CHAR_13_BIT_MINIMUM);
LPUART_SetIntMode(base, LPUART_INT_LIN_BREAK_DETECT, true);

/* Send break char by using queue mode */
LPUART_QueueBreakField(base); 
}
}

return retVal;
}LPUART_QueueBreakField(base); here in this line it is just sending the break character i dont know how it is sending the sync field and break field in the LIN_LPUART_DRV_MasterSendHeader function

0 Kudos
Reply

2,365 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

next bytes of header are handled and sent via interrupt routine.

BR, Petr 

0 Kudos
Reply