Is there a way to set up Serial for Idle Low ? (For UNO R3 SoftwareSerial could be used).
Part of code that is working (for Idle High) :
void setup() {
delay(2000);
Serial.begin (115200);
//Serial1.setRX(2); //optional to change pin
//Serial1.setTX(16); //optional to change pin
Serial1.begin (9600,SERIAL_8N1); //(9600,SERIAL_8E1) // (9600,SERIAL_8O1)
Serial.println(N);
delay(5000); // Note long delay
Serial.println("Serial_Tx_Raspberry Pi Pico2");
}
void loop() {
N=N+1;
//Serial1.write ("ABC");
// Serial.print("Serial_Tx_UNO_R4 ");
Serial.print("loop counter: "); Serial.print(N);
Serial.println(" A B C") ;
Serial1.write (65);
Serial1.write (66);
Serial1.write (67);
delay(300);
}
Serial (i.e. USB) or SerialX (i.e. UART)?
The code above sends pulses out on pin1 but with idle high. Uart.
Have you investigated the setInvertTX and setInvertRx methods of the SerialUART class?
It is a little unusual to operate serial with the line idling low, but there is a discussion here:
https://forums.raspberrypi.com/viewtopic.php?t=360230
The last post mentions two possible scenarios (inverting the data vs turning off the line until needed) and the Pico SDK commands to use for each.
The marine nmea0183 and some other applications use idle low. I am trying to avoid an inverter logic IC after the Pi pico2 pin.
setInvertTX. I read something about this , and tried something , but then the code did not compile. Error.
So I need an exact code-statement and where to put it. Before ”begin(9600)” I think
I'm sure you'll figure it out if you put your mind to it. Don't expect others to do all your research for you.
Yes now it works. Pulses are fine on oscilloscope with Serialdecode IdleLow correct.
long N=0;
void setup() {
delay(2000);
Serial.begin (115200);
//Serial1.setRX(2); //optiona to change pin
//Serial1.setTX(16); //optiona to change pin
Serial1.setInvertTX(1); // sets inverted , idle Low
Serial1.begin (9600,SERIAL_8N1); //(9600,SERIAL_8E1) // (9600,SERIAL_8O1)
Serial.println(N);
delay(5000); // Note long delay
Serial.println("Serial_Tx_Raspberry Pi Pico2");
}
void loop() {
N=N+1;
Serial.print("loop counter: "); Serial.print(N);
Serial.println(" A B C") ;
Serial1.write (65);
Serial1.write (66);
Serial1.write (67);
delay(300);
}