Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 8 of 8

Thread: Working on an Interrupt Based LIN-Client

Threaded View

  1. #1
    Senior Member
    Join Date
    Apr 2013

    Working on an Interrupt Based LIN-Client

    Hello there,

    some weeks ago I finished an LIN-Master that used the LIN-Break provided by the Teensy Chips (T3.0 - 3.6). After this I was working on an LIN-Slave with Interrupt based Breakdetection, detection and reading works also handling from different IDs, what I can't get to work is the LIN-Response, I hope someone can help me solv it.

    Technically I struggle on this part:
    void LIN_Slave::response(frame d) {  
      UART0_TWFIFO = 1;
      byte b;
      //UART0_C2 &= ~UART0_C2_RX_ENABLE;
      UART0_C1 |= UART_C1_LOOPS;
      UART0_C1 |= UART_C1_RSRC;
      if (d.version == 1 || d.version == 0)
        d.crc = dataChecksum(, d.length, 0);
        d.crc = dataChecksum(, d.length, message[1]&0x3F);
      //junkpart for direct wiring
      byte junk[] = {0x00, 0x55, message[1]};
      for (int i = 0; i < 3; i++) {
        while(!(UART0_S1 & UART_S1_TDRE));
          UART0_D = junk[i];
      for (int i = 0; i < d.length; i++) {
        while(!(UART0_S1 & UART_S1_TDRE));
          UART0_D =[i];
      while(!(UART0_S1 & UART_S1_TDRE));
        UART0_D = d.crc;
      Serial.println(d.crc, HEX);
    //  Serial.print("UART0_C2 ");
    //  PRINTBIN(UART0_C2);
      //UART0_C2 |= UART0_C2_RX_ENABLE;
      UART0_C1 |= UART_C1_LOOPS;
      //UART0_C1 |= UART_C1_RSRC;
    //  Serial.print("UART0_C2_");
    //  PRINTBIN(UART0_C2);
    If I connect 2 Teensys without the LIN-Stuff between it (T1 Tx to T2 Rx, T1 Rx to T2 Tx) it works well (needed to include the junkpart for the Master to transmit enough bytes)

    I used the Parts from SKPang for the LIN-Parts.

    Based on the MCP2004A(LIN Bus-Driver) the Rx Pin to the Uart has the following behavior
    Click image for larger version. 

Name:	MCP2004A_RX.JPG 
Views:	12 
Size:	22.9 KB 
ID:	17820
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts