Change Baudrate in runtime on old project - ATMega328

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 6.

Moderator: Benj

Niro
Posts: 77
Joined: Mon Jan 03, 2011 8:58 pm
Has thanked: 29 times
Been thanked: 10 times
Contact:

Change Baudrate in runtime on old project - ATMega328

Postby Niro » Tue Dec 18, 2018 5:03 pm

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);
}

User avatar
Benj
Matrix Staff
Posts: 14468
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4536 times
Been thanked: 4204 times
Contact:

Re: Change Baudrate in runtime on old project - ATMega328

Postby Benj » Tue Dec 18, 2018 6:12 pm

Hello,

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

Niro
Posts: 77
Joined: Mon Jan 03, 2011 8:58 pm
Has thanked: 29 times
Been thanked: 10 times
Contact:

Re: Change Baudrate in runtime on old project - ATMega328

Postby Niro » Tue Dec 18, 2018 6:56 pm

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