But I could able to send the data exactly to the slave from master. The ouput is printing just "??????". I dont know exactly where I am doing mistake. I am also attaching the screenshot and the codes that I am using to test the hardware serial.
My main task is to read and write the sensor values from the both the boards and and send them acorrding to algorithm given to the boards.
Hoping for responses from you.
Here below I am posting the code for my Master:
Code: Select all
#define enable PB15
HardwareSerial myserial(PA10, PA9);
char firstname[7] = "Mustaq";
void setup()
{
pinMode(enable, OUTPUT);
digitalWrite(enable, HIGH);
Serial.begin(115200);
myserial.begin(19200);
}
void loop()
{
myserial.write(firstname);
Serial.println(firstname);
delay(1000);
}
Code: Select all
#define enable PC14
HardwareSerial myserial(PA10, PA9);
char myname[7];
byte nextchar = 0;
byte currentchar = 0;
void setup()
{
pinMode(enable, OUTPUT);
digitalWrite(enable, LOW);
Serial.begin(115200);
myserial.begin(19200);
}
void loop()
{
Serial.println("before while");
while(myserial.available());
{
Serial.println("inside while");
currentchar = myserial.read();
myname[nextchar] = currentchar;
nextchar++;
Serial.println("one loop of while is done");
}
Serial.println(myname);
delay(1000);
}
https://github.com/stm32duino/Arduino_Core_STM32. I am working on Windows 10. My Arduino IDE version 1.8.5.