Go Down

Topic: Arduino on ATmega169P (Read 4100 times) previous topic - next topic

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:
Code: [Select]
jtag1.name=USB JTAG
jtag1.communication=serial
jtag1.protocol=jtag1


I also had to update the "desc" in the m169 section of /etc/avrdude/avrdude.conf:
part
Code: [Select]
    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:
Code: [Select]
hr20.name=HR20 (not Open Hardware)
hr20.upload.protocol=arduino
hr20.upload.maximum_size=15872
hr20.upload.speed=115200
hr20.bootloader.low_fuses=0x62
hr20.bootloader.high_fuses=0x91
hr20.bootloader.extended_fuses=0xfd
hr20.bootloader.path=optiboot
hr20.bootloader.file=optiboot_atmega169.hex
hr20.bootloader.unlock_bits=0x3F
hr20.bootloader.lock_bits=0x0F
hr20.build.mcu=atmega169p
hr20.build.f_cpu=1000000L
hr20.build.core=arduino
hr20.build.variant=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.

BR,
  Frank

Coding Badly

Code: [Select]
hr20.build.f_cpu=1000000L

Running it at 1 MHz?


Running it at 1 MHz?

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.

Coding Badly


Is that how you are using it?  With the OpenHR20 code?


Is that how you are using it?  With the OpenHR20 code?


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.

Coding Badly

Code: [Select]
#if 0
static const uint8_t LED_BUILTIN = ??;
#endif


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...

https://github.com/arduino/Arduino/blob/master/hardware/arduino/variants/standard/pins_arduino.h#L47

Coding Badly


Brown Out Detection at 1.8 volts?

Coding Badly

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.


Will you be directly driving an LCD display?


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.


Brown Out Detection at 1.8 volts?

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).


Will you be directly driving an LCD display?

Yes, I already created a first version of an ATmega169PLCD lib. Playing with it, as we speak.

Coding Badly

#9
Mar 23, 2014, 12:46 am Last Edit: Mar 23, 2014, 08:26 pm by Coding Badly Reason: 1
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.


Excellent.  Thank you.

Quote
I still get some compiler warning from a few of the standard files, so there's work to do still.


Before knocking out a bunch of warnings I suggest switching to Arduino IDE 1.5.  I believe there has been some effort cleaning up the Arduino core.

You may be able to get help with the effort from the Developers List...
https://groups.google.com/a/arduino.cc/forum/?fromgroups#!forum/developers

Quote
Yes, I already created a first version of an ATmega169PLCD lib. Playing with it, as we speak.


Nice.

#10
Mar 23, 2014, 07:38 pm Last Edit: Mar 23, 2014, 08:26 pm by Coding Badly Reason: 1
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:
Code: [Select]

jtag1.name=USB JTAG
jtag1.communication=serial
jtag1.protocol=jtag1
jtag1.program.protocol=jtag1
jtag1.program.tool=avrdude
jtag1.program.extra_params=-P{serial.port}


and boards.txt:
Code: [Select]
hr20.name=HR20 (not Open Hardware)
hr20.upload.protocol=arduino
hr20.upload.maximum_size=15872
hr20.upload.speed=115200
hr20.upload.tool=avrdude
hr20.bootloader.low_fuses=0x62
hr20.bootloader.high_fuses=0x91
hr20.bootloader.extended_fuses=0xfd
hr20.bootloader.path=optiboot
hr20.bootloader.file=optiboot_atmega169.hex
hr20.bootloader.unlock_bits=0x3F
hr20.bootloader.lock_bits=0x0F
hr20.build.mcu=atmega169p
hr20.build.f_cpu=1000000L
hr20.build.core=arduino
hr20.build.variant=atmega169p


About the warnings in 1.5: I was so happy, that I didn't see any warnings anymore and then I discovered this thread discussing warnings in 1.5:
https://groups.google.com/a/arduino.cc/forum/?fromgroups#!topic/developers/5iaId6nPzqA

Long story short: I don't get any warnings, because warnings have been disabled in 1.5 even in verbose mode.  :smiley-eek-blue:

Now I'll go figure out how to enable them again.  XD

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.

Here's the code:
https://github.com/federvieh/Arduino/tree/ide-1.5.x

Coding Badly

Now I'll go figure out how to enable them again.  XD


You may be able to modify the[font=Courier New] platform.txt [/font]file to get what you want.

In any case, please add your 2ยข to that thread.

Coding Badly

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...

1. Create an issue here...
https://github.com/arduino/Arduino/issues?state=open
I suggest keeping the description very short.  Something like "fixed warnings in whatever".

2. Create a "pull request" referencing the issue you created.  I don't know how to do that.

#14
Mar 31, 2014, 06:32 pm Last Edit: Mar 31, 2014, 09:47 pm by Coding Badly Reason: 1
Well, the warnings were actually introduced by me, when adding the new processor. I'll create the pull request, once I figured out, how to proceed with the remaining warning. Maybe someone cares to help:
https://groups.google.com/a/arduino.cc/forum/m/?fromgroups#!topic/developers/-_pSWRcdme8

Go Up