Pages: [1] 2 3 ... 6   Go Down
Author Topic: Ok, on to Atmega32  (Read 21422 times)
0 Members and 1 Guest are viewing this topic.
Hurley, NY
Offline Offline
Jr. Member
**
Karma: 0
Posts: 86
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok, I feel like I really know the Atmega168 now, so now I'm just pushing dev like the kind of project manager we have all hated at some point during our careers. Shoot me if this is going too far.  I have an Atmega32. This thing rocks, hardware-wise.  If Arduino can go  here, at least in the software world, there is no end to what it can do. I see that the Arduino Atmega168 bootloader supports it.  The question is:  what are we going to need to add to the Arduino IDE to support it?  I want an item in the dropdown.  I just tried burning the Atmega168-compatible software to an Atmega32 in an Olimex AVR-P40-USB board and, well, nothing much happened when I then tried to upload an Arduino sketch.  Perhaps someone can shine a light on the differences between an Atmega168 and an Atmega32 and how that applies to the dropdown in the Arduino IDE.  
« Last Edit: October 21, 2006, 10:19:18 pm by bigfun » Logged

Forum Administrator
Cambridge, MA
Offline Offline
Faraday Member
*****
Karma: 12
Posts: 3538
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

To start experimenting, you can change the "build.mcu" setting in your preference file.  This is the setting that the Tools | Microcontroller (MCU) menu sets.   Changing it to "atmega32" will tell the Arduino environment to compile your sketch for the atmega32, which means your .hex file will have the right opcodes at least (since I think the ATmega32 and the ATmega8 have slightly different instructions).  You'll probably get a bunch of errors in the Arduino core, though, since the hardware - and thus the code - for the two chips are different.  Take a look at ARDUINO/lib/targets/arduino/wiring.c and pins_arduino.c.  Sadly, editing this file to work with the ATmega32 probably requires reading the ATmega32 datasheet (http://www.atmel.com/dyn/resources/prod_documents/doc2503.pdf), which is not the most fun way to spend a Sunday.  Supporting different chips and different boards is definitely a long-term goal of the Arduino project, though, so any headway you make would be greatly appreciated.
« Last Edit: October 22, 2006, 05:02:30 am by mellis » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 36
blablablabla
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

even easier for beginning; try it without Arduino IDE, with the command line way-of-life. http://www.arduino.cc/playground/Learning/CommandLine. just edit the mcu type in makefile and adjust both files pins_arduino.c and wiring.c. probably, other files? anyway, i would be very interested in getting different atmel chips to work. would expand arduino community enormously.
Logged

Forum Administrator
Cambridge, MA
Offline Offline
Faraday Member
*****
Karma: 12
Posts: 3538
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Just to reiterate, since you were asking questions on another thread.  You don't need to worry about the IDE (at least, not at first).  You don't actually need a menu item for the chip you want to use, you can just edit your preferences file and set "build.mcu" to "atmega32".  What you do need to do is edit the wiring.c and pins_arduino.c files in the ARDUINO/lib/targets/arduino directory.  It shouldn't require too many changes, just changing some names of hardware registers and bits for doing particular hardware configuration things.  It will probably mean spending a lot of time reading the ATmega32 datasheet, though.  Once you get those files working, you can go in and add an ATmega32 menu item if you want.
Logged

berlin
Offline Offline
Sr. Member
****
Karma: 0
Posts: 295
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hi,

what's the main advantage of the atmega32 over the 168 ?

i found an avr overview here: http://www.sander-electronic.de/datasheet/AVR.pdf

am i right that the difference is something like from the atmega8 to the atmega168?
i mean double sized memory + a few more I/O ?

not that i could not find a use for both of it,
i just wonder if there was another killer feature or possibility i didn't find being ignorant, like for USB-connectivity or energy-saving or something.

//kuk
Logged

