Hi everyone.
I follow AVRSTUDIO HELP to configure STK500 with ATMEGA168.
I flashed some simple programs working with LEDs, switches, timers to verify
the system.
I find troubles when i work with the UART.
I wrote a simple code that works fine with other micros like AT90S4433 or
ATMEGA163, but with ATMEGA168 the program echoes strange chars.
I am using cvavr
#include <mega168.h>
// Standard Input/Output functions
#include <stdio.h>
// Declare your global variables here
void main(void) {
// Declare your local variables here
char k;
// The other setting were deleted
/// PORTs, TIMERs, ADC, etc.
/// ....
// USART initialization
// Communication Parameters: 8 Data, 1 Stop, No Parity
// USART Receiver: On
// USART Transmitter: On
// USART0 Mode: Asynchronous
// USART Baud rate: 19200
UCSR0A=0x00;
UCSR0B=0x18;
UCSR0C=0x06;
UBRR0H=0x00;
UBRR0L=0x0B;
while (1) {
/* receive the character */
k = getchar();
/* and echo it back */
putchar(k);
};
}
What's wrong?
Ricardo Callejo
SURbyte SRL
San Martin 952
(9000) Comodoro Rivadavia
Chubut - Argentina
_____
De: AVR-Chat@yahoogroups.com [mailto:AVR-Chat@yahoogroups.com] En nombre de
Don AE5K
Enviado el: martes, 20 de febrero de 2007 11:38
Para: AVR-Chat@yahoogroups.com
Asunto: Re: [AVR-Chat] STK500/Mega168 basic setup
codsniper_net wrote, On 02/20/2007 02:17 AM:
> Hi all, we are a student group working on a project where we need the
> ATMega168 microprocessor and could use some help setting it up.
>
> We thought we had all the wireings and settings right from the start
> but it seems like we cant program the chip.
>
> Could anyone describe a step by step procedure for setting this up,
> all the way from the settings on the STK500 board to the AVR Studio
> settings.
>
> This would be of great help.
>
> Regards
> Roger, Mats & Kristian
>
> (Sry bout my bad english)
Hi Roger, Mats & Kristian...
Your "bad english" is better than most native speakers ;-)
Getting out my little "cheat sheet" I have drawn the jumper
configuration for the ATMega48/88/168 series...
1. Jumper "Prog Ctrl" to "Port D"
2. Jumper "Prog Data" to "Port B"
3. Single wire jumper from BSEL-2 (pin toward power connector side) to
PORT-C pin 3 labeled PC2
4. Shorting jumpers on P-JUMP (two of them) ... place so they are
parallel to the long edge of the STK500 board. (hard to describe!)
5. You should have shorting jumpers on VTARGET, RESET, XTAL1 and pins
1-2 of OSCSEL.
Use socket 3200A2 (green) for your chip.
In AVR Studio, besides setting the correct COM port, not much to set
other than make sure you have the correct chip ATmega168 selected.
Hopefully that will get you going. All this information is buried in
the help sections of the Studio program -- but it is rather disorganized
and confusing even to one who has used it many times.
The ATMega168 (and its smaller brothers) are very neat microcontrollers!
Best of luck,
Don
[Non-text portions of this message have been removed]