8 years, 3 months ago.

Serial port at 300 baud

I am trying to read data with an mDot from a serial device that only accepts a baudrate of 300, protocol 7E1. Code follows. Baudrate of 300 is not working, as far as I can see. Is there a lower limit for that parameter? I tested the port with a different device at 9600,8N1 and it works ok. Any advice?

#include "mbed.h"
#include "mDot.h"

Serial mmm(PA_2, PA_3);         //  D1,D0 in kit
Serial pc(USBTX, USBRX);        // debug

int main() {

    // Console
    pc.baud(115200);
    pc.printf("\n\rHello Serial\n\r");
    
    // Device
    mmm.format(7, SerialBase::Even, 1);  
    mmm.baud(300);
       
    mmm.putc(0x2f);    // Command
    mmm.putc(0x3f);
    mmm.putc(0x21);
    mmm.putc(0x0d);
    mmm.putc(0x0a); 

    while(1) pc.printf("%c",mmm.getc());    // Read answer
}

Question relating to:

The MultiConnect® mDot™ offers significantly longer range and improved radio performance compared to traditional wireless solutions—resulting in greater transmission range and reduced capital expense.

2 Answers

8 years, 3 months ago.

I dont have the mDot, but recall that other ST devices could not go below 2400 baud on Serial ports unless you selected the one for the host PC. This limitation is due to the baudrate divisor register that has a limited range: you either have to reduce the input frequency (which meant slowing down the processor clock) or you had to reduce the maximum available baudrate. You can check the mbed sourcecode for details and modify this in case you want to adjust the baudrate range. The other options might be to swap serialports between the host PC and the peripheral. This would probably involve a hardware modification. Yet another solution would be a software serialport. This should work if you transmit only small amounts of data. There are some soft serial libs available in the mbed code repository.

Thanks for your advice, Wim. From these options, my choice would be to reduce the maximum available baudrate. But I have never handled mbed sourcecode. Which startpoint would you recommend?

posted by Alejandro Veiga 10 Aug 2016

Reducing the frequency of the processor is a risk because I still need the radio, as Jason noted. I tested PC serial port of mDot and I found it can neither run at 300 bauds. So I put it to work with SoftSerial. But I still believe that changing the range of the baudrate is a good idea. There are more chances to find an old serial device that requires a slow baudrate, than running a serial port at megahertz speeds. Is that possible without changing the clock speed?

posted by Alejandro Veiga 11 Aug 2016

See here for a discussion regarding the clockrate. The F401 should be able to slow down the peripheral clockrate PCLK2 (and thus the minimal baudrate) without reducing the system coreclock. I dont know in detail what the dependencies are between the mDot processor and the radio. A quick check of the mbed sourcecode seems to suggest the interface is through SPI and some digital pins?

posted by Wim Huiskamp 16 Aug 2016
8 years, 3 months ago.

I would suggest investigating the software serial port. Adjusting the core or peripheral clock may cause other peripherals to not function. I assume in the end you will still want the radio to be functioning?