I have purchased the USBtinyISP AVR Programmer and intend to use it on some more of your Game of Life kits.
https://www.adafruit.com/product/46 (USBtinyISP AVR)
https://www.adafruit.com/product/89 (Conway's Game of Life Kit)
After reading the tutorial I was curious if the published material from a few years ago is still the best strategy for programming an AVR chip, such as in this project, over the wire?
If so, awesome, time to carry on with the terminal!
Else, looking to explore possibly simpler ways such as this project, perhaps: https://www.obdev.at/products/crosspack/index.html
Thank you,
Current Mac AVR Strategy? x Game of Life
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- adafruit_support_rick
- Posts: 35092
- Joined: Tue Mar 15, 2011 11:42 am
Re: Current Mac AVR Strategy? x Game of Life
Even if you get crosspack, you will still be using avrdude for programming the chip. If you want to install Arduino as well, then I recommend against crosspack, as the version of avrdude.conf that it installs tends to conflict with the version installed by Arduino.
- CaseyScalf
- Posts: 149
- Joined: Wed Nov 05, 2014 3:07 am
Re: Current Mac AVR Strategy? x Game of Life
Great tips,
All of those subtle details really can compound and I appreciate the advice against the new route, and to reaffirm the older tutorial.
I will endeavor the installation and let you know when I get some LEDs blinking!
All of those subtle details really can compound and I appreciate the advice against the new route, and to reaffirm the older tutorial.
I will endeavor the installation and let you know when I get some LEDs blinking!
- CaseyScalf
- Posts: 149
- Joined: Wed Nov 05, 2014 3:07 am
Re: Current Mac AVR Strategy? x Game of Life
Is there anyway I could just use an Arduino to upload the code?
As in drop in the IC from the Game of Life kit and upload it via the IDE?
If so, how would I structure the code for the project to be used in the IDE? Is this even possible?
https://github.com/adafruit/Conways-Gam ... r/firmware
I was thinking that although it would only wok on chips that were compatible it may ease the tech of the project.
Cheers,
As in drop in the IC from the Game of Life kit and upload it via the IDE?
If so, how would I structure the code for the project to be used in the IDE? Is this even possible?
https://github.com/adafruit/Conways-Gam ... r/firmware
I was thinking that although it would only wok on chips that were compatible it may ease the tech of the project.
Cheers,
- adafruit_support_rick
- Posts: 35092
- Joined: Tue Mar 15, 2011 11:42 am
Re: Current Mac AVR Strategy? x Game of Life
Wellll... You certainly could port the code to an Arduino sketch. I think. For instance, the function main maps into both setup and loop:
The rest of the code doesn't change much, I don't think. There may some functions you'll have to change to the Arduino equivalent.
Code: Select all
int main()
{
/*********************************************/
/* goes outside of setup() */
uint32_t a;
/*********************************************/
/*********************************************/
/* goes in setup() */
init();
if ( !(PINC & _BV(5)) ) {
compatmode = 1;
}
set_random();
if (compatmode)
commtimeout = 40000;
else
commtimeout = 60000;
/*********************************************/
while(1) { //delete
/*********************************************/
/* goes in loop() */
while (mode == SLEEP) {
colony = 0xFFFF;
display();
SMCR = _BV(SM1) | _BV(SE); // enable sleep
sleep_cpu();
_delay_ms(100);
}
mode = AWAKE;
SMCR = 0; // disable sleep
reset_border();
for (a=0;a<commtimeout;a++) {
if (inprogress())
break;
}
transmit(3,&fetch_trans_data);
while (inprogress()) {}
lastcolony = colony;
evolve();
if (!compatmode) {
if (colony == 0xFFFF) {
deadcount++;
} else {
deadcount = 0;
}
if (colony == lastcolony) {
staticcount++;
} else {
staticcount = 0;
}
if ((deadcount == RESPAWN) || (staticcount == RESPAWN*2) && !compatmode) {
staticcount = deadcount = 0;
set_random();
}
}
}
/*********************************************/
return 0; //delete
}
- CaseyScalf
- Posts: 149
- Joined: Wed Nov 05, 2014 3:07 am
Re: Current Mac AVR Strategy? x Game of Life
Hi Rick,
Thank you so much for the head start.
I am going to look a bit more into the code and see how I can properly decipher and translate it.
I think this would be a nice approach for this project. I will be sure to report back on what I find out!
Thank you so much for the head start.
I am going to look a bit more into the code and see how I can properly decipher and translate it.
I think this would be a nice approach for this project. I will be sure to report back on what I find out!
- steven_conaway
- Posts: 41
- Joined: Fri May 20, 2016 9:18 pm
Re: Current Mac AVR Strategy? x Game of Life
If you ever get the code, can you please post it? I would like to use an arduino.
- CaseyScalf
- Posts: 149
- Joined: Wed Nov 05, 2014 3:07 am
Re: Current Mac AVR Strategy? x Game of Life
Finally getting back to this project.
How does one actually upload the code? I have the USBTiny Programmer. The blank chips. The 6 pin plugged in. AVR Dude is installed.
Is there a tutorial for this?
Cheers,
How does one actually upload the code? I have the USBTiny Programmer. The blank chips. The 6 pin plugged in. AVR Dude is installed.
Is there a tutorial for this?
Cheers,
- CaseyScalf
- Posts: 149
- Joined: Wed Nov 05, 2014 3:07 am
Re: Current Mac AVR Strategy? x Game of Life
Alright, I was able to get it to work.
I used this line:
avrdude -c usbtiny -p m48 -U flash:w:life.hex
However, it is much slower than the complete kit version.
How then do I remake the hex file?
I used this line:
avrdude -c usbtiny -p m48 -U flash:w:life.hex
However, it is much slower than the complete kit version.
How then do I remake the hex file?
- CaseyScalf
- Posts: 149
- Joined: Wed Nov 05, 2014 3:07 am
Re: Current Mac AVR Strategy? x Game of Life
Alrighty, so I think I found out why the hex I uploaded does not run the same as th code from the kit.
That is because the Atmega48v 10PU chips are not created equal!
The ones from the kit have a "1407" on the top of the chip and the ones I ordered as suggested in the parts list have a 1409.
Upon further inspection the 1409 does not run the Game of Life at all. It blinks like it. But it is not it. Also, it's not just slow. The speed is intermittent.
Can I change anything to help this?
How do I find the appropriate chip? I have not found a listing that delineates 1407 vs 1409.
Thank you,
That is because the Atmega48v 10PU chips are not created equal!
The ones from the kit have a "1407" on the top of the chip and the ones I ordered as suggested in the parts list have a 1409.
Upon further inspection the 1409 does not run the Game of Life at all. It blinks like it. But it is not it. Also, it's not just slow. The speed is intermittent.
Can I change anything to help this?
How do I find the appropriate chip? I have not found a listing that delineates 1407 vs 1409.
Thank you,
- westfw
- Posts: 2008
- Joined: Fri Apr 27, 2007 1:01 pm
Re: Current Mac AVR Strategy? x Game of Life
You probably need to set the fuses as well, so the chip will run at 8MHz instead of 1MHz (the "new chip default")However, it is much slower than the complete kit version.
Probably something like:
Code: Select all
avrdude -c usbtiny -p m48 -U lfuse:w:0xE2:m -U flash:w:life.hex
Those are probably date codes that shouldn't matter (7th week of 2014 vs 9th week?)The ones from the kit have a "1407" on the top of the chip and the ones I ordered as suggested in the parts list have a 1409.
- CaseyScalf
- Posts: 149
- Joined: Wed Nov 05, 2014 3:07 am
Re: Current Mac AVR Strategy? x Game of Life
Thank you so much that is an excellent tip! I can't wait to try that out this morning.
Is setting the fuses common? Should I anticipate this in the future when programming blank chips?
Is setting the fuses common? Should I anticipate this in the future when programming blank chips?
- westfw
- Posts: 2008
- Joined: Fri Apr 27, 2007 1:01 pm
Re: Current Mac AVR Strategy? x Game of Life
Yes, when you're working with factory-fresh chips. It's one of the things that is (hopefully) unnecessary when you work with arduino-class "board" products (they should already have the fuses set appropriate, and a bootloader installed.)Is setting the fuses common? Should I anticipate this in the future when programming blank chips?
Be careful - you can "brick" chips if you set the fuses incorrectly:
1) enabling "debugWire" when you don't have a debugWire programmer, or when the board interferes with debugwire (I just ran into this one last night!)
2) configuring for an external crystal or clock, when none is present.
3) disabling the RESET pin.
- CaseyScalf
- Posts: 149
- Joined: Wed Nov 05, 2014 3:07 am
Re: Current Mac AVR Strategy? x Game of Life
It totally worked!
Thank you so much for all the help.
How did you know to use that hex value for the FUSE command? Did you look this up in the datasheet?
Just trying to get an idea for how to figure this out in the future.
Thank you so much for all the help.
How did you know to use that hex value for the FUSE command? Did you look this up in the datasheet?
Just trying to get an idea for how to figure this out in the future.
- westfw
- Posts: 2008
- Joined: Fri Apr 27, 2007 1:01 pm
Re: Current Mac AVR Strategy? x Game of Life
You can get the info from the datasheet (careful - a feature is "enabled" by setting it's value to 0!)How did you know to use that hex value for the FUSE command? Did you look this up in the datasheet?
But there's this wonderful online calculator: http://www.engbedded.com/fusecalc/
Please be positive and constructive with your questions and comments.