Hello all!
The hw is set, namely running the TJA1021 transceiver on the AT Tiny 3216 and 1626, and apparently the master side works well, can see the signal on the LIN bus,
the code:
byte ledPin = 0;
byte brightness = 0;
byte txEnPin = 12;
byte fadeAmount = 1;
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(txEnPin, OUTPUT);
//LIN setup
Serial.swap(0);
Serial.begin(19200, SERIAL_HALF_DUPLEX); //
digitalWrite(txEnPin, HIGH);
}
void loop() {
Serial1.println(brightness);
delay(5);
brightness = 100;
Serial.write(brightness);
Serial.flush ();
}
However, the code below does not want to work and read from the transceiver , any ideas if the code for serial is ok?
#define LED_PIN PIN_PA4
byte ledPin = 0;
byte brightness;
byte txEnPin = 12;
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(txEnPin, OUTPUT);
//LIN setup
Serial.swap(0);
Serial.begin(19200, SERIAL_HALF_DUPLEX);
//normal, print out serial ! ? Why is see nonsense on this tport too?
Serial1.swap(0);
Serial1.begin(9600);
Serial1.println("dev board 2");
// setting up the tja1021?
digitalWrite(txEnPin, HIGH);
}
void loop() {
if ( Serial.available() ) {
byte t = Serial.read();
if ( true) {
analogWrite (ledPin, 255);
}
else analogWrite (ledPin, 0);
}
}
Any ideas comments, are more than welcome!
Best.