Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[patch #6768] Addition to util/setbaud.h #763

Open
avrs-admin opened this issue Jan 31, 2022 · 2 comments
Open

[patch #6768] Addition to util/setbaud.h #763

avrs-admin opened this issue Jan 31, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@avrs-admin
Copy link

Thu 05 Mar 2009 05:21:09 PM CET

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>
UBRRH = UBRRH_VALUE;
UBRRL = UBRRL_VALUE;
UCSRC = _BV(1<<UMSEL);
Configure as clock source
XCK_DDR |= _BV(1<<XCK_DDx);
}

file #17593: setBaud.diff

This issue was migrated from https://savannah.nongnu.org/patch/?6768

@avrs-admin
Copy link
Author

Frédéric Nadeau
Thu 05 Mar 2009 05:43:04 PM CET

After reread, it should be:

UCSRC |= _BV(1<<UMSEL);

But I guess that most of you already spotted that.

@avrs-admin
Copy link
Author

Eric Weddington
Fri 13 May 2011 12:28:38 AM CEST

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?

@sprintersb sprintersb added the enhancement New feature or request label Feb 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants