Search code examples
arduinoserial-portuartarduino-idetexas-instruments

How can I change UART configurations(# of stop bits, parity bits etc.) on ENERGIA IDE?


I need to use UART of TI CC3220s launchpad with 2 stop bits. how can I change the UART configurations on energia ide like number of stop bits?

config parameters do not work (https://energia.nu/reference/en/language/functions/communication/serial/begin/)
the following error occurs: 'SERIAL_5N1' was not declared in this scope

Any help will be appreciated.

Thanks in advance


Solution

  • edit
    The link that you provided directly says:

    Serial.begin(speed) Serial.begin(speed, config)
    Arduino Mega only

    According to the code (I found), the Serial library of Energia-IDE is only a SoftwareSerial, that only provides the begin(speed) function (without a config). Maybe you should have a look into that, so that you can adapt the function, for your own purpose.
    /edit

    In the Arduino-IDE, the config's are defined in HardwareSerial.h. If the Energia-IDE uses the same library, you might try to use the same values instead.

    // Define config for Serial.begin(baud, config);
    #define SERIAL_5N1 0x00
    #define SERIAL_6N1 0x02
    #define SERIAL_7N1 0x04
    #define SERIAL_8N1 0x06
    #define SERIAL_5N2 0x08
    #define SERIAL_6N2 0x0A
    #define SERIAL_7N2 0x0C
    #define SERIAL_8N2 0x0E
    #define SERIAL_5E1 0x20
    #define SERIAL_6E1 0x22
    #define SERIAL_7E1 0x24
    #define SERIAL_8E1 0x26
    #define SERIAL_5E2 0x28
    #define SERIAL_6E2 0x2A
    #define SERIAL_7E2 0x2C
    #define SERIAL_8E2 0x2E
    #define SERIAL_5O1 0x30
    #define SERIAL_6O1 0x32
    #define SERIAL_7O1 0x34
    #define SERIAL_8O1 0x36
    #define SERIAL_5O2 0x38
    #define SERIAL_6O2 0x3A
    #define SERIAL_7O2 0x3C
    #define SERIAL_8O2 0x3E
    

    At least this passes the "validate" step in the Energia-IDE:

    void setup()
    {
      Serial.begin(9600, 0x00);
    }