go_away

Author Topic: ATmega8 Fuses and UART  (Read 15298 times)

0 Members and 1 Guest are viewing this topic.

Offline airman00Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,653
  • Helpful? 21
  • narobo.com
ATmega8 Fuses and UART
« 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 :

However in AVRstudio when I need to select fuses I get totally different choice for fuses.



The ATmega8 should be running at 8mhz internal oscillator.

Can someone please guide me to a solution to this fuses issue.

Thanks,
Eric
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

Offline pomprocker

  • Supreme Robot
  • *****
  • Posts: 1,430
  • Helpful? 16
  • Sorry miss, I was giving myself an oil-job.
Re: ATmega8 Fuses and UART
« Reply #1 on: September 22, 2008, 10:55:36 PM »
Every atmega has different fuses!!

Offline airman00Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,653
  • Helpful? 21
  • narobo.com
Re: ATmega8 Fuses and UART
« Reply #2 on: September 23, 2008, 07:25:36 AM »
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?
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

Offline pomprocker

  • Supreme Robot
  • *****
  • Posts: 1,430
  • Helpful? 16
  • Sorry miss, I was giving myself an oil-job.
Re: ATmega8 Fuses and UART
« Reply #3 on: September 23, 2008, 10:04:06 AM »
atmega8 doesnt have a ckdiv8 fuse

does baud really have anything to do with clock speed?

Offline airman00Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,653
  • Helpful? 21
  • narobo.com
Re: ATmega8 Fuses and UART
« Reply #4 on: September 23, 2008, 10:29:45 AM »
atmega8 doesnt have a ckdiv8 fuse

does baud really have anything to do with clock speed?


yes it effects error rate
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,121
  • Helpful? 108
Re: ATmega8 Fuses and UART
« Reply #5 on: September 23, 2008, 12:36:38 PM »
The fuses set in your screen shot are correct.

SUT_CKSEL is set to use the internal clock at 8MHz.
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline pomprocker

  • Supreme Robot
  • *****
  • Posts: 1,430
  • Helpful? 16
  • Sorry miss, I was giving myself an oil-job.
Re: ATmega8 Fuses and UART
« Reply #6 on: September 23, 2008, 01:11:50 PM »
Can you even do UART at 1MHz on the atmega8?

Offline TrickyNekro

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,207
  • Helpful? 15
  • 1.6L Peugeot 307 tuner
Re: ATmega8 Fuses and UART
« Reply #7 on: September 23, 2008, 01:26:21 PM »
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!!!
For whom the interrupts toll...


P.S. I've been inactive for almost a year... Don't give promises but I'll try to complete my tutorials. I'll let you know when..

Cheers!

Offline airman00Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,653
  • Helpful? 21
  • narobo.com
Re: ATmega8 Fuses and UART
« Reply #8 on: September 23, 2008, 04:38:33 PM »
thx for the replies guys


Would I have to check off any other fuses for it to work?
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

Offline pomprocker

  • Supreme Robot
  • *****
  • Posts: 1,430
  • Helpful? 16
  • Sorry miss, I was giving myself an oil-job.
Re: ATmega8 Fuses and UART
« Reply #9 on: September 23, 2008, 04:53:47 PM »
no you dont really even need brown out.

also you may not need the size of your boot sector that big

Offline airman00Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,653
  • Helpful? 21
  • narobo.com
Re: ATmega8 Fuses and UART
« Reply #10 on: September 23, 2008, 04:57:27 PM »
I assume I should check off RSTDISBL  ?
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

Offline pomprocker

  • Supreme Robot
  • *****
  • Posts: 1,430
  • Helpful? 16
  • Sorry miss, I was giving myself an oil-job.
Re: ATmega8 Fuses and UART
« Reply #11 on: September 23, 2008, 08:08:28 PM »
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.
« Last Edit: September 23, 2008, 08:09:04 PM by pomprocker »

Offline airman00Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,653
  • Helpful? 21
  • narobo.com
Re: ATmega8 Fuses and UART
« Reply #12 on: September 23, 2008, 08:15:04 PM »
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
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

Offline pomprocker

  • Supreme Robot
  • *****
  • Posts: 1,430
  • Helpful? 16
  • Sorry miss, I was giving myself an oil-job.
Re: ATmega8 Fuses and UART
« Reply #13 on: September 23, 2008, 08:17:51 PM »
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.

Offline airman00Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,653
  • Helpful? 21
  • narobo.com
Re: ATmega8 Fuses and UART
« Reply #14 on: September 24, 2008, 08:04:42 AM »
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?

Code: [Select]
// 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
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

Offline pomprocker

  • Supreme Robot
  • *****
  • Posts: 1,430
  • Helpful? 16
  • Sorry miss, I was giving myself an oil-job.
Re: ATmega8 Fuses and UART
« Reply #15 on: September 24, 2008, 09:46:09 AM »
I wonder how then I had UART working on my atmega8 for many months before upgrading to the mega168....

Offline airman00Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,653
  • Helpful? 21
  • narobo.com
Re: ATmega8 Fuses and UART
« Reply #16 on: September 24, 2008, 10:39:33 AM »
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?
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,121
  • Helpful? 108
Re: ATmega8 Fuses and UART
« Reply #17 on: September 24, 2008, 12:15:28 PM »
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.
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline airman00Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,653
  • Helpful? 21
  • narobo.com
Re: ATmega8 Fuses and UART
« Reply #18 on: September 24, 2008, 01:11:54 PM »
OK thanks for the input Webbot , I guess its a baud issue. I'll focus on that .
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,632
  • Helpful? 169
    • Society of Robots
Re: ATmega8 Fuses and UART
« Reply #19 on: October 08, 2008, 05:26:59 AM »
Was this ever resolved?

Offline airman00Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,653
  • Helpful? 21
  • narobo.com
Re: ATmega8 Fuses and UART
« Reply #20 on: October 08, 2008, 07:05:28 AM »
Was this ever resolved?

nope . I just got some 168's in the mail , so I'm gonna try with those.
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

Offline Mikael

  • Beginner
  • *
  • Posts: 1
  • Helpful? 0
Re: ATmega8 Fuses and UART
« Reply #21 on: May 21, 2009, 08:32:53 AM »
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


Offline Pierre

  • Jr. Member
  • **
  • Posts: 47
  • Helpful? 0
Re: ATmega8 Fuses and UART
« Reply #22 on: January 03, 2010, 04:15:11 PM »
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
« Last Edit: January 03, 2010, 09:42:34 PM by Pierre »

 


Get Your Ad Here