This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS320F280049: LIN Slave Mode Configuration Example

Part Number: TMS320F280049

Dear Team,

We are trying to configure LIN on 280049 in slave mode.

In our driverlib, we only provided an API _initModule() to configure LIN in master mode.

In order to configure the LIN in slave mode, we modified the code in lin.c(in driverlib documents). And putted the corresponding code in main.c.

However, the code cannot jump into interrupt function. Could you please help review the configuration or provide a correct example to configure LIN communication?

I noted our modification in bold characters.

void
LIN_init_Module(uint32_t base)
{
//
// Check the arguments.
//
ASSERT(LIN_isBaseValid(base));

EALLOW;

//
// Reset LIN module
// Release from hard reset
//
LIN_disableModule(base);
LIN_enableModule(base);

//
// Enter Software Reset State
//
LIN_enterSoftwareReset(base);

//
// Enable LIN Mode
//
LIN_disableSCIMode(base);

//
// Set LIN mode to Master
//
LIN_setLINMode(base, LIN_MODE_LIN_SLAVE);

//
// Enable Fixed baud rate mode
//
//LIN_disableAutomaticBaudrate(base);
LIN_enableAutomaticBaudrate(base);
//
// Use the set frame length and not ID4/ID5 bits for length control
//
LIN_setCommMode(base, LIN_COMM_LIN_USELENGTHVAL);

//
// Setup to continue operating on emulation suspend
//
LIN_setDebugSuspendMode(base, LIN_DEBUG_COMPLETE);

//
// Use Enhanced Checksum
//
LIN_setChecksumType(base, LIN_CHECKSUM_ENHANCED);

//
// Message filtering uses slave task ID byte
//
//LIN_setMessageFiltering(base, LIN_MSG_FILTER_IDSLAVE);
LIN_setMessageFiltering(base, LIN_MSG_FILTER_IDBYTE);

//
// Disable Internal loopback for external communication
//
LIN_disableIntLoopback(base);

//
// Enable multi-buffer mode
//
LIN_enableMultibufferMode(base);

//
// Enable parity check on received ID
//
LIN_enableParity(base);

//
// Enable transfer of data to and from the shift registers
//
LIN_enableDataTransmitter(base);
LIN_enableDataReceiver(base);

//
// Enable the triggering of checksum compare on extended frames
//
LIN_triggerChecksumCompare(base);

//
// Set LIN interrupts to disabled
//
LIN_disableInterrupt(base, LIN_INT_ALL);

//
// Set Baud Rate Settings - 100MHz Device
//
//LIN_setBaudRatePrescaler(base, 96U, 11U);
LIN_setMaximumBaudRate(base, 100000000U);

//
// Set response field to 1 byte
//
LIN_setFrameLength(base, 1U);

//
// Configure sync field
// Sync break (13 + 5 = 18 Tbits)
// Sync delimiter (1 + 3 = 4 Tbits)
//
LIN_setSyncFields(base, 5U, 3U);

//
// Set Mask ID so TX/RX match will always happen
//
LIN_setTxMask(base, 0xFFU);
LIN_setRxMask(base, 0xFFU);

//
// Disable IODFT testing and external loopback mode
//
LIN_disableExtLoopback(base);

//
// Finally exit SW reset and enter LIN ready state
//
LIN_exitSoftwareReset(base);

EDIS;
}

inline void Config_LIN(uint32_t base)

{
//
// Interrupts that are used in this example are re-mapped to
// ISR functions found within this file.
// This registers the interrupt handler in PIE vector table.
//
Interrupt_register(INT_LINA_0, &level0ISR);
Interrupt_register(INT_LINA_1, &level1ISR);

//
// Enable the LIN interrupt signals
//
Interrupt_enable(INT_LINA_0);
Interrupt_enable(INT_LINA_1);

//
// Initialize the LIN module
//
LIN_initModule(LINA_BASE);

//
// Enable Internal Loopback mode
//
LIN_enableIntLoopback(LINA_BASE);

//
// Enable interrupts for when an header identifier is received
//
LIN_enableInterrupt(LINA_BASE, LIN_INT_ID);

//
// Set the interrupt priority line
// Default is set to Interrupt line 0 (high priority)
// Comment out "LIN_setInterruptLevel0" and uncomment
// "LIN_setInterruptLevel1" to change to interrupt line 1 (low priority)
//
LIN_setInterruptLevel0(LINA_BASE, LIN_INT_ALL);
//LIN_setInterruptLevel1(LINA_BASE, LIN_INT_ALL);

//
// Enable parity check
//
LIN_enableParity(LINA_BASE);

//
// Enable global interrupt lines and clear status to known value
//
LIN_enableGlobalInterrupt(LINA_BASE, LIN_INTERRUPT_LINE0);
LIN_enableGlobalInterrupt(LINA_BASE, LIN_INTERRUPT_LINE1);
LIN_clearGlobalInterruptStatus(LINA_BASE, LIN_INTERRUPT_LINE0);
LIN_clearGlobalInterruptStatus(LINA_BASE, LIN_INTERRUPT_LINE1);

}