Structure syntaxique binaire option30 comments
Binary options practice app
Homework for this week: Link two Arduino compatibles via SPI. One serves as ISP programmer for the second. Use two SPI devices on one Arduino simultaneously. I cannot use plain Arduino Uno's for these tasks, as they do not offer the necessary amount of memory. I cannot use the Arduino Mega , because I cannot solder its processor.
Moreover, we need to build our own board. I found an interesting Blog contribution on the Adafruit learning pages here. An Adafruit forum user has developed a program by the name Optiloader that lets an Arduino, instead of a computer, program another chip, very fast. Optiloader is very specialized, as it lets you program only one chip not a problem for my project using one particular HEX file a problem for my project.
Another contributor, Mike Tsao, improved and extended Adafruit's further development and published the result by the name adaStandalone.
One highlight among his improvements is that the memory footprint of the hex code you feed the AVR with is now roughly half as large as that achieved by the guys at Adafruit. Tsao achieved this by changing the data format. For information on what he improved, see the section "Changing the Code" on the Adafruit training website above link and the comments in adaStandalone.
At this time I realized that I had made a notional mistake. There is a problem that is not immediately obvious: This means that, in particular, the hex code from the SD card cannot be read in its entirety into Flash memory, where it would rest until it is written out to another Arduino. The Flash memory cannot be written during program execution; it is the same memory the program is burnt into beforehand. A solution for this is to stream the hex data from the SD card and simultaneously write it out to the second device.
This is what I have to do now. An advantage would be that I could use an ordinary Satshakit for the device that is writing to the second because I would not need the larger memory of the Mighty ATmegap.
But there is an alternative. With a modified Optiboot boot loader by Marek Wodzinski, it has fairly recently become possible to write to Flash memory during runtime. Wodzinski has added three new commands to the Optiboot boot loader that allow you to write pages or words or erase the memory. If my above streaming approach fails, I could also try this. The modified boot loader and the technique are detailed on this GIThub page and in this Arduino forum entry.
Modifications to the sketch AdaStandalone: His program and OptiLoader see optiLoader. I found out that the ATmegap has the same page size as the ATmegap which is used in the Arduino Uno, words, which is byte see here in section "Grundlagen" and in the ATmegap datasheet, page , section When I was investigating the code in AdaStandalone , I realized that it would be very hard for me to make the necessary modifications to the code for on-the-fly streaming from SD card.
Also, I regarded it too risky. I decided to use above mentioned OptiBoot boot loader that lets me write into Flash memory during program execution see comment in brackets. The new board definitions did not appear in my Arduino IDE 1. It worked after moving the content of the directory optiboot in a newly created folder avr. This corresponds to the way I had installed the Mighty p board definitions before.
The path to the folder avr is Arduino. Below this, you should find the folders boot loaders with sub folder optiboot , AtmelStudio , examples and two files with board definitions. One file is for new Arduino IDE versions 1. I renamed the file with the newer boards definitions with boards. What was missing, however, was a new boot loader for the ATmegap. TXT file that comes with his OptiBoot. Additionally, after compiling the new boot loader, I moved it to the location that the Arduino IDE reported it would search for it.
Within the Arduino IDE, I can now compile sketches that make use of Wodzinski's Optiboot boot loader, and that write to Flash memory while the sketch is being executed. I am suffering from a new phenomenon: I want to look at this later on. Today I have linked the Arduino Mega to the SD card reader, read from it and tried to write the file on the Flash memory.
In general, this was successful. I followed this tutorial on the Arduino website www. I wanted to do the same for the new Satshakit by Daniele Ingrassia.
It took hours to get the electrical connections right because, as soon as I put the SD card reader into the circuit, Arduino IDE did not recognize the Satshakit , or it was recognized but with a different device number, and no sketch could be burnt on it.
I read about this advice in a tutorial on SPI. This still does not work. I have decided to not use the feature from OptiBoot to load the game's hex code into Flash memory of the programming device - now an Arduino Mega - first. Instead, I have modified the program AdaStandalone such that I burn the code page per page on the target Satshakit while reading from the SD card. Although I have adjusted the program in a way that it performs this task, it does not yet work. It reads from SD card but does not yet burn the fuses correctly.
The Satshakit's on-board LED is attached to pin I used this sketch in order to check by wiring. I am using an Arduino Uno Rev. I wrote a sketch that allows me to read from the SD card see below section.
Sometimes the sketch burnt to the Satshakit , sometimes the Satshakit was not recognized, and the Arduino IDE reported device number 0x0.
At one point, neither a sketch could be burnt, nor could the directory of the SD card be printed. I switched to the Arduino Mega , and I could at least read the directory contents from the SD card. But I cannot read from SD card and burn on the Satshakit using my wiring. I, too, connected pin 10 on the Arduino Mega to this pin. Now two pins are linked to digital pin 10 of the Arduino Mega Now I can both access the SD card reader and burn sketches on the Satshakit using the same circuit see below image.
I have also added a uF capacitor to disable the autoreset function on the Arduino Mega I read this hint in an Instructables tutorial. I did that because this topic from electronics. To avoid driver contention, a series resistor should be placed on each of the three dedicated lines if there is a possibility that external circuitry could be driving these lines. The program could no longer initialize it. But it had the pleasant side effect that the fuses of the Satshakit were burnt successfully: I would need to tweak the SPI settings in my code.
SettingsA consists of the following parameters: After some time, however, it turned out that I can only reliably burn the fuses if I do not initialize the SD card reader. Again, more investigation is needed. The games on the SD card are saved in Intel hexadecimal format. I want to convert them into binary files. This would allow me to write the byte stream page per page onto the target Satshakit On a Windows 10 PC, I used the program srecord v1.
I am again suffering from a strange error: I also tried different USB cables without positive result. I have found a very strange workaround: Any clue why this works?
Does my program garble the contents of my folder? I cannot burn to my Arduino Mega at all any longer. A user on this forum reports problems that hinder the collaboration between the SD card library by Arduino and Sparkfun and the SPI library.
You can find it here. I will try this after FabAcademy, as I am running out of time. For my video game system, sadly, this means that it will not have the attractive features I wanted for it. The player will not be able to load a game from SD card. Instead, for the time being, the system will remain a toy for advanced users. The SD card library supports only 8.
The SD card library makes it simple to read files from and write to an SD card. I attached my SD card reader to the Arduino Mega using the following connections: I prepared an SD card following the advice from here file system FAT32, names not longer than 8 characters with the hex code of games I have written over the time.
I used this example program to print out its contents: Where do the files come from? The Arduino IDE temporarily stores the hexadecimal representation for a sketch it is compiling in a temporary directory with a seemingly random name.