Write on flash memory of Atmega64 during running

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

i want to write float variable to flash memory during running and change the variable depending on running code 
i tried to use SPM instruction but i can't understand the steps to write on flash clearly .

i am using Atmel studio 7  and Atmega64 microcontroller   

mohamed elsayed

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

Why Flash specifically? ATMega64 has 2K EEPROM ...

 

https://www.microchip.com/wwwproducts/en/ATmega64

 

embeddeduser wrote:
i tried to use SPM instruction

So show what you tried.

 

For instructions on how to post source code, see Tip #1.

 

On the Product Page (link above), go to the 'Documents' Tab.

 

There are (at least) 3 Application Notes there regarding writing to Flash ...

 

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: 0

i can't use  EEPROM because i want to write array of floats and the size of data will be more than 2K  

mohamed elsayed

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

embeddeduser wrote:

i want to write float variable to flash memory during running and change the variable depending on running code 
i tried to use SPM instruction but i can't understand the steps to write on flash clearly .

AVR106

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

You do know that flash has a limited write lifetime, ~10k times, right?  Seems you have chosen the wrong micro for the task, or look at using external eeprom/flash memory.

 

Jim

 

Click Link: Get Free Stock: Retire early!

share.robinhood.com/jamesc3274

 

 

 

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

embeddeduser wrote:
i want to write array of floats and the size of data will be more than 2K  

Each float is 32 bits; so you have over 64 512 values to store?

 

Do they really have to be floats ... ?

 

EDIT

 

Correction: see #8

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...
Last Edited: Thu. Jul 19, 2018 - 12:55 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:
There are (at least) 3 Application Notes there regarding writing to Flash ...

ccrause wrote:
AVR106

Yep - that's one of 'em!

 

 

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: 0

#6 ?

The EEPROM can hold 512 floats.

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

oops - you're right.

 

Must remember the difference between bits & bytes!

 

blush

 

#6 corrected.

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: 0

#5 
yes i know but i have to use internal flash memory and already the writing on flash will be less than 100 times .

thanks

#6 
i have more than 512 float  . 

#7 
thanks it's very useful and i will try it now . 

 

mohamed elsayed

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

embeddeduser wrote:
i have more than 512 float 

And you're sure that they do actually need to be floats?

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: 0

#11 
unfortunately yes crying

i will try the functions in application note 
thank you 

mohamed elsayed

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

When you use the 'Reply' button in a post, the forum automatically identifies which post you're replying to - no need to manually type it:

 

 

#HowToReply

 

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: 0

oh sorry i am a new user blush .
thanks 

mohamed elsayed

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

I still put them in because in the past spam cleaning would break the number. 

Is that fixed ?