To fully understand how microcontrollers work, I'm trying to program by myself an ATtiny2313.
First I set LOW the reset pin, and then I send the Programming Enable command (0xAC, 0x53). At MISO the attiny2313 send me back 0x53, so I guess I successfully enter in programming mode. After that I send the Chip Erase command. Here there is a problem. Searching on the internet (and also in this forum), I didn't understand if I have to toggle the reset pin after the chip erase or not.
By the way, I tried both.. After this I start Loading the program with "Load program memory Page". So I send 0x40 with my LSB, and 0x48 with the program MSB. As I read on the micro datasheet, then I have to send the Write Program memory page to really burn the program on the micro flash, and I did.
The problem is that after I did that, when I try to read what I wrote, I read or 0xFF or 0.
I can't understand why. The program I write is simply: LDI r16,0xFF
As Atmel says, LDI code is 1110 kkkk dddd kkkk, so my code is 1110 1111 0000 1111
But I have to send before the lsb byte.
In a nutshell my program in binary is:
0100 0000 0000 0000 0000 0000 0000 1111 (load memory page LSB at address 0)
0100 1000 0000 0000 0000 0000 1110 1111 (load memory page MSB at address 0)
0100 1100 0000 0000 0000 0000 0000 0000 (Write program memory page at address 0)