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.
Hi expert,
My customer wants to use LIn as SCI function. the baud rate is 250Khz, and they can see the correct data on TX pin.
they can get the data on SCIRD register. But they can not go into the RX interrupt, not even once!
The register status is as below:
the configuration code is
SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_LINA); Interrupt_register(INT_LINA_0, DEBUG_RX_ISR); Interrupt_enable(INT_LINA_0); EALLOW; GPIO_setPinConfig(GPIO_28_LINA_TX); GPIO_setPinConfig(GPIO_29_LINA_RX); GPIO_SetupPinMux(29, GPIO_MUX_CPU1, 10); GPIO_SetupPinOptions(29, GPIO_INPUT, GPIO_PUSHPULL); GPIO_SetupPinMux(28, GPIO_MUX_CPU1, 10); GPIO_SetupPinOptions(28, GPIO_OUTPUT, GPIO_ASYNC); EDIS; LIN_initModule(LINA_BASE); configureSCIMode(); LIN_enableGlobalInterrupt(LINA_BASE, LIN_INTERRUPT_LINE0); LIN_clearGlobalInterruptStatus(LINA_BASE, LIN_INTERRUPT_LINE0); void LIN_initModule(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_MASTER); // // Enable Fixed baud rate mode // LIN_disableAutomaticBaudrate(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); // // 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 // //EALLOW; LIN_enableDataTransmitter(base); LIN_enableDataReceiver(base); //LinaRegs.SCIGCR1.bit.TXENA = 1; //LinaRegs.SCIGCR1.bit.RXENA = 1; //LinaRegs.SCIGCR1.all = 0x3000000; //EDIS; // // 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, 120000000U); // // 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; } void configureSCIMode(void) { // // Enter LIN reset state to perform configurations // LIN_enterSoftwareReset(LINA_BASE); // // Switch LIN into SCI mode // LIN_enableSCIMode(LINA_BASE); // // Set the SCI communication mode to idle line // LIN_setSCICommMode(LINA_BASE, LIN_COMM_SCI_IDLELINE); // // Set Baudrate // Bitrate = (SYSCLOCK) / ((P + 1 + M/16) * 16) // P : 24bit M : 4bit // LIN_setBaudRatePrescaler(LINA_BASE, 29, 0); // 250kHz // // Set SCI to transmit one stop bit // LIN_setSCIStopBits(LINA_BASE,LIN_SCI_STOP_ONE); // // Disable parity check // LIN_disableSCIParity(LINA_BASE); // // Disable multi-buffer mode // LIN_disableMultibufferMode(LINA_BASE); // // Module set to complete operations when halted by debugger // LIN_setDebugSuspendMode(LINA_BASE, LIN_DEBUG_COMPLETE); // // Set character length as 8-bits // LIN_setSCICharLength(LINA_BASE, LIN_CHAR_LENGTH); // // Set to 1 character in response field // LIN_setSCIFrameLength(LINA_BASE, LIN_FRAME_LENGTH); // // // // Enable Internal Loopback mode // // // LIN_enableIntLoopback(LINA_BASE); // // Enable interrupt for when a frame has been completely received // LIN_enableSCIInterrupt(LINA_BASE, LIN_SCI_INT_RX); // // Set the interrupt priority to line 0 (high) // LIN_setSCIInterruptLevel0(LINA_BASE, LIN_SCI_INT_RX); // // Exit LIN reset state // LIN_exitSoftwareReset(LINA_BASE); } __interrupt void DEBUG_RX_ISR(void) { CHK_LINRX(); // ��ȡ�������� // Swi_post(SWI_LINa); // // Clear module interrupt flag and global interrupt flag for line 0 // //LIN_clearInterruptStatus(LINA_BASE, LIN_INT_RX); //LIN_clearGlobalInterruptStatus(LINA_BASE, LIN_INTERRUPT_LINE0); // // Acknowledge this interrupt located in group 8 // Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP8); }
Since the sci share the clock with SPI and they can not get the baud rate they want by SCI module. so they must use Lin to achieve this function.
Could you kindly help on this case since it is a really urgent project?
BR
Emma
Hi Emma,
I believe the clock is also shared with LIN peripheral, so I don't know if you will be able to avoid using the same clock as SPI/SCI with LIN. I will reach out to LIN owner on this.
Regards,
Vince
Hi Emma,
Could you try the "lin_ex2_sci_loopback.c" example and see if it works for you? I'm looking at your code and a lot of the items from that example are missing. For example, clearing interrupts in the ISR is missing.
I will let LIN owner comment further if you cannot get loopback example to work.
Regards,
Vince
Vince,
They have tested the lookback mode. they still can receive the data on SCIRD but can not go into the interrupt.
Could you kindly give me the code which support external communication, setting lin as SCI?
Then I can just change the baud rate and use it.
Emma
Hi Emma,
In "lin_ex2_sci_loopback" example you just need to comment out the "LIN_enableIntLoopback(LINA_BASE)", which I see you have already done. Also if you are receiving the data on SCIRD, then looks like the code is working.
Can you check if all the interrupt configurations are happening correctly i.e. when below lines get executed, does it really set the bits?
//
// Enable interrupt for when a frame has been completely received
//
LIN_enableSCIInterrupt(LINA_BASE, LIN_SCI_INT_RX);
//
// Set the interrupt priority to line 0 (high)
//
LIN_setSCIInterruptLevel0(LINA_BASE, LIN_SCI_INT_RX);
Best Regards,
Nirav