Page 1 of 1

Change Baudrate in runtime on old project - ATMega328

Posted: Tue Dec 18, 2018 5:03 pm
by Niro
Hi guys,

I urgently need to fix an old project with FCV6 to change the UART baudrate in runtime from 38400 to 4800 and back,
using an ATMega328.

I found a post about this problem, but this solution doesn't seem to work.
Calling the FC macro within C-code with parameter 2 stops working with 38400 Baud,
but doesn't work on 4800 Baud. Changing it back to 38400, the UART doesn't work here anymore also.

Did I miss anything??

Any help would be appreciated!
Many thanks!!

Code: Select all

/*=----------------------------------------------------------------------=*\
   Use :Changes the hardware UART baud rate allowing for dynamic speed changes.
       :
       :Parameters for macro ChangeHWBaud:
       :  NewBaud : 0=1200, 1=2400, 2=4800, 3=9600, 4=19200, 5=38400, 6=57600, 7=115200
\*=----------------------------------------------------------------------=*/
void FCD_047b1_RS232__ChangeHWBaud(MX_UINT8 FCL_NEWBAUD)
{
	FC_CAL_UART_UpdateBaud_1(FCL_NEWBAUD);
}

Re: Change Baudrate in runtime on old project - ATMega328

Posted: Tue Dec 18, 2018 6:12 pm
by Benj
Hello,

Please can you attach your project so we can see what you're currently doing.

Re: Change Baudrate in runtime on old project - ATMega328

Posted: Tue Dec 18, 2018 6:56 pm
by Niro
Hi Ben,

many thanks for your quick reply!

I just did some more testing and now got it working, changing the UART baudrate register UBRR0 directly .

Code: Select all

  
//BaudRate 4800 -> UBRR: 0x0067
// BaudRate 38400 -> UBRR: 0x000C

//Example for 4800:
UBRR0H = 0x00;
UBRR0L = 0x67;
Regards ;-)
Niro