Commit 834de360 authored by Alexandre Kaspar's avatar Alexandre Kaspar

To hexa

parent e90cfd11
Pipeline #4512 passed with stage
in 1 second
...@@ -247,7 +247,57 @@ The manual is slightly more verbose and tells us what's available for the memory ...@@ -247,7 +247,57 @@ The manual is slightly more verbose and tells us what's available for the memory
<img src="images/avrdude_u.png" width="600"> <img src="images/avrdude_u.png" width="600">
In our case, `program-usbtiny` uses the following update command:
```bash
-U flash:w:hello.ftdi.44.echo.c.hex
```
which means:
* Updating the `flash` memory
* **W**riting to it (not **r**eading nor **v**erifying)
* Using the hex file `hello.ftdi.44.echo.c.hex` that got generated
Why the `flash` memory?
You should read this [memory part](https://en.wikibooks.org/wiki/Embedded_Systems/Atmel_AVR#Memory) of the Embedded Systems from Wikibooks.
And you will definitely need to read the *datasheet* of your target micro-controller.
As a summary, there are different types of memory available. For the simple AVR systems, there are:
* **data** memory, I/O registers and SRAM - those are dynamic, changing during execution, and vanishing upon shutdown (aka *volatile* memory)
* **flash** program memory - this is where your program goes
* **[EEPFROM](https://en.wikipedia.org/wiki/EEPROM)** aka Electrically Eraseable Programmable Read-Only Memory, which allows you to store data that survives a restart / shutdown
* **fuses** are special types of memory that cannot be modified by the program and must be programmed separately
For interested readers:
* [flash vs eeprom](https://electronics.stackexchange.com/questions/69234/what-is-the-difference-between-flash-memory-and-eeprom/69275)
### avrdude and fuses
Fuses are specific bits of the memory that specify low-level configurations.
Thoses have to be programmed separately from the main program memory.
In our previous example with the ATTiny44, the fuse programming was done with the `program-usbtiny-fuses` target:
```bash
program-usbtiny-fuses: $(PROJECT).hex
avrdude -p t44 -P usb -c usbtiny -U lfuse:w:0x5E:m
```
Here, the `-U` command targets the **low** bits of the fuse memory for the ATTiny44.
The actual value is specified as a hex number: `0x5E`.
### Hexadecimal Numbers
Hex numbers are numbers in hexadecimal base (16) and are typically prefixed with `0x`.
The symbols are:
| Decimal | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| Hexa | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C | D | E | F |
| Bin | 0000 | 0001 | 0010 | 0011 | 0100 | 0101 | 0110 | 0111 | 1000 | 1001 | 1010 | 1011 | 1100 | 1101 | 1110 | 1111 |
Looking at the individual bits (in groups of 4 since `2^4 = 16`) is typically the main reason for hexadecimal.
</xmp> </xmp>
<script src="sd/strapdown.js"></script> <script src="sd/strapdown.js"></script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment