DSPRelated.com
Forums

prog(A) not working right?

Started by Brian C. Lane December 2, 2003
What could cause a prog(A) call that has worked in previous instances to
fail to work properly? This is code I have used in several reflash
routines, but in my latest implementation it is writing to memory
location 0x00 (although it still seems to successfully erase the flash).

Here's a piece of the code:

flash_erase:
; Reserve a word on the stack
SP += #-1

A = #8555h
nop
nop
nop
*SP(0) = #0AAh
prog(A) = *SP(0)

repeat(#WRITE_DELAY)
nop

I added the nops to see if there was a pipeline problem, but even with
them I am seeing the 0x00AA show up in my IMR register!

I can't think of any DSP settings that could cause this, but maybe I'm
missing something (I must be, it has worked before).

This is on a C5416 processor.

Thanks,

Brian

--
-----------------
Brian C. Lane (W7BCL) Programmer
www.shinemicro.com RF, DSP & Microcontroller Design



Brian C. Lane wrote:
>
> flash_erase:
> ; Reserve a word on the stack
> SP += #-1
>
> A = #8555h
> nop
> nop
> nop
> *SP(0) = #0AAh
> prog(A) = *SP(0)
>
> repeat(#WRITE_DELAY)
> nop

For the record, things like this happen when CPL = 0 and you are trying
to use the stack. They also happen because the C54xx is a PITA to debug
with its pipeline -- if I had added nops after the *SP(0) and noticed
that IMR changed after the attempted stack write, not after the prog(A)
I would have caught it sooner.

Oh, and the other code ran with interrupts disabled, so even though its
a nasty bug, it didn't effect it.

Brian

--
-----------------
Brian C. Lane (W7BCL) Programmer
www.shinemicro.com RF, DSP & Microcontroller Design