7 years, 5 months ago.

Serial Parity Issue


I'm attempting to use a parity bit within my application with little success. To eliminate an issue with my code I've tried to incorporate a parity bit into a simple application (as shown below) and this doesnt appear to work either. I would expect, as there appears to be no error handling, that the receiver would just scrap the incomming packet. What I see is the receiver acknowledging any character transmitted using a standard hyperterminal configured with both odd and even parity.

Can anyone see what I'm doing wrong? Has anyone used the parity check within serial.h?

#include "mbed.h"
DigitalOut led1(LED1);
DigitalOut led2(LED2);
Serial pc(USBTX, USBRX);
void callback() {
    // Note: you need to actually read from the serial to clear the RX interrupt
    printf("%c\n", pc.getc());
    led2 = !led2;
int main() {
    while (1) {
        led1 = !led1;

Question relating to:

1 Answer

7 years, 5 months ago.

The documentation does not say explicitly but it would be unusual for the code to discard RX characters with bad parity - you sometimes want to see these. I guess you'll have to read the line status register yourself directly and check the PE bit (2). See also http://mbed.org/forum/mbed/topic/1201/