Serial Programming Algorithm Flash memory Problem

Go To Last Post
14 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello everyone.

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)

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

First thing first: Have you read the chapter "Memory Programming" in the ATtine2313 data sheet?

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm sorry, where? I can't find it. I'm reading about "Programming Protocol"

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sorry, in the ATtiny2313 data sheet the chapter is actually named "External programming". Pages 184-205.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Isn't that what he was already describing in #1? 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yeah! It's where I found the info to start programming. I think I followed all the steps in the right way. I can't understand where I did wrong

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Guys, I can't tell you how, but now everything works fine. I did the same things, but now they works. 

So... I'm happy! I just programmed by myself a microcontroller! smiley I did not explain before, but I did it ALL by myself,  I mean: I just light a led with a microcontroller just using two PUSH BUTTON as programmer! One for SCK and one for MOSI. No computer involved! Sounds crazy to me!laugh

Next step, make that led blink! Ahahahah

Thank you guys.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Jackpcb wrote:
just using two PUSH BUTTON as programmer!

You're just wonderfully crazy! :-)

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

i'm working to  this project too

but i dont any answer

plz can u send me some code

jj168akm@gmail.com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Note that the thread is from 3 years ago, and the OP is no longer here.

 

Also, probably not a good idea to post your email address in a public forum - unless you particularly like SPAM?

 

mohammad_mz wrote:
i dont any answer

 

So what have you tried? Where are you stuck?

 

Have you studied the documents already mentioned?

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 2

Why not concentrate on writing a program that actually uses the chip, rather than trying to figure out how to get the chip to accept your code?    There are plenty of programmers to use. Live on the backs of giants! 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

Note also that the OP didn't actually write any programming code, just a small blinky program.

He was a very special type of freak who wanted to program his AVR serially with the two push-button equivalent of this:

 

https://en.wikipedia.org/wiki/Data_General_Nova#/media/File:Nova1200.agr.jpg

 

 

PS: If you need code, what's wrong with investigating avrdude?

 

Last Edited: Mon. Jun 22, 2020 - 03:17 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

thank you to mentioned that

i confuse in page write

my algurithm is i write 32*2 byte by loading instruction

when i program page one is correct but next word write at address 0x200 in flash and next one at 0x400

i don't understand when i write in page

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Is your Page Size correct?  I get  16 words or 32 bytes in teh t2313A data sheet

 

 

mohammad_mz wrote:

 

my algurithm is i write 32*2 byte by loading instruction