Hi,
I'm currently in the process of porting the Arduino platform to ATmega169P.
So far, I have
created variants/atmega169p/pins_arduino.h and
updated cores/arduino/wiring_analog.c (based on arduino 1.0.5).
I attached both files.
Then there are the following files in cores/arduino/ for which it seems (at first glance) that they don't need any update. But I will check them again, once I need any of the functionality or I find the time:
WInterrupts.c
Tone.cpp
HardwareSerial.cpp
wiring_private.c
I don't have a bootloader yet. But it's possible to use JTAG and the "Upload using programmer" menu item, for this I created the following entry in /etc/programmers.txt:
I also had to update the "desc" in the m169 section of /etc/avrdude/avrdude.conf:
part
id = "m169";
desc = "ATMEGA169P";
I.e. I added a "P" to the desc. This is because - as far as I understand - the Arduino IDE uses the "xxx.build.mcu" entry from the boards.txt for both compiling and uploading. In case of the ATmega169P it should use "atmega169p" for compiling and "m169" or "atmega169" (without "p") for uploading. But I could not find a way to configure this in the boards.txt. Hence I changed the avrdude.conf as described above. Better ideas are appreciated.
In addition I have created a board.txt section for the HR20 (a radiator thermostat) which uses an ATmega169P:
I've compiled, uploaded and run a first sketch (blink of course). Did I forget something? Is anyone else interested in this? I'd like to have optiboot on the ATmega169P at one point in the future, but that's a low priority task for me.
Yes, running at 1 MHz probably for powersaving. You can find a nice analysis of the board in use in the OpenHR20 code repository. Unfortunately, it's only available in German.
No, OpenHR20 is not based on Arduino. My aim is to reproduce a subset of what is implemented in OpenHR20, but using the Arduino platform, so that I can re-use Arduino libraries.
LED_BUILTIN is supposed to be a macro rather than a typed constant. Do not #define it if the board does not have an on-board LED. An example for the Uno...
Ok, thanks, I was a bit uncertain, if some parts of the platform code use LED_BUILTIN, so I just commented it out for a start. I've now completely removed it.
For getting ATmega169P into the distro, I should probably fork Arduino on github and make a pull request once I know it's working reliably. I still get some compiler warning from a few of the standard files, so there's work to do still.
Yepp, the board is battery powered. Brown out seems to be a wise choice (it's also set by the manufacturer of the HR20 in the original firmware and OpenHR20).
Yes, I already created a first version of an ATmega169PLCD lib. Playing with it, as we speak.
Thanks for the hint regarding 1.5 and the dev list. I've now switched to the latest 1.5 nightly build. Some things are done differently in 1.5, so I had to change my programmers.txt:
To whom it may concern, I've created a fork on github, after hunting down three compiler warnings. One warning remains. I've started a topic on the developer mailing list, but I assume it takes some time to show up there.
federvieh:
To whom it may concern, I've created a fork on github, after hunting down three compiler warnings. One warning remains. I've started a topic on the developer mailing list, but I assume it takes some time to show up there.
The most effective way to get changes added to the Arduino software is to...
Create an issue here... Issues · arduino/Arduino · GitHub
I suggest keeping the description very short. Something like "fixed warnings in whatever".
Create a "pull request" referencing the issue you created. I don't know how to do that.
It depends on what you want the core to do with timer 2. For supported processors, all timers except 0 are configured for Phase Correct PWM. Essentially they are initialized to support analogWrite. If you want analogWrite to work on the OC2A pin (B7, physical pin 17) then the warning will have to be corrected.
I suspect there are a few other spots that will also need attention for OC2A to support PWM.
This was the warning we were discussing earlier, so that was already fixed:
In my first post I mentioned, that I didn't look at Tone.cpp until later, but ok, why not fix it now. Here you go:
Unfortunately, I can test neither tone nor PWM, since I lack a real development board for the ATmega169P. (Edit: Maybe I should mention that it does compile the tone examples without errors or warnings.)