ArduPilot / SiK

Tools and firmware for the Si1000
BSD 2-Clause "Simplified" License
286 stars 232 forks source link

Custom SERIAL_SPEED #36

Open Georges760 opened 7 years ago

Georges760 commented 7 years ago

Hello,

I am trying to use SiK on a HM-TRP in order to transmit a 76800 bps UART over the air.

76800 bps is not in the known SERIAL_SPEED, so I modified serial.c to add it's support :

static const __code struct {
    uint8_t rate;
    uint8_t th1;
    uint8_t ckcon;
} serial_rates[] = {
    {1,   0x2C, 0x02}, // 1200
    {2,   0x96, 0x02}, // 2400
    {4,   0x2C, 0x00}, // 4800
    {9,   0x96, 0x00}, // 9600
    {19,  0x60, 0x01}, // 19200
    {38,  0xb0, 0x01}, // 38400
    {57,  0x2b, 0x08}, // 57600 - default
    {115, 0x96, 0x08}, // 115200
    {76,  0x61, 0x08}, // 76800 - replace the 203400
};

After compiling and firmware upload, I can select this new speed with AT commands. But after save eeprom and reboot, i am not able anymore to access AT mode by sending '+++' at 76800 bps...

Did I do something wrong ?

As long as the Si1000 UART baud rate is controled by the Timer1 Overflow, setting the TH1 register to 0x61 should do the job. Si1000 datasheet give the formula UartBaudRate = T1CLK / (2 * (256 - TH1)) so with a T1CLK of 24.5 MHz, this should give a good 77044 bps so only -0.32% error...

Note : I have Mavlink framing disabled.

Maybe should I stay on 1.9 stable release ?

Anyone tryed these intermediate but still standard baud rates ?

I know how to force bootloader mode at startup in order to upload again FW, but what baud rate should I use now ?

Thanks,

Georges

VigibotDev commented 7 years ago

Hi,

bootloader.c set the TH1 to 0x96 :

TH1              =  0x96;               // 115200 bps

(Also I use 230400 baud on my project without any problem but I never tested 77044)

Pascal