Attiny40 write to nonvolatile memory

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

I would appreciate if someone could give me pointers on how I can save data (during run time) that won't be lost when power is removed. There is a section in the datasheet about NVM, but it would be useful if I can see an example in C that can be used with Atmel Studio. 

 

 

 

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

asarangan wrote:
how I can save data (during run time) that won't be lost when power is removed.

There is no EEPROM on attiny40, so that can not happen. I'd say look for AVR which has EEPROM.

“Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how will you ever debug it?” - Brian W. Kernighan

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

Well, in theory, most AVRs CAN write to flash, like a bootloader does. Whether Tiny40 allows that, I don't know. It does have 4K of flash. So, even if you can write to nonvolatile memory (FLASH), you are limited to the space left over after the program is saved. It looks like you CANNOT. From the spec sheet, it says (section 19.4):

 

The ATtiny40 supports only external programming. Internal programming operations to the NVM have been dis- abled, which means any internal attempt to write or erase NVM locations will fail.

 

Jim

 

Until Black Lives Matter, we do not have "All Lives Matter"!

 

 

Last Edited: Sun. Sep 12, 2021 - 02:03 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Same for tiny10 though the follow-on, tiny102, has self programming and a bootloader.

A tiny40 follow-on may be tiny406.

ATTINY406 | Microchip Technology

https://www.microchipdirect.com/product/search/all/ATtiny406 (44 to 52 week lead time)

 

"Dare to be naïve." - Buckminster Fuller

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

If you want to "learn" AVRs then why pick a model that has been stripped of all but the most minimal functionality simply to make an attractive price for industrial bulk usage ? Things like Atmega328P and ATmega1284P are nice device to learn on as they have "plenty of everything" (the 1284P especially). What's nice about the 328P is that you can buy an Arduino board for very little more than the cost of the raw chip and you not only get the great micro to learn on but on an extremely well designed board that provides things like clock, PC interface, programming channel and pretty much everything (with the possible exception of a debugger) that you could possibly ever want when learning.

 

Possibly even better are the Xplained Pro and Curiosity boards from Microchip themselves that deliver all that and a debugger as well.

 

Sure tiny 4/5/9/10/20/40 look "cute" because you can apparently squeeze clever logic designs onto the head of a pin but the practicality is that you are banging up against their limitations all the time.

 

YMMV.

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

clawson wrote:
(with the possible exception of a debugger)
debugWIRE via USB UART | AVR Freaks

AVR Studio On Mac & Linux? | AVR Freaks

 

"Dare to be naïve." - Buckminster Fuller

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

There are two realistic approaches to non-volatile data storage (data retained after power off).  Battery backup or EEPROM.

Batteries come with Real-time clock chips:  Here's a pack of 10 RTC modules that cost about $3 each: https://www.ebay.com/itm/3246962...

 

The FM25V02 functions as EEPROM and non-volatile RAM in a single small IC.  It holds 32K bytes.

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

Simonetta wrote:
There are two realistic approaches to non-volatile data storage (data retained after power off).  Battery backup or EEPROM.
Two? Or FRAM or SD/MMC or I2C/SPI EEPROM or link to HTTP/FTP server or ...