Society of Robots - Robot Forum
Electronics => Electronics => Topic started by: airman00 on September 22, 2008, 08:19:04 PM
-
Hello,
I am trying to follow through this tutorial ( intended for the ATmega168)http://www.societyofrobots.com/microcontroller_uart_50_robot.shtml
My issue lies in the fuse settings. I am supposed to set the following fuses : (http://www.societyofrobots.com/images/microcontroller_uart_clock_settings.png)
However in AVRstudio when I need to select fuses I get totally different choice for fuses.
(http://i273.photobucket.com/albums/jj202/erobot/Misc%20Documentation/fuses.jpg)
The ATmega8 should be running at 8mhz internal oscillator.
Can someone please guide me to a solution to this fuses issue.
Thanks,
Eric
-
Every atmega has different fuses!!
-
Every atmega has different fuses!!
Yea I know that , I mean what would I do with the CKDIV8 fuse , whats the same type of fuse on the ATMega8
Would I have to run the ATmega8 at a lower speed and therefore use a lower baud?
-
atmega8 doesnt have a ckdiv8 fuse
does baud really have anything to do with clock speed?
-
atmega8 doesnt have a ckdiv8 fuse
does baud really have anything to do with clock speed?
yes it effects error rate
(http://www.societyofrobots.com/images/microcontroller_uart_error.gif)
-
The fuses set in your screen shot are correct.
SUT_CKSEL is set to use the internal clock at 8MHz.
-
Can you even do UART at 1MHz on the atmega8?
-
Can you even do UART at 1MHz on the atmega8?
That depends on the device you are talking at man... and it's baudrate...
Suppose you have a device with slow baud rate like an el chipo transmitter...
When 1MHz is good...
Usually 10MHz will be too good for any hobby associated comm, If you therefore like to place a bigger crystal like a 20MHz one...
You can get better resolution in many things like PWM, more steps for servos if they handle (which most do however)...
That kinda stuff...
So yep you can even overcloack a micro but in comm expect a greater error...
That's from me...
And airman yup that's the right config!!! cheers!!!
-
thx for the replies guys
(http://i273.photobucket.com/albums/jj202/erobot/Misc%20Documentation/fuses.jpg)
Would I have to check off any other fuses for it to work?
-
no you dont really even need brown out.
also you may not need the size of your boot sector that big
-
I assume I should check off RSTDISBL ?
-
Please note that your AVR needs an external RESET source for the ISP interface to work.
When you program the RSTDISBL fuse you disable the ISP interface at the same time.
To reenable the ISP interface you need to use High Voltage Programming to unprogram the RSTDISBL fuse.
To do this you need an STK500. The procedure and connections for High Voltage Programming is located in the AVR Studio Helpfiles:
AVR Tools on-line help --> STK 500 User's Guide --> Hardware description --> High Voltage Programming.
-
oh ok pomprocker
I have it flash an LED OK @ 8mhz but the UART just doesnt work!
I followed the tutorial perfectly but I just cant get the ATmega8 to transmit or receive over UART ! Everything is set up exactly how Admin said to do it in the tutorial
Did anyone have the same problems with their UART on the ATmega8?
Thanks,
Eric
-
oh ok pomprocker
I have it flash an LED OK @ 8mhz but the UART just doesnt work!
I followed the tutorial perfectly but I just cant get the ATmega8 to transmit or receive over UART ! Everything is set up exactly how Admin said to do it in the tutorial
Did anyone have the same problems with their UART on the ATmega8?
Thanks,
Eric
its most likely the baud rate.
check global.h, makefile, and the baud at which you initiate in your main C file.
make sure you set your BlueSMiRF to the correct baud, and make sure you set the port in windows to the right baud.
-
I think uart.c is the issue
There is no compatibility for the ATmega8 , only ATmega 168.
Anyone know how to make my own compatibility script for the ATmega8?
// compatibility with most newer processors
#ifdef UCSRB
#define UCR UCSRB
#endif
// compatibility with old Mega processors
#if defined(UBRR) && !defined(UBRRL)
#define UBRRL UBRR
#endif
// compatibility with megaXX8 processors
#if defined(__AVR_ATmega88__) || \
defined(__AVR_ATmega168__) || \
defined(__AVR_ATmega644__)
#define UDR UDR0
#define UCR UCSR0B
#define RXCIE RXCIE0
#define TXCIE TXCIE0
#define RXC RXC0
#define TXC TXC0
#define RXEN RXEN0
#define TXEN TXEN0
#define UBRRL UBRR0L
#define UBRRH UBRR0H
#define SIG_UART_TRANS SIG_USART_TRANS
#define SIG_UART_RECV SIG_USART_RECV
#define SIG_UART_DATA SIG_USART_DATA
#endif
// compatibility with mega169 processors
#if defined(__AVR_ATmega169__)
#define SIG_UART_TRANS SIG_USART_TRANS
#define SIG_UART_RECV SIG_USART_RECV
#define SIG_UART_DATA SIG_USART_DATA
#endif
// compatibility with dual-uart processors
// (if you need to use both uarts, please use the uart2 library)
#if defined(__AVR_ATmega161__)
#define UDR UDR0
#define UCR UCSR0B
#define UBRRL UBRR0
#define SIG_UART_TRANS SIG_UART0_TRANS
#define SIG_UART_RECV SIG_UART0_RECV
#define SIG_UART_DATA SIG_UART0_DATA
#endif
#if defined(__AVR_ATmega128__)
#ifdef UART_USE_UART1
#define UDR UDR1
#define UCR UCSR1B
#define UBRRL UBRR1L
#define UBRRH UBRR1H
#define SIG_UART_TRANS SIG_UART1_TRANS
#define SIG_UART_RECV SIG_UART1_RECV
#define SIG_UART_DATA SIG_UART1_DATA
#else
#define UDR UDR0
#define UCR UCSR0B
#define UBRRL UBRR0L
#define UBRRH UBRR0H
#define SIG_UART_TRANS SIG_UART0_TRANS
#define SIG_UART_RECV SIG_UART0_RECV
#define SIG_UART_DATA SIG_UART0_DATA
#endif
#endif
-
I wonder how then I had UART working on my atmega8 for many months before upgrading to the mega168....
-
I wonder how then I had UART working on my atmega8 for many months before upgrading to the mega168....
I guess I was incorrect
hmmmm , what fuses did you set on the ATmega8? Any other things you can provide me that worked for you?
-
Did anyone have the same problems with their UART on the ATmega8?
I just changed the fuse to use the 8MHz internal clock (like you have done).
I included uart.h
and then in my initialisation routine I initialised the UART as follows
uartInit(); // initialize the UART (serial port)
uartSetBaudRate(19200);// set the baud rate of the UART for our debug/reporting output
and then I wrote to it using rprintfChar and rprintfStr.
All worked ok.
-
OK thanks for the input Webbot , I guess its a baud issue. I'll focus on that .
-
Was this ever resolved?
-
Was this ever resolved?
nope . I just got some 168's in the mail , so I'm gonna try with those.
-
oh ok pomprocker
I have it flash an LED OK @ 8mhz but the UART just doesnt work!
I followed the tutorial perfectly but I just cant get the ATmega8 to transmit or receive over UART ! Everything is set up exactly how Admin said to do it in the tutorial
Did anyone have the same problems with their UART on the ATmega8?
Thanks,
Eric
I followed the tutorial perfectly but I just cant get the ATmega8 to transmit or receive over UART ! Everything is set up exactly how Admin said to do it in the tutorial
I don´t know if it would help but here´s a tip (I had a similar problem like you):
Did you try to setup the baudrate like this example?:
#define BAUDRATE 57600
#define UBRRVAL ((F_CPU/(BAUDRATE*16UL))-1)
UBRRL=(uint8_t)UBRRVAL; //low byte
UBRRH=(uint8_t)(UBRRVAL>>8); //high byte
In that case please instead take help of the clockspeeds/Baudrates/Error Table in the datasheet and do like this example:
#define BAUDRATE 57600
#define UBRRVAL ((F_CPU/(BAUDRATE*16UL))-1)
UBRRL=3; //low byte
UBRRH=(3/256); //high byte, downshift 8 times, divide by 2^8
It helped me.
/Mikael
-
I am following through the UART with the ATmega8 on an other post. It really seems that Airman00 would be wright about the ATmega8 with UART using the photoresistor on the $50 robot.
http://www.societyofrobots.com/robotforum/index.php?topic=9944.0 (http://www.societyofrobots.com/robotforum/index.php?topic=9944.0)