executing an "FF", or "00" what happens?

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

Suppose your AVR takes a flying branch or jump to
some unprogrammed flash address. I assume that unused
flash programming space has a value of either xFF or x00.
I scanned the op-codes for AVR assembler and could not
find an instruction that is FF or 00.. so what happens
if a glitch hits the program counter, or you do a bad offset
or jump to an unprogrammed address?? Just curious.

Thanks,
Scott

admin's test signature
 

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

Well, let me first point out that instructions are words, not bytes, so what you probably
really want to know is what happens on an 0000 or FFFF.
Answer: 0000 is a NOP, FFFF is SBRS R31, 7

admin's test signature
 

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

Hi,

This may be handled differently in each programmer. The STK500 generally doesn't program unused memory space. This means that if you've done a Chip Erase (which you should), the remaining locations will be 0xff (erased). The command line version of the STK500 software allows you to pad the remaining memory with a value of your choice. Type "stk500 -help" in your \AVR Studio\STK500 directory for details (okay, it's the 'x' option).

Best regards,

Morten, AVR tech. support, Atmel FAE

admin's test signature
 

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

OK, I see NOP = x0000 now..

Would xFFFF really be interpretted as SBRS R31,7
given that it's OP code is 1111 111r rrrr 0bbb
there is a zero in the op code, would that be
ignored and just executed as SBRS R31,7 anyway?

If it does execute, then I guess depending on
R31 contents of bit 7 will determine the next
instruction executed. Assuming you've landed in
a block of xFF's after the end of the program,
then you'll either skip every other instruction
or execute every xFFFF until program counter
hits the end, then what? Does it wrap and then
execute next instruction at address zero (normally
the reset vector).

Same question if you've landed in a
block of zeros after your program, once you've
NOP'd to the end, does the PC wrap?

Thanks,
Scott

admin's test signature
 

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

What I've done is filled the chip's program space
after the "real program" with a long list of
"rjmp RESET_V" statements.

So any errant branch or glitch that puts the PC outside
of the program, will promptly reset the chip and get back
to a known state.

Regards,
Scott

admin's test signature
 

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

Is there any harm in putting *too many* such filler/padding
(rjmp RESET_V) statements after a program? ...other than the warning
that the assembler generates for too many statements
for the given chip? Suppose I just a big pad file to
.include after the program... do I have to worry about
trimming it to the right length?

I guess I'd like to know what happens in the extreme case near
the end of the programming cycle when memory limit is reached.

Will the AVR assembler stop generating the file after the
chip's limit is reached, or is a "too-long" file generated?

If a file that is longer than a chip's program space gets
fed into the (serial/parallel) programmer, will the
chip simply stop accepting input after the last instruction word is reached,
or does the protocol keep trying to stuff the chip?
if so, will the chip start ignoring input (toss it away), fail
on the whole operation completely, or do something entirely different (silly?) like re-write the last word over and over again
with each incoming program word until the last one received is
is the one that sticks?

I guess a little experimentation with lots of read-backs would answer these questions,
but if you happen to know the answer, its good to share it!

Thanks
Scott

admin's test signature
 

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

Hi,

All the programmers I know will either not accept too large an input file or simply cut the extra bytes at the end (possibly after a warning). I haven't heard of any programmer wrapping around to the beginning :-)

STK500 cuts off the rest after a warning.

Best regards,

Morten, AVR tech. support, Atmel FAE

admin's test signature
 

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

Hi Scott,
please tell me the instruction of the r_jump (I am programming only in C). My applications are working in industrial environment. I use a voltage monitorand, of course the WDR. I am working with a IAR developement-tool and I have the option, to fill unused code.
Thanks for a response.
Michael

admin's test signature