I'm developing a board with an ATmega32M1 (http://www.mouser.com/ds/2/36/doc8209-242488.pdf) for automotive applications. I would like to use the familiar Arduino IDE to program it, but have had to modify some files to work with the ATmega32M1. Right now I can compile the simple "Blink" sketch without errors and upload it to the ATmega32M1. Although the code uploads without errors, the chip does not seem to be responding or "blinking" any of the pins tried.
Chip: ATmega32M1
Programmer: Arduino as ISP
OS: Windows XP Home
Arduino IDE: 1.0.4
Files modified:
- Board.txt------Added "Atmega32M1" section.
- Wiring_private.h-----Added additional interrupts
- Wrote a pins_arduino.h-----Tried to account for and accommodate all pins to be used. this file was then placed in its own folder under "hardware/arduino/variants"
Board.txt addition: (bootloader is not being used)
atmega32m1.name=ATmega32M1 (arduino)
atmega32m1.upload.protocol=arduino
atmega32m1.upload.maximum_size=30720
atmega32m1.upload.speed=19200
atmega32m1.bootloader.low_fuses=0xE2
atmega32m1.bootloader.high_fuses=0xD9
atmega32m1.bootloader.extended_fuses=0xD9
atmega32m1.bootloader.path=atmega
atmega32m1.bootloader.file=ATmegaBOOT_168_atmega328.hex
atmega32m1.bootloader.unlock_bits=0x3F
atmega32m1.bootloader.lock_bits=0x0F
atmega32m1.build.mcu=atmega32m1
atmega32m1.build.f_cpu=8000000L
atmega32m1.build.core=arduino
atmega32m1.build.variant=standard
Wiring_private.h (hardware/arduino/cores/arduino/wiring_private.h) now looks like this:
#ifndef WiringPrivate_h
#define WiringPrivate_h
#include <avr/io.h>
#include <avr/interrupt.h>
#include <stdio.h>
#include <stdarg.h>
#include "Arduino.h"
#ifdef __cplusplus
extern "C"{
#endif
#ifndef cbi
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#endif
#ifndef sbi
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
#endif
#define EXTERNAL_INT_0 0
#define EXTERNAL_INT_1 1
#define EXTERNAL_INT_2 2
#define EXTERNAL_INT_3 3
#define EXTERNAL_INT_4 4
#define EXTERNAL_INT_5 5
#define EXTERNAL_INT_6 6
#define EXTERNAL_INT_7 7
#define EXTERNAL_INT_8 8
#define EXTERNAL_INT_9 9
#define EXTERNAL_INT_10 10
#define EXTERNAL_INT_11 11
#define EXTERNAL_INT_12 12
#define EXTERNAL_INT_13 13
#define EXTERNAL_INT_14 14
#define EXTERNAL_INT_15 15
#define EXTERNAL_INT_16 16
#define EXTERNAL_INT_17 17
#define EXTERNAL_INT_18 18
#define EXTERNAL_INT_19 19
#define EXTERNAL_INT_20 20
#define EXTERNAL_INT_21 21
#define EXTERNAL_INT_22 22
#define EXTERNAL_INT_23 23
#if defined(__AVR_ATMEGA32M1__)
#define EXTERNAL_NUM_INTERRUPTS 24
#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
#define EXTERNAL_NUM_INTERRUPTS 8
#elif defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega644P__)
#define EXTERNAL_NUM_INTERRUPTS 3
#elif defined(__AVR_ATmega32U4__)
#define EXTERNAL_NUM_INTERRUPTS 4
#else
#define EXTERNAL_NUM_INTERRUPTS 2
#endif
typedef void (*voidFuncPtr)(void);
#ifdef __cplusplus
} // extern "C"
#endif
#endif
Notes:
- Power is definitely getting to the board. On board power LED is lit and voltages checked with multimeter.
- All lines have been checked with multimeter.
- Arduino IDE shows good upload.
a. Avrdude knows that it is programming an ATmega32M1 (from verbose output):
AVR Part : ATMEGA32M1
Chip Erase delay : 9000 us
PAGEL : PD7
BS2 : PE2
RESET disposition : dedicated
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
Memory Detail :
b. ATmega32M1's signature is properly recognized (from verbose output):
avrdude: AVR device initialized and ready to accept instructions
Reading | avrdude: Send: u [75] [20]
avrdude: Recv: . [14] . [1e] . [95] . [84] . [10]
################################################## | 100% 0.03s
avrdude: Device signature = 0x1e9584
c. Appropriate thank you is given at the end (from verbose output):
avrdude: Recv: . [14]
avrdude: Recv: . [10]
### | 100% 1.38s
avrdude: 1074 bytes of flash written
avrdude: Send: Q [51] [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]
avrdude done. Thank you.
- Since no bootloader has been used yet, no crystal has been added to the board yet and it is running off the internal resonator.
- Board is a custom board of my own design.
- Right now I'm just trying a simple "Blink" sketch, but if I add "Serial.begin(9600);" the compiler throws an error:
error: 'Serial' was not declared in this scope
Although it is not my intention to use Serial yet, I wanted to add that note as it might be a clue!
Thank you in advance for your time with this. I look forward to your thoughts and suggestions.
(Due to the length of this post I'm splitting it up and adding the coding in the following post.)