Hurley, NY
Offline Offline
Jr. Member
**
Karma: 0
Posts: 86
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Actually, a lot more i/o.  and double the flash of the atmega168 and quadruple the atmega8.   Anything with half the storage of my old commodore 64 should be able to do a lot of fun stuff.  Still, at this point in Moore's Law I don't know why Atmel can't make a processor with a megabyte of storage that fits in the Atmega8 footprint.  Imagine what that could do!
Logged

berlin
Offline Offline
Sr. Member
****
Karma: 0
Posts: 295
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i see,

but how many more i/o is that? digital or analog... the pdf i found is not clear to me.
Logged

Chicago IL
Offline Offline
Newbie
*
Karma: 0
Posts: 36
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

according to AvrFreaks there is 32 I/O pins, 4 are PWM and 8 are analog.
Logged

0
Offline Offline
Newbie
*
Karma: 1
Posts: 9
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I would like to use an Atmega16 with the Arduino software.  I have seen in the previous posts, there is a way to do this. But as the last post is from december 2006 I want to ask if maybe someone has already resolved this problem.
I want to switch from Bascom AVR (which is a programing language for Atmels in Basic) to an open source programme like Arduino or Wiring, but as far I see, there are only some types of Atmels supported at the moment.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 1
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi, I have also a spare ATmega16 which I'd like to use for Arduino. Some suggestions? So now there are two requests  for ATmega16 support 8-)
« Last Edit: September 29, 2007, 03:32:33 am by qratman » Logged

Brisbane, Australia
Offline Offline
God Member
*****
Karma: 1
Posts: 593
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

It would be nice if Arduino handled all AVR chips.

I'd figure out how to do it but I only have a 168.
Feel free to send me chips. smiley-wink

If the Arduino supported multiple chips then we could pick the right chip for the job, write the code and just hit the upload button.
Hell it would automatically make programs work on different chips.
Logged

0
Offline Offline
Newbie
*
Karma: 1
Posts: 9
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have taken a look to the files that mellis mentioned in one of the previous posts. I think, it will be not too complicated to make some Atmega16 or 32 files. I like the Atmega16 because it is cheap and have more I/O pins. As a first step, we could try to create the necessary files for Atmega16 and 32. So more experienced users would be able to upload their .hex files with an ISP programmer and AVRDude on homemade Atmel/Arduino boards.
Logged

0
Offline Offline
Newbie
*
Karma: 1
Posts: 9
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I modified now the pins_arduino.c file and changed the build command in the preferences.
The compiling works fine without error message. As I have problems with upload (I have a STK200 parallel programmer), I use the .hex file that will be generated in the applet folder and upload it separately with AVRDude. At the end, writing is successful, but no reaction on my atmel16....

What can be the problem?
I didn't touch so far the wiring.c file because  I hope that maybe the ATmega8 and 16 have the same parameters. No idea....

Although i get no error message with compiling I don't know, if the changes i made, are ok. Especially I don't know if #elseif is correct syntax at all.
I attach you the code of the file. I hope someone can help me to figure out what is wrong. Thanks!

#include <avr/io.h>
#include "wiring_private.h"
#include "pins_arduino.h"

#define PA 1
#define PB 2
#define PC 3
#define PD 4

// these arrays map port names (e.g. port B) to the
// appropriate addresses for various functions (e.g. reading
// and writing)
const uint8_t PROGMEM port_to_mode_PGM[] = {
      NOT_A_PORT,
#if defined(__AVR_ATmega16__)
        &DDRA,
#else
NOT_A_PORT,
#endif
      &DDRB,
      &DDRC,
      &DDRD,
};

const uint8_t PROGMEM port_to_output_PGM[] = {
      
      //NOT_A_PORT,
#if defined(__AVR_ATmega16__)
        &PORTA,

#else
NOT_A_PORT,
#endif
      &PORTB,
      &PORTC,
      &PORTD,
};

const uint8_t PROGMEM port_to_input_PGM[] = {
      
      //NOT_A_PORT,
#if defined(__AVR_ATmega16__)
        &PINA,
#else
NOT_A_PORT,
#endif
      &PINB,
      &PINC,
      &PIND,
};

