skpang
Well-known member
I'm trying to write a LIN-bus driver for Teensy 3.2
A LIN-bus frame consist of break, synch(0x55), Ident, data. I'm trying to do this in software and found when I configure the uart there seems to be a delay of 1mS before the synch(0x55) is sent out.
Any idea why there is a delay of 1mS before the synch byte is sent out and how to remove that ?
The green trace is the test_pin to show where is the code is.
I also tried this on an Uno board there is no delay before the synch byte is sent out.
A LIN-bus frame consist of break, synch(0x55), Ident, data. I'm trying to do this in software and found when I configure the uart there seems to be a delay of 1mS before the synch(0x55) is sent out.
Code:
int led = 13;
int lin_cs = 23;
int tx_pin = 1;
int test_pin = 5;
void setup() {
pinMode(lin_cs, OUTPUT);
pinMode(test_pin, OUTPUT);
digitalWrite(lin_cs, HIGH);
pinMode(led, OUTPUT);
digitalWrite(test_pin, HIGH);
pinMode(tx_pin, OUTPUT);
digitalWrite(tx_pin, HIGH);
delay(100);
digitalWrite(tx_pin, LOW); // Break
delayMicroseconds(1024); // Break dealy
digitalWrite(tx_pin, HIGH);
digitalWrite(test_pin, LOW);
Serial1.begin(9600);
digitalWrite(test_pin, HIGH);
Serial1.write(0x55); // Synch
Serial1.write(0x23); // Ident
Serial1.write(0x41); // Data
}
void loop() {
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(500);
digitalWrite(led, HIGH);
delay(100);
}
Any idea why there is a delay of 1mS before the synch byte is sent out and how to remove that ?
The green trace is the test_pin to show where is the code is.
I also tried this on an Uno board there is no delay before the synch byte is sent out.