Hi,
I made some changes to add support for the ATmega162. In the ATmega162 the UCSRC register shares the same I/O location as the UBRRH register. The selected register is determined by the MSb value.
Attached is a patch against trunk.
Marco
[PATCH] ATmega162 support Topic is solved
[PATCH] ATmega162 support
- Attachments
-
- atmega162.patch.zip
- Patch for ATmega162 support
- (1.06 KiB) Downloaded 195 times
-
- Posts: 359
- Joined: Sat Jan 07, 2012 6:22 pm
- Location: Brazil
- Has thanked: 1 time
- Been thanked: 20 times
- Contact:
Re: [PATCH] ATmega162 support
Applied, thanks!
Some nitpicks without looking at the ATmega162 DS! The #ifdef block below is unnecessary because UBRR0H is probably an 8 bit register so the & 0x0f is superfluous.
In the code below | 0 might have been added for clarity purposes but not required and not common style.
Btw, what's your environment? I still get errors when merging your patches on macOS Sierra. Works on Linux passing --binary to patch. You should check your auto.crlf config if using the github mirror.
Cheers,
Fabio Utzig
Some nitpicks without looking at the ATmega162 DS! The #ifdef block below is unnecessary because UBRR0H is probably an 8 bit register so the & 0x0f is superfluous.
Code: Select all
#if defined(__AVR_ATmega162__)
UBRR0H = (config->sc_brr >> 8) & 0x0f;
#else
UBRR0H = config->sc_brr >> 8;
#endif
In the code below | 0 might have been added for clarity purposes but not required and not common style.
Code: Select all
#if defined(__AVR_ATmega162__)
UCSR0C = (1 << URSEL0) | 0;
#else
UCSR0C = 0;
#endif
Btw, what's your environment? I still get errors when merging your patches on macOS Sierra. Works on Linux passing --binary to patch. You should check your auto.crlf config if using the github mirror.
Cheers,
Fabio Utzig
Re: [PATCH] ATmega162 support
Thanks!
UBRR0H is indeed an 8bit register but the effective bits in that register are bits 0-3. Bit 7 should be 0 to select the UBRR0H register. Since config->sc_brr is 16 bits i thought it would be possible for bit 7 to be 1 causing a write to UCSR0C instead of UBRR0H.
Indeed the | 0 was added for clarity. It can be removed.
I'm currently using git under Windows 7. The patch was created against the svn trunk. Probably that caused some issue with line endings.
Marco
UBRR0H is indeed an 8bit register but the effective bits in that register are bits 0-3. Bit 7 should be 0 to select the UBRR0H register. Since config->sc_brr is 16 bits i thought it would be possible for bit 7 to be 1 causing a write to UCSR0C instead of UBRR0H.
Indeed the | 0 was added for clarity. It can be removed.
I'm currently using git under Windows 7. The patch was created against the svn trunk. Probably that caused some issue with line endings.
Marco
-
- Posts: 359
- Joined: Sat Jan 07, 2012 6:22 pm
- Location: Brazil
- Has thanked: 1 time
- Been thanked: 20 times
- Contact:
Re: [PATCH] ATmega162 support Topic is solved
Marco wrote:UBRR0H is indeed an 8bit register but the effective bits in that register are bits 0-3. Bit 7 should be 0 to select the UBRR0H register. Since config->sc_brr is 16 bits i thought it would be possible for bit 7 to be 1 causing a write to UCSR0C instead of UBRR0H.
Ah, nice! Just re-checked for the other supported MCUs and they don't use the 4 MSb, only ATmega162 has a register selector I think. Maybe the code could as well have the & 0xf for all models removing the #ifdef requirement.
Who is online
Users browsing this forum: No registered users and 2 guests