I have an old STK200 programmer with the ATMEGA16 40 Pin package that was given to me and I would like to use it in the Arduino environment. I have got it so that it will upload the boot loader by changing
- upload.using=parallel in the preference file
- Creating a new entry in boards :
I assume a lot of this is wrong ;)
- parallel.protocol=pony-stk200 in programmers.txt
I also had to fiddle with some preprocessors in the hardware/cores/arduino to get it to compile. Which I know some of what I put down was incorrect so I won't post it here right now. I would like to work and help someone to port this micro to the Arduino platform as this chip has more pin i/o and 2 extra analog i/o which I could use.
The chip information can be found on avrfreaks.
N.B please no responses about buying the right equipment, this is about having a challenge and providing the information back to the code base. :)
Does the bootloader work with the atmega16?
I use an atmega32 and it did not work, so I had to burn a modified version… And I guess that if you replace mega8 by mega16 in all source files and of course edit the arduino_pin.c the atmega16 can be used.
The mega32 works fine, but PORTC has some issues.
Yes the bootloader will write to the ATMEGA16. But since the programmer I have is parallel only I can only upload the code - I don’t have anything to check if it is working correctly :). What issues did you have with PORTC?
I just had a look at the Sanguino code for the 644 and while not the same chip it has almost the same pin i/o’s. I’m going to look as what is different between to 2 and see if I can adapt it to work. It would be nice if the Sanguino code was put in the standard code base
I will try this tonight and report back to see how I go.
PORTC does not work at all on my mega32. And I am sure that I ported the core correctly. Maybe my chip is broken, because all other ports work as they should.
I do not really understand what you mean by this:
But since the programmer I have is parallel only I can only upload the code - I don't have anything to check if it is working correctly
Did you upload a blink example to your mega16? Or are you not sure if your bootloader is running on the chip?
Don't forget to set the fuses and lock bits... And the Arduino bootloader is very big - I wonder if it fits into the (1024 words small) bootspace of the mega16?
Did not get a chance to check Sanguino code last night - will hopefully get to it tonight :)
Sorry wasn't clear on the parallel bit - I can upload to the ATMEGA16 various code examples in the Arduino Software with no problem over the stk200 via the computer parallel port. When I set the verbose in the preference file for uploading it all looks and verifies ok. I'm just not sure if it is working though as I haven't attached any outputs (i.e LEDs) yet to the ATMEGA16 because I know the pins don't match, and I'm being cautious... :)
To be honest I don't understand the fuses and lock bits correctly. I know I removed the extended fuse preference from boards.txt to make it work. It was a guess and I really didn't know what I was doing.
I noticed in the C preprocessing there is stuff for __AVR_ATMEGA8. If I was to put in my own preprocessing for the ATMEGA16 is there any difference for the 16 vs the 168 chips? and what would they be? I might look into the AVR GCC code to see if I can see a difference.
simply replace ALL __AVR_ATMEGA8 by __AVR_ATMEGA16
this should work, because they are one family (with the mega32). The mega168 is a different story...
the pin mapping can be found in pins_arduino.c
look what pin 13 is. If you use this file from the arduino core then pin 13 is PD7. Look in the datasheet and connect an LED (with resistor) to this pin (PD7) and try the Blink sketch... should work.
Ok I got the ATMEGA16 setup for arduino :) I think there are still some issues with it and I'm going to be testing each pin as much as I can tonight to make sure they do what they are supposed to do.
In the end I based it of the Sanguino core and modified that to match the ATMEGA16 and then compiled and tested it. Unfortunately I don't have the code on me now to post - And I'm not sure where to upload it in any case :(
Bohne thanks for the tip regarding preprocessors I thought that was the case and you just confirmed it for me :) And yes I now have a led blinking at me.
I am going to test each of the pins and then I'm going to try and get the STK200 4 Bit LCD going. There is some code around for that so I'm going to try what I can to get it going.
when you tested your code we can think about releasing a core that supports mega16 and mega32 if you want. Right now I am very busy (LumiNet) but in a few weeks we can try to work on this core if you want.
General update : I now have the LCD going using pins PC2-7. I tried using the Liquid Crystal and then LCD4Bit libraries and neither of these seem to work. I then tried another piece of 4Bit library from these forums and that seems to work just fine!
I'm now able to get on with my coding and see the debugging on my screen :)