const uint8_t PROGMEM digital_pin_to_port_PGM[] = {
      PD, /* 0 */
      PD,
      PD,
      PD,
      PD,
      PD,
      PD,
      PD,
      PB, /* 8 */
      PB,
      PB,
      PB,
      PB,
      PB,
      PC, /* 14 */
      PC,
      PC,
      PC,
      PC,
      PC,
#if defined(__AVR_ATmega16__)
        PC,
      PC,
        PA,         /* 22*/
      PA,
      PA,
      PA,
      PA,
      PA,
      PA,
      PA,
#endif

};

const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] = {
      _BV(0), /* 0, port D */
      _BV(1),
      _BV(2),
      _BV(3),
      _BV(4),
      _BV(5),
      _BV(6),
      _BV(7),
      _BV(0), /* 8, port B */
      _BV(1),
      _BV(2),
      _BV(3),
      _BV(4),
      _BV(5),
      _BV(0), /* 14, port C */
      _BV(1),
      _BV(2),
      _BV(3),
      _BV(4),
      _BV(5),
#if defined(__AVR_ATmega16__)
        _BV(6),
      _BV(7),
      _BV(0), /* 22, port A */
      _BV(1),
      _BV(2),
      _BV(3),
      _BV(4),
      _BV(5),
        _BV(6),
      _BV(7),
#endif


};

const uint8_t PROGMEM digital_pin_to_timer_PGM[] = {
      NOT_ON_TIMER, /* 0 - port D */
      NOT_ON_TIMER,
      NOT_ON_TIMER,
      // on the ATmega168, digital pin 3 has hardware pwm
#if defined(__AVR_ATmega168__)
      TIMER2B,
#else
      NOT_ON_TIMER,
#endif
      NOT_ON_TIMER,
      // on the ATmega168, digital pins 5 and 6 have hardware pwm
#if defined(__AVR_ATmega168__)
      TIMER0B,
      TIMER0A,
#elseif defined(__AVR_ATmega16__)
        TIMER1B,
        TIMER1A,
#else
      NOT_ON_TIMER,
      NOT_ON_TIMER,
#endif

#if defined(__AVR_ATmega16__)
        TIMER2,
#else

      NOT_ON_TIMER,
#endif
      NOT_ON_TIMER, /* 8 - port B */
#if defined(__AVR_ATmega16__)
        NOT_ON_TIMER,
      NOT_ON_TIMER,
#else
      TIMER1A,
      TIMER1B,
#endif

#if defined(__AVR_ATmega168__)
      TIMER2A,
#elseif defined(__AVR_ATmega16__)
        NOT_ON_TIMER,
#else  
      TIMER2,
      
#endif
      NOT_ON_TIMER,
      NOT_ON_TIMER,
      NOT_ON_TIMER,/* 14 - port C */
      NOT_ON_TIMER,
      NOT_ON_TIMER,
      NOT_ON_TIMER,
      NOT_ON_TIMER,
      NOT_ON_TIMER,
#if defined(__AVR_ATmega16__)
      NOT_ON_TIMER,
      NOT_ON_TIMER,
      NOT_ON_TIMER, /*22 port A */
      NOT_ON_TIMER,
      NOT_ON_TIMER,
      NOT_ON_TIMER,
      NOT_ON_TIMER,
      NOT_ON_TIMER,
       NOT_ON_TIMER,
      NOT_ON_TIMER,
#endif

};
« Last Edit: September 30, 2007, 01:17:33 pm by scubo » Logged

0
Offline Offline
Newbie
*
Karma: 1
Posts: 9
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

it works, it works!!! yupi....

There are still some problems with the ports addressing maybe and maybe we have to adjust the interupts for the timer and PWM... but in fact, I have some blinking LEDs here!

  ;D  Welcome Atmega16  ;D
Logged

Netherlands
Offline Offline
Sr. Member
****
Karma: 0
Posts: 414
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Congrats, well done!

Now, on to Atmega32?
Logged

Pages: [1] 2 3 ... 6   Go Up
Jump to: