patchAVR C Runtime Library - Patches: patch #6768, Addition to util/setbaud.h


You are not allowed to post comments on this tracker with your current authentication level.

patch #6768: Addition to util/setbaud.h

Submitter:  Frédéric Nadeau <fnadeau>
Submitted:  Thu 05 Mar 2009 04:21:09 PM UTC
Category:  None Priority:  7 - High
Status:  None Privacy:  Public
Assigned to:  None Open/Closed:  Open

Thu 12 May 2011 10:28:38 PM UTC, comment #2: 

Hi Frédéric,

On line 16 of this patch you are defining BAUD_SYNC to 0 in the header file. Then later on, you check to see if it is not defined, if so then define BAUD_SYNC to 0. Shouldn't that first definition on line 16 be removed?

Eric Weddington <arcanum>
Group administrator
Thu 05 Mar 2009 04:43:04 PM UTC, comment #1: 

After reread, it should be:


But I guess that most of you already spotted that.

Frédéric Nadeau <fnadeau>
Thu 05 Mar 2009 04:21:09 PM UTC, original submission:  

I noticed that util/setbaud.h cannot calculate baudrate for sync mode.

I did the following modification to the file. I doubt it will it the
next release, but I do beleive it is a good thing to have.

Basic explanation:
if BAUD_SYNC is define and equal to 1, a modified macro is use to
calculate baud rate.
If BAUD_SYNC is define and equal to 0 or not define, macro works as before.

Modification should not break code that use the current version of setbaud.h.

Usage could be:
#include <avr/io.h>

#define F_CPU 4000000

static void uart_9600(void)
#define BAUD_SYNC 1
#define BAUD 9600
Device specific declaration
#define XCK_DDR DDRB//For ATmega16A
#define XCK_DDx DDB0
#include <util/setbaud.h>
   UCSRC = _BV(1<<UMSEL);
   Configure as clock source
   XCK_DDR |= _BV(1<<XCK_DDx);

Frédéric Nadeau <fnadeau>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by arcanum (Posted a comment)
  • -email is unavailable- added by fnadeau (Submitted the item)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.


    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2011-05-12 arcanum Priority5 - Normal 7 - High
    2009-03-05 fnadeau Attached File- Added setBaud.diff, #17593

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code