1
I can’t do the reading of Serial in baudrate 110. I tried some alternatives of changing processor clock, but it didn’t work.
Does anyone have any idea or suggestion of what to do?
Thank you.
#define SSUSerial Serial1
#define RXD1 5
#define TXD1 18
char dataSSU[255];
void setup()
{
setCpuFrequencyMhz(80);
pinMode(SSerialTxControl, OUTPUT);
digitalWrite(SSerialTxControl, RS485Transmit); // Init Transceiver
// Start the software serial port, to another device
RS485Serial.begin(9600, SERIAL_8N1, RXD2, TXD2);
SSUSerial.begin(110, SERIAL_8N1, RXD1, TXD1);
RS485Serial.setRxBufferSize(512);
SSUSerial.setRxBufferSize(512);
RS485Serial.println(F_CPU);
RS485Serial.println(getCpuFrequencyMhz());
}
void loop()
{
while (true)
{
digitalWrite(SSerialTxControl, RS485Transmit); // Disable RS485 Transmit
if (int bytes = SSUSerial.available()) //Look for data from other Arduino
{
RS485Serial.printf("Detected bytes in serial is %lu\n", bytes);
while (SSUSerial.available())
{
delay(1);
char caractereSSU = SSUSerial.read();
dataSSU[countSSU] = caractereSSU;
countSSU++;
}
for(int i = 0; i < countSSU; i++){
RS485Serial.print("[");
RS485Serial.print(int(dataSSU[i]), DEC);
RS485Serial.print("]");
}
dataSSUComplete = true;
}
String conteudo = "";
char caractere;
int count = 0;
RS485Serial.print("Numero de Bytes Recebidos:");
RS485Serial.print(countSSU);
RS485Serial.println("<- Recebido pelo SSU");
RS485Serial.flush();
digitalWrite(SSerialTxControl, RS485Receive); // Disable RS485 Transmit
countSSU = 0;
}
}