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

Post Reply
Niro
Posts: 77
Joined: Mon Jan 03, 2011 8:58 pm
Contact:

Change Baudrate in runtime on old project - ATMega328

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

User avatar
Benj
Matrix Staff
Posts: 14929
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Contact:

Re: Change Baudrate in runtime on old project - ATMega328

Post by Benj »

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
Contact:

Re: Change Baudrate in runtime on old project - ATMega328

Post 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

Post Reply