thomasonw / ATmegaxxM1-C1

Arduino IDE support files for CAN enabled Atmel AVR chips: ATmega64M1, ATmega32M1, ...
GNU Lesser General Public License v2.1
30 stars 18 forks source link

ATmegaxxM1-C1: Arduino Core for ATmegaxxM1/C1 CPUs

Atmel offers a line of CPUs compatible with the CPUs commonly used in Arduino boards. Some have additional features, such as the ATmega32M1 which includes built in CAN (Control Area Network) hardware.

ATmegaxxM1-C1 is an extension to the Arduino IDE environment enabling several of these CAN containing CPUs.

Future:

Enhancements

The ATmegaxxM1/C1 CPUs have some additional features which have allowed for the API to be extended. Additions over the 'standard' Arduino are:

Summary of new Keywords: GAIN5, GAIN10, GAIN20, GAIN40, DAC_PORT

Notes

There are some small hardware differences between the ATmegaxxM1/C1 CPUs and the ATmega328 (used in the Uno). Mostly this will not be an issue, but one should be aware of them, including:

Special note concerning PSC ports at power-on. The ATmegaxxM1 CPUs contains a high speed PSC (Power Stage Controller) subsystem. Targeted for high-speed PWM, most commonly in a push-pull configuration. There are three channels for a total of 6 ports. A special feature of the ATmegaxxM1 CPU is the ability to hold those ports at a pre-determined value at initial power-on and/or reset, to prevent unintended actions until such time as the startup code is able to execute.

Fuse PSCRB has been set by default causing all 6 PSC ports to be held LOW until such time as when they are used or reconfigured to a different purpose. Care should be taken in hardware design NOT to tie these pins to a value other then GND. If there is a need to do so, make sure to use a current limiting resistor. The ports affected are: PB0, PB1, PB6, PB7, PC0, PD0 (Arduino ports: D5, D6, A7, A8, D12 & D11)

Though the ATmegaxxC1 does not contain a PSC subsystem, fuse PSCRB is still set - refer to Atmel users document to confirm the behavior of the ATmegaxxC1 CPU with this fuse set.

Port Mapping

alt text

Installation

This is designed for Arduino 1.6.7+

Option 1) Arduino Board Package Manager:

  1. Start Arduino
  2. Open menu File/Preferences
  3. Click the 'window box' to the right of the 'Additional Boards manager URLs:' entry window.
    • This will allow you to add more than one entry
  4. Copy the following URL into the box.
  5. Press OK button to close the data entry window
  6. Press OK button to close the Preferences menu.
  7. Open the Tools/Boards menu and select Boards Manager
  8. Scroll down and click on the 'ATmegaxxM1-C1 by thomasonw version x.x.x' entry
  9. press the Install button

Option 2) Manual Install:

  1. Copy down the ZIP file to your local computer.
  2. Open the Zip File, and copy the entire content to your users local hardware subdirectory.
    • in Windows, this is: "Libraries/Documents/Arduno/Hardware"
  3. Restart the Arduino IDE

After either is used to install the support files, you can select the new CPUs from the tools/boards menu.

Support for IDE versions released prior to 1.6.7 may be found at: http://smartmppt.blogspot.com/search/label/xxM1-IDE

Versions

v1.0.3 --> Original porting using rather old CORE files. Does NOT implement analogWrite() for DAC. analogRead() of differential ports are not corrected for +/- values (raw ADC count is returned)

v1.0.4 --> Reported to new CORE files from Arduino 1.6.8. Added DAC support. analogRead() of differential ports are not corrected for +/- values (raw ADC count is returned)

v1.0.5 --> pinMode(DAC_PORT,xxx) disconnects DAC from port (is connected by analogWrite(DAC_PORT, xx). analogRead() differential ports corrected for +/- values.

v1.0.6 --> Enabled TONE capability (note, interfers with PWM as it uses the same timer..), corrected SerialWrite IRQ race bug.

v1.0.7 --> Initialize VREF at 1st usage of DAC, restructured to Arduino menu selections, added menu options for PWM initial state (Thank you Geraldjust).

V1.0.8 --> Added support for dedicated 64m1 with Arduino footprint https://www.tindie.com/products/15615/ (By GeraldJust)

V1.0.9 --> Added support for ATmega16M1

CORE files

A major effort for this porting effort is the modification of the CORE include files used by Arduino. There is a separate GitHib repository which contains the edits I have made to enable the ATmegaM1/C1 CPUs: https://github.com/thomasonw/Arduino---CORE-files-for-ATmegaM1-C1-port/tree/master/hardware/arduino/avr/cores/arduino

It is forked from the master Arduino files to allow updating from them as well.