I’m using a boron to communicate with another micro over serial1 only problem is that the required baud rate is 63000. The problem is it looks like I cant setup Serial1 for 63000.
When ever I include the following code in Setup
Serial1.begin(63000,SERIAL_8E1); // for profibus mux
The boron boots up ok, but then throws a panic:hard fault error as soon as it hits the line.
Doing a safe boot, followed by reprogramming with the baud rate changed to 115200 fixes it
I have also verified that the ARGON has the exact same behavior.
The troubleshooting guides says that hard faults are caused by the following
- Using an invalid pointer.
- Memory corruption caused by freeing memory twice, overwriting the end of a block of memory, etc.
- Making Wire (I2C) calls without calling Wire.begin().
Since the only change needed is to change the baud rate back to a standard one, I don’t think the issue is with my code.
Also just for grins I changed it to 57600 and there was no hard fault, but changing to 57601 resulted in a hard fault. Seems like it is anything other than “approved” baud rates.
So is there anyway I can use custom baud rates with the Boron?
Can it be done with direct writes to registers?
Any help would be appreciated, since it is sort of a show stopper…
Thanks to all. Ended up just writing to the Nordic’s uart baudrate register.
Verified and it works.
Note that this has only been tested on the BORON, but should also work on the ARGON since they use the same micro
#define UARTE0_BASE_ADDR 0x40002000 // As per nRF52840 Product spec - UARTE #define UARTE1_BASE_ADDR 0x40028000 // As per nRF52840 Product spec - UARTE #define UART_BAUDRATE_REG_OFFSET 0x524 // As per nRF52840 Product spec - UARTE #define UART0_BAUDRATE_REGISTER (*(( unsigned int *)(UARTE0_BASE_ADDR + UART_BAUDRATE_REG_OFFSET))) #define UART1_BAUDRATE_REGISTER (*(( unsigned int *)(UARTE1_BASE_ADDR + UART_BAUDRATE_REG_OFFSET))) /* from nRF52840 Product spec A baud rate of 31250 uses a register value of 0x00800000 (31250/0x00800000) = 0.00372529 baud per bit 63000 / 0.00372529 = 0x0102116F rounding it off to 0x0102100 give a theoretical baud rate of 62998 (Pretty good) */ #define BAUD63000 0x01021000 Serial1.begin(19200,SERIAL_8E1); // IFS board attached to Serial1, use this to setup Serial port for class use // original values - used to verify that we are looking at the correct registers Serial.print("UART0 Baud rate: 0x"); Serial.println(UART0_BAUDRATE_REGISTER,HEX); Serial.print("UART1 Baud rate: 0x"); Serial.println(UART1_BAUDRATE_REGISTER,HEX); Serial.println(""); // change the baud rate UART0_BAUDRATE_REGISTER = BAUD63000;// NOTE: UART0 is attached to Serial1. Serial is attached to USB // Did the right stuff change? Serial.print("UART0 Baud rate: 0x"); Serial.println(UART0_BAUDRATE_REGISTER,HEX); Serial.print("UART1 Baud rate: 0x"); Serial.println(UART1_BAUDRATE_REGISTER,HEX);