headedspy
(Vladimir Vladinov)
April 13, 2020, 12:04am
1
Hello there,
I need to create a serial communication for the Nucleo F303RE board using the A1 and A0 pins. So far I’ve tried several libraries for software serial communication but with no luck.
So far this code which is supposed to echo returns only 224.
#include "mbed.h"
#include "SoftSerial.h"
SoftSerial SerialAD(A1, A0);
//TX RX
uint8_t num;
int main(){
SerialAD.baud(9600);
while(1){
while(SerialAD.readable() == 1){
num = SerialAD.getc();
SerialAD.putc(num);
}
}
}
And when I try to send some info with putc() it sends the data multiplied by two except for the 10:
I can’t wrap my head around what exactly am I missing and would be more than grateful for some help.
JohnnyK
(Jan Kamidra)
April 13, 2020, 10:19am
2
Hi,
probably depends on the board and its speed on GPIO pins or something like that.
I tested your code on two boards:
Nucleo-F446RE = no problem, it runs OK
Nucleo-F303K8 = similar problem like you have
BR, Jan
headedspy
(Vladimir Vladinov)
April 13, 2020, 12:39pm
3
Well I’m driving a CO2 sensor which requires 9600 baud rate and I can’t switch its connected pins. I’m out of ideas on what to do ¯_(ツ)_/¯
JohnnyK
(Jan Kamidra)
April 13, 2020, 1:15pm
4
Why you can not switch to another pins?
headedspy
(Vladimir Vladinov)
April 13, 2020, 1:44pm
5
Because the sensor is mounted on a shield that connects it to those two pins specifically
JohnnyK
(Jan Kamidra)
April 14, 2020, 8:27pm
6
Maybe remove the these two pins from the header of the shield and replace them with wires and connect it to PA_14 and PA15.
BR, Jan