[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-chat] 16Mhz or bust
From: |
Jesper Hansen |
Subject: |
Re: [avr-chat] 16Mhz or bust |
Date: |
Tue, 16 Aug 2005 09:38:56 +0200 |
Your UBBR value seems a bit off. The UBBRH and UBBRL registers are only
8-bit and you're loading a 16-bit value to it.
Also, for 2400 bps at 16 MHz, I get the value 415 (or 416 depending on
rounding), and not 432.
Here's the "classic" code that many people use :
#define F_CPU 16000000
.
.
#define UART_BAUD_RATE 115200
#define UART_BAUD_SELECT (uint16_t) ((uint32_t)F_CPU /
((uint32_t)UART_BAUD_RATE * 16L) - 1)
.
.
// set baud rate
UBBRH = UART_BAUD_SELECT >> 8;
UBBRL = UART_BAUD_SELECT & 0xff;
/Jesper
----- Original Message -----
From: "Mikey Sklar" <address@hidden>
To: <address@hidden>
Sent: Tuesday, August 16, 2005 2:37 AM
Subject: [avr-chat] 16Mhz or bust
I have been working with a ATmega32 through a stk500 under Mac OS/X.
I've had no trouble getting a little test serial program working through
the USART using the 1MHz default internal oscillator. However, I have
had no luck working at running the MCU at higher speeds than 1MHz.
I'm sure someone must have been successful using a AT part at greater
than 1MHz. What am I missing here?
Knobs I've been frobing with:
(note: these settings are known **BAD!**)
- Configuring the ATmega32 for 16MHz
* stk500 - external 16MHz crystal installed
* stk500 - XTAL1 unjumpered
* stk500 - OSCSEL - pins 2,3 jumperred
* Fuse high byte - CKOPT - 10011001 (uisp --wr_fuse_h=0x99)
* Fuse low byte - CKSEL - 11101111 (uisp --wr_fuse_l=0xEF)
* OSCCAL --wr_osc=16000000 (sets to 3686400, perhaps unsigned int issue)
* src code - 16MHz @ 2400bps UBRRL=432 or UBRRL=1B0
I've been using 'uisp' to set the fuse bits. I see at least one issue
with uisp not taking a clock value over 3.6864Mhz. I'm aware of the
usual mistakes:
- Internal oscillator maxes at 8MHz
- Fuse bits are inversed logic (0 is enabled)
_______________________________________________
AVR-chat mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/avr-chat