ATMEGA16 - is it possible to write data to flash during run?

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

Hello,
I'm working on an ATMEGA16 data collection project where I need to sample a lot of data for a long time. The 16 has 16k of flash. This is plenty of room for my data, but I don't know how to write to the flash, and I'm not sure it can be written to during a program run.

Can someone give me an explanation of how flash is programmed? A code example would be great. And what is it generally used for?

thanks,
Andy

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

Refer to the discussion by following this link.

https://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=73563

I would recommend an external, serial flash for this. It is "possible" to store data in the internal flash. But,just because you can, doesn't mean that you should.

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

Andy,

The core of the solution is SPM - you didn't say which language you want to use but a look through your previous posts suggests it might be Codevision? I'll leave it to someone like Lee or David to comment on whether it is supplied with any form of SPM "helper" routines or whether you have to write it all from scratch. I'm guessing it must have something available for you to use.

Cliff

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

It sounds like more trouble than its worth to use the on board flash. I will be using an external serial data chip for storage. So, can someone please explain why Atmel would put so much flash on this chip? What kind of application would require this much flash? All I can think of is using it for look-up tables, and maybe tables of DTMF codes or something. Any ideas?

thanks

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

You are kidding right? 16K is actually one of the smaller AVRs - they go up to 256K these days. Sure a device of 128K/256K may be mainly full of data (often graphic images for an LCD or sound samples for PWM playback of PCM) but some apps - especially those containing an RTOS and maybe a fulll TCP/IP stack can fill (or certainly make a large dent) in devices of that size. In this realm 16K is nothing.

Cliff

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

Quote:

So, can someone please explain why Atmel would put so much flash on this chip? What kind of application would require this much flash? All I can think of is using it for look-up tables, and maybe tables of DTMF codes or something. Any ideas?

16 KB is 8 K instructions (as one AVR instruction is 16 bits).

Let us speculate that one source statement on average generates 5 to 10 machine instructions. Or really simplify things and assume 8 - 16 instructions per source statement. That's 1000 or even just 500 C statements. Including the startup code.
I realize I might be off by a factor two or so but still.. Is that much?

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 believe Bill Gates once said that there will never be a need for more than 64K of code space on a PC.

I wonder if the o/p is refering to EEPROM?

A

AVR Studio 4 Ver. 4.18 684
avr-gcc Ver. 4.3.0
ISIS 7
ELECTRA

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

What Bill apparently said was:

Quote:
"So that's a 1 MB address space. And in that original design I took the upper 340k and decided that a certain amount should be for video memory, a certain amount for the ROM and I/O, and that left 640k for general purpose memory. And that leads to today's situation where people talk about the 640k memory barrier; the limit of how much memory you can put to these machines. I have to say that in 1981, making those decisions, I felt like I was providing enough freedom for 10 years. . That is, a move from 64k to 640k felt like something that would last a great deal of time. Well, it didn't - it took about only 6 years before people started to see that as a real problem."

So he was talking about a step up from the 64K to 640K in fact

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

Cliff,

Thats why there are no quotes on my statement. :D

By the by... where do you find this stuff?

A

AVR Studio 4 Ver. 4.18 684
avr-gcc Ver. 4.3.0
ISIS 7
ELECTRA

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

Google, which lead to:

http://www.neowin.net/index.php?...

(it's just my initial thought was that it wasn't actually Gates who said it at all - I thought the 640KB/384KB split in the 5150 was a decision of an IBM electronic design engineer - not the guy they later asked to provide a BASIC for the thing - but then who knows how much WG is re-writing history?)

It is interesting to note that the very first IBM PC 5150 had 16KB soldered and the other 48KB socketed offering a 16KB or 64KB option. I could have sworn they started at 64KB - but there you go - memory ain't what it used to be.

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

I still long for my 1K Timex Sinclair.

Things where so much simpler then.

A

EDIT: I always thought he got involve because of DOS not basic. You learn something new every day.

AVR Studio 4 Ver. 4.18 684
avr-gcc Ver. 4.3.0
ISIS 7
ELECTRA

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

Maybe look at:

http://www-03.ibm.com/ibm/histor...

The entry model was a 16K unit that used tape to save/load GWBasic programs. The floppy drives and disc operating system were later options.

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

andrew99 wrote:
I still long for my 1K Timex Sinclair.

Things where so much simpler then.

Ah, yes. Back when 1K, or at most 32K, of RAM was plenty enough for everything you needed to do. Back before the time when Every OS Sucks. :twisted:

Stu

Engineering seems to boil down to: Cheap. Fast. Good. Choose two. Sometimes choose only one.

Newbie? Be sure to read the thread Newbie? Start here!

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

Stu,

With only 1K of code to worry about, you could probably figure out what was going on even in hex. :)

A

AVR Studio 4 Ver. 4.18 684
avr-gcc Ver. 4.3.0
ISIS 7
ELECTRA

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

andrew99 wrote:
With only 1K of code to worry about, you could probably figure out what was going on even in hex. :)
True enough. Although we still get lots of questions about the ATtiny series. :twisted:

Stu

Engineering seems to boil down to: Cheap. Fast. Good. Choose two. Sometimes choose only one.

Newbie? Be sure to read the thread Newbie? Start here!