AnsweredAssumed Answered

Programming Trim Byte in Flash from RAM using IntFlash Bean

Question asked by Thomas Walsh on Jun 21, 2009
Latest reply on Jul 11, 2009 by Thomas Walsh


I'm trying to program a trim/calibration byte into non-voltatile flash, to survive loss of power.  The Flash programming sequence is fairly complex, and the code executing it must be run from RAM.  I've never programmed in assembly before, and after multiple failed attempts to home-brew code for this using various application notes, I forked over the money for the IntFlash bean for CodeWarrior, which ostensibly provides a simple function for programming a byte to flash (SetByteFlash).  


Unfortunately, when theSetByteFlash function executes, my code stops.  Stepping through the program, I see that at a consistent point in the programming sequence, there is a "Cpu_Interrupt" triggered (the ISR contains no code, so it just stalls).  If I use set the simple "Write" mode in the IntFlash bean, this Cpu_Interrupt is triggered upon execution of this assembly line in RTSHC08.h:


JSR    ,X                     ; // call pushed copy loop on TOS


If I set the IntFlash write mode to Destructive Write,  a different line triggers the same interrupt:


PSHX                          ; // src addr


The IntFlash bean is advertised as a straightforward solution to programming a byte into flash, and the documentation is fairly sparse - it seems that just running the functions is supposed to work.  I can only find a few mentions on the forums here.  Any ideas on what could be causing this interrupt, or what I should investigate?  Is there better documentation on how to use PE beans somewhere?  I've spent hours digging through the reems of posts on programming to Flash from RAM, but applicability to the PE bean is not obvious, and I fear that I lack the low-level programming knowledge to properly implement the flash programming sequence without a bean.