Markus_L811
Well-known member
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:
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 http://skpang.co.uk/catalog/teensy-canbus-and-linbus-breakout-board-include-teensy-32-p-1566.html for the LIN-Parts.
Based on the MCP2004A(LIN Bus-Driver) the Rx Pin to the Uart has the following behavior
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:
Code:
void LIN_Slave::response(frame d) {
UART0_TWFIFO = 1;
byte b;
notes(&tmp);
//Serial.print(d.length);
//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.data, d.length, 0);
else
d.crc = dataChecksum(d.data, d.length, message[1]&0x3F);
__disable_irq();
delayMicroseconds(100);
__enable_irq();
/*
//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 = d.data[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 http://skpang.co.uk/catalog/teensy-canbus-and-linbus-breakout-board-include-teensy-32-p-1566.html for the LIN-Parts.
Based on the MCP2004A(LIN Bus-Driver) the Rx Pin to the Uart has the following behavior