9 years, 8 months ago.

NUCLEO SERIAL Parity function BUG

Hey,

i think there is a BUG in the Serial Implementation for NUNCLEO BOART 401RE. When I call the function format and set the Parity to EVEN, the USART doesn't make the PARITY BIT. I only see the Start Bit,8 Data Bit and 2 Stop Bits. (SEE PICTURE). It is the same when I set the Parity to odd. And I miss the last 1 (Bit7);

greetings ChrisH

include the mbed library with this snippet

#include "mbed.h"
 #include "cdef.h"
 #include "FastPWM.h"
#include "LCD.h"
 FastPWM pwm(PB_6);
 DigitalOut myled(LED1);
Serial device(PA_9, PA_10);

int main() {
    int i = 0;
    pwm.period_ms(19);
    pwm.pulsewidth_us(2000);
    device.format(8,SerialBase::Even,2);
    device.baud(100000);
    while(1) {
        device.putc(134);
        while(!device.writeable());
       myled = 1; // LED is ON
     wait(0.3); // 200 ms
 myled = 0; // LED is OFF
    wait(0.3); // 1 sec
    }
}

/media/uploads/chrish/tek0000.bmp

1 Answer

9 years, 8 months ago.

Hi, Christopher

The definition of even parity is that if the number of "1" bits in the stream is an odd number, the parity bit turns to 1, if the number os "1" bits is an even number, the parity bit remains 0. In your number (134) you have 3 of ones (10000110), 2 stop bits, that is 5 ones, so your parity bit should also be a 1.

Regards, thenoble66