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.

TMS320F28034: LIN Communication problem

Part Number: TMS320F28034
Other Parts Discussed in Thread: C2000WARE,

Dears:

   I use GPIO9 as LINTXA, write TDO register, but there are no date out from TX pin. the Header transmit is OK, but the date is not OK, always high level. 

attachment is my part of code and LIN Initialization code.

static void Init_LINSCI(void)
{
  EALLOW;

//====================================================================
/*
SCIGCR0 --- Address

*/
//  LinaRegs.SCIGCR0.all = 0;

  //Reset module and release reset.
  LinaRegs.SCIGCR0.bit.RESET = 0;
  LinaRegs.SCIGCR0.bit.RESET = 1;

  //LIN into software reset mode
  LinaRegs.SCIGCR1.bit.SWnRST = 0;

  //Select LIN Mode
  LinaRegs.SCIGCR1.bit.LINMODE = 1;         // lin mode enable.


  //Configure LIN mode
	LinaRegs.SCIGCR1.bit.CLK_MASTER = 1; 	// 1-->Master, 0-->Slave
//	LinaRegs.SCIGCR1.bit.TIMINGMODE = 1; 	// Must be set to 1 when module is configured for SCI operation
	LinaRegs.SCIGCR1.bit.ADAPT = 0; 		// Fixed baud rate
	LinaRegs.SCIGCR1.bit.COMMMODE= 0; 		// ID bits 4 and 5 not used for length control
	LinaRegs.SCIGCR1.bit.CONT = 1; 			// Continue on Emulation suspend
	LinaRegs.SCIGCR1.bit.CTYPE = 0; 		// LIN 2.0 Enhanced checksum used
	LinaRegs.SCIGCR1.bit.HGENCTRL = 1; 		// ID match vs LinaRegs.bit.IDSLAVETASKBYTE
	LinaRegs.SCIGCR1.bit.LOOPBACK = 0; 		// External communication mode
	LinaRegs.SCIGCR1.bit.MBUFMODE = 1; 		// Buffered mode
	LinaRegs.SCIGCR1.bit.PARITYENA = 0; 	// Check received ID for parity
	LinaRegs.SCIGCR1.bit.RXENA = 1; 		// Enable RX pin
	LinaRegs.SCIGCR1.bit.TXENA = 1; 		// Enable TX pin

	//More LIN configs
//	LinaRegs.SCIGCR2.bit.CC = 1; 			// Validate checksum


	//Set all interrupts to disabled
  LinaRegs.SCICLEARINT.all 		= 0xFFFFFFFF;
//  LinaRegs.SCISETINT.bit.SETRXINT = 1;		// Receiver Interrupt is enabled.
 // LinaRegs.SCISETINT.bit.SETTXINT = 1;		// Transmitter Interrupt is enabled.
 // LinaRegs.SCICLEARINT.bit.CLRTXINT = 1;		// Transmitter Interrupt is disabled.
 // LinaRegs.SCISETINT.bit.SETBRKDTINT = 1;   // break-detect interrupt is enabled.
//  LinaRegs.SCISETINT.bit.SETIDINT = 1;   // Set Identification interrupt.
//  LinaRegs.SCISETINT.bit.SETISFEINT = 1;   // Set inconsistent-sync-field-error interrupt.

  //
  LinaRegs.SCICLEARINTLVL.bit.CLRRXINTLVL = 1; // Receiver Interrupt level mapped to INT0 line.
//  LinaRegs.SCICLEARINTLVL.bit.CLRBRKDTINTLVL = 1; // Break-detect Interrupt level mapped to INT0 line.
  LinaRegs.SCICLEARINTLVL.bit.CLRIDINTLVL = 1; // id Interrupt level mapped to INT0 line.
  LinaRegs.SCICLEARINTLVL.bit.CLRISFEINTLVL = 1; // Inconsistent-Sync-Field-Error interrupt level mapped to INT0 line.
  LinaRegs.SCISETINTLVL.bit.SETTXINTLVL = 1;  // Transmitter Interrupt level mapped to INT1 line.

  //Baud Rate Settings - 60MHz device
  LinaRegs.BRSR.bit.SCI_LIN_PSH = 0;
  LinaRegs.BRSR.bit.SCI_LIN_PSL = 389; 		// 4.8 kbps
  LinaRegs.BRSR.bit.M = 10;

//  LinaRegs.BRSR.bit.SCI_LIN_PSH = 0;
//  LinaRegs.BRSR.bit.SCI_LIN_PSL = 194; 		// 9.6 kbps
//  LinaRegs.BRSR.bit.M = 5;

//  LinaRegs.MBRSR = 92;                      //20kHz (max autobaud rate)

  //LIN Character Size and Length
  LinaRegs.SCIFORMAT.bit.LENGTH 	= 7; 	// 8 bit transmission/response
//  LinaRegs.SCIFORMAT.bit.CHAR 	= 7; 	// The character is 8 bits long.
//  LinaRegs.SCIFORMAT.all = 0x00070007;


  //SYNC Field Configuration
  LinaRegs.LINCOMP.bit.SBREAK = 0; 		// Sync break is 13 + 5 = 18 Tbits
  LinaRegs.LINCOMP.bit.SDEL = 0; 			// Sync delimiter is 1 + 3 = 4 Tbits

  //LIN MASK Configuartion
  LinaRegs.LINMASK.bit.TXIDMASK = 0x0a;//0xFF; 	// Mask ID so TX match will always happen
  LinaRegs.LINMASK.bit.RXIDMASK = 0x0a;//0xFF; 	// Mask ID so RX match will always happen

  //IODFT Configuarations
//  LinaRegs.IODFTCTRL.bit.IODFTENA = 0x0; 	// IODFT testing module disabled
//  LinaRegs.IODFTCTRL.bit.LPBENA 	 = 0; 	// IODFT loopback disabled

  //
  LinaRegs.LINID.bit.IDSLAVETASKBYTE = 0x30;	// 0x30


  //Release	SCI from software reset state - End of Config
  LinaRegs.SCIGCR1.bit.SWnRST = 1;

  EDIS;
}

  • Hello,

    Have you ran any of the LIN software examples within C2000Ware to rule out any possible hardware issues?

    C:\ti\c2000\C2000Ware_version\device_support\f2803x\examples\c28\lina_external_loopback

    Also, could you please provide the content for SCIFLR register to determine if there were any errors?

    Best Regards,

    Marlyn

  • hello,I found that after the short connection between Rx and Tx, the data was sent normally, but the data could not be sent if they were disconnected.

  • If I do not connect the RX and TX pins, the IDTXFLAG flag bit will not be set to 1 after writing the TD0 register. But if I connect the RX and TX, this IDTXFLAG flag and IDRXFLAG flag bits will be set to 1 and the data will be sent to the TX pin.

    I emulated the lina_external_loopback routine to do the same.

  • Hi jh,

    What are you trying to connect your TX line to within an application? Have you tried testing if data is sent while the TX line is connected to a receiver?

    Best Regards,

    Marlyn

  • hi Marlyn,

    I have tried to connect the TX pin to the RX pin of another device in the application, and only see a header transmission being sent on this bus, no data.

  • Hi jh,

    Could you please monitor the SCIFLR register and see if there are any errors, this will be indicated if any of the flags are set.

    Best Regards,

    Marlyn

  • hi marlyn,

    Of course, I have monitored the SCIFLR register and no other error flags have appeared. When I write the TD0 register this TXRDY flag and TXEMPTY flag bits are cleared to zero.

    Theoretically, no error flags should occur when the master sends data. However, why is the IDTXFLAG  flag bit not set to 1 when disconnecting RX and TX?

    Can you help me debug a project that can be master sent?

    thank you very much.

  • Hi jh,

    The other node on the bus is not being identified, have you done some debugging on the other device that is being connected within this application?

    Best Regards,

    Marlyn

  • Hi Marlyn,

    I think you are missing the point of the question. Other device nodes are used as slave. Now it's the TMS320F28034 device that the master can't send data. I don't think it has anything to do with other devices.

    why is the IDTXFLAG  flag bit not set to 1 when disconnecting RX and TX?

  • Hi jh,

    The IDTXFLAG bit is set once an identifier is received with a TX match and no ID-parity error. Looking at the "Message Filtering and Validation" portion of the Technical Reference Manual, I would suggest you try a mask of all 1s so that there can always be an ID match regardless of the content of the ID-SlaveTask BYTE field in the LINID register, for debug purposes.

    Best Regards,

    Marlyn

  • hi Marlyn,

    From the code I posted you can see my LIN initialization configuration, just like what you said.The value was also debugged but to no avail.I have looked over the reference manual many times.If I do not connect the RX and TX pins, the IDTXFLAG flag bit will not be set to 1 after writing the TD0 register. But if I connect the RX and TX, this IDTXFLAG flag and IDRXFLAG flag bits will be set to 1 and the data will be sent to the TX pin.

  • jh,

    The TXIDFLAG will be set to one when a TX Match occurs. The received ID of an incoming header will be compared in order to decide whether a RX response, a TX response, or no action needs to be done by the LIN node. Writing to the IDBYTE bit will just initiate a header transmission. That is why when the RX and TX pins are connected a TX Match is able to happen and the data is able to be transmitted.

    Best Regards,

    Marlyn

  • Hi Marlyn,

    Yes, you're absolutely right. But now the problem is that TX matches occured only when RX and TX pins are connected and written to theTD0 register,and the IDTXFLAG flag bit will be set to 1. The actual application will not connect RX to TX, so it can only send the frame header, not the data.

    Theoretically, Whether the TX pin is connected to the RX pin or not,the TX match should occur after it sends the frame header.However, the current emulation is not occurring, and there are no other errors in the SCIFLR register.

    best regards.

  • Hi jh,

    LIN is a half duplex protocol. You would have to use a LIN transceiver to connect to the bus. 

    When a transceiver is used, the LIN transmit side is also able to receive the data its transmitting and it validates the data being transmitted.

    Only when it knows the ID transmitted matches on bus the IDTXFLAG will get set. So that might be reason why connecting RX TX is working in your case.

    Regards,

    Yashwant

  • hi Yashwant,

    Thank you for your reply. I checked the datasheet for the LIN transceiver. LIN's TX bus data also appears on the RX bus. But it still didn't solve my puzzle.

    When I disconnect Rx and Tx, I can also see the frame header waveform through the oscilloscope on the Tx bus. The frame header contains the correct ID number. Theoretically, a TX match should occured, but it doesn't. Why?

    From your point of view, the TX match must occured only on the RX pin. But this does not correspond to the reference manual for the microcontroller.

    best regards.

  • Hi jh,

    Can you please explain/show what your connections are between the transceiver and the F2803x device?

    Best Regards,

    Marlyn