EmbeddedRelated.com
Forums

Reading FLASH after programming

Started by Jeff McKnight July 25, 2007
Hi all,
i am a student and i am trying to write a application on this micro
controller in c programing language. Since i don't know how to write a
code to access flash memmory i am asking you if you can help me with
this. Sample code would be most appreciated.
Best regards,
BoSCHoW.
--- In 6..., "Edward Karpicz" wrote:
>
> DG256 has more than 4k of RAM (F000..FFFF). Remapping so big RAM to
vector
> area makes RAM overlapping flash far below than EFFE.
> With remapped to vectors RAM, bootloader must flashing locations
near EFFE
> setting PPAGE to $3F and programming flash in the page window. So
without
> reset and with RAM in vector area you should not check if
$EFFE:$EFFF is
> programmed but set PPAGE to $3F and check if $AFFE:$AFFF is programmed.
>
> Regards
> Edward
>
> ----- Original Message -----
> From: "Jeff McKnight"
> To: <6...>
> Sent: Wednesday, August 08, 2007 18:05
> Subject: Re: [68HC12] Re: Reading FLASH after programming
> > OK - sorry if there has been some confusion.
> > Previously I said that INITRM was not getting
> > reset out of a COP reset. It appears now that
> > this was an incorrect statement. I don't think it
> > was "illogical" - just a mistake. It is difficult
> > to debug because when the MCU resets, the NoICE
> > debugger loses communications.
> >
> > This is the problem that I still can't figure out :
> >
> > I am using the 9S12DG256. I am using the
> > bootloader from Motorola AN2153. I am using it
> > with very little modification. It works - and has
> > worked for me - for several years. The reset
> > vector points to the bootloader. The first thing
> > the bootloader does is look at the last byte of
> > the secondary interrupt vector table in the user
> > application code area ($efff). If the byte is
> > programmed (indicating valid code) - it jumps to
> > the start of the code. If it is not programmed -
> > it continues running the bootloader. So - after
> > the user code is programmed - a power cycle is
> > required to make it jump to the user code.
> >
> > Again - this all has worked for several years. I
> > came across this problem when I decided I wanted
> > to make the bootloader automatically jump to the
> > user code after the Flash was programmed - without
> > power cycling. I thought this would be easy to
> > just force a COP reset after the Flash was
> > programmed. When I do this - what happens is the
> > bootloader doesn't read the correct value at $efff
> > after the COP reset so it just runs the bootloader
> > again. Note - the MCU doesn't "runaway" it just
> > doesn't read the expected value at $efff so it
> > just continues on in the bootloader instead of
> > jumping to the application code. But I know the
> > Flash has been programmed because if I just do a
> > power cycle - it correctly jumps to the
> > application code and works fine. This is why I
> > say it SEEMS there is some difference between a
> > COP reset and a hard reset.
> >
> > Also if I put a breakpoint immediately after the
> > Flash is programmed - and then refresh and read
> > the memory in NoICE, I do NOT see the correct
> > values. But, as soon as I do a reset with NoICE,
> > I see the correct values. I don't know if this is
> > related to the problem - or just a quirk of NoICE.
> >
> > Thanks to all who have commented. Sorry again for
> > the confusion.
> > Jeff M.
> >
> >
> >
> >
> > Edward Karpicz wrote:
> >>
> >>
> >> Jeff Smith wrote:
> >>
> >>
> >>
> >> >
> >> > My thought was that maybe you just need a certain delay (even
a few
> >> > cycles) before trying to verify the new Flash contents. Have
you tried
> >> > that?
> >> >
> >>
> >> No. Jeff M wrote in one of messages that he waits for CCIF set. => no
> >> delays
> >> are necessary.
> >>
> >> > If you are now troubleshooting because the COP reset loses control
> >> > (runaway CPU), then where is the COP vector pointing... into
RAM? What
> >> > are the specific steps taken when attempting to relocate this
RAM in
> >> > that case?
> >> >
> >>
> >> Don't know what to answer to this, request not understood, sorry.
Why are
> >> you so complicating the things. Jeff M said he thinks it's INITRM not
> >> reset.
> >> I said what I think, primarily about INITRM. Maybe let Jeff M say
if my
> >> guess was applicable or not? Would be simple and would save your
and my
> >> time.
> >>
> >> Regards
> >> Edward
> >>
> >
> >
> >
> > Yahoo! Groups Links
> >
> >
> >
>
Hello,
I may suggest you to have a look in examples provided with your compiler and dev chain.
Regards
________________________________

De : 6... [mailto:6...] De la part de boschow2003
Envoy: jeudi 9 ao 2007 00:37
: 6...
Objet : [68HC12] Re: Reading FLASH after programming

Hi all,
i am a student and i am trying to write a application on this micro
controller in c programing language. Since i don't know how to write a
code to access flash memmory i am asking you if you can help me with
this. Sample code would be most appreciated.
Best regards,
BoSCHoW.
--- In 6...



















"boschow2003" wrote:

> Hi all,
> i am a student and i am trying to write a application on this micro
> controller in c programing language. Since i don't know how to write a
> code to access flash memmory i am asking you if you can help me with
I'm not sure what you are asking about. Don't you know how to load your code
to flash? Do you have necessary tools? Do you want bootloader? If the last
one then look for AN3275.pdf and AN3275SW.zip at following page. It looks
being done in C, probably CW:

http://www.freescale.com/webapp/sps/site/overview.jsp?nodeId430Z5777K100
> this. Sample code would be most appreciated.

Search Freescale page for application notes. I guess you are using CW? If
yes then it should have some examples. Use processor expert maybe.
Of course we can help you but we want just little more specific questions.
Show us your code that doesn't work, cite excerpt from the docs that you
don't understand. Ask were to look for information, though I'm also having
trouble with new FSL homepage. Previously all part relevant docs (ANs,
guides, datasheets) were on the same page. Navigation and ctrl+f ruled. Now
it's odd search engine that I'm not compatible with :-). It can give zilions
of matches, none of which helps. But probably I'm alone who doesn't like it.

Regards
Edward
> Best regards,
> BoSCHoW.
Hi again,

is not that my code dosent work, the problem is that a friend send me
a piece of code done in assembler. Sience i want to program in C i
want every part of the code written in C language. I asked my friend
why he had choosen assembler his response was that programing flash is
a very delicate thing this is why. Thats why i am asking for some
examples how this is done and i dont have any code written in C that
access the ram area.

Best regards,
BoSCHoW.

--- In 6..., "Edward Karpicz" wrote:
>
> "boschow2003" wrote:
>
> > Hi all,
> > i am a student and i am trying to write a application on this micro
> > controller in c programing language. Since i don't know how to write a
> > code to access flash memmory i am asking you if you can help me with
> I'm not sure what you are asking about. Don't you know how to load
your code
> to flash? Do you have necessary tools? Do you want bootloader? If
the last
> one then look for AN3275.pdf and AN3275SW.zip at following page. It
looks
> being done in C, probably CW:
http://www.freescale.com/webapp/sps/site/overview.jsp?nodeId430Z5777K100
> > this. Sample code would be most appreciated.
>
> Search Freescale page for application notes. I guess you are using
CW? If
> yes then it should have some examples. Use processor expert maybe.
> Of course we can help you but we want just little more specific
questions.
> Show us your code that doesn't work, cite excerpt from the docs that
you
> don't understand. Ask were to look for information, though I'm also
having
> trouble with new FSL homepage. Previously all part relevant docs (ANs,
> guides, datasheets) were on the same page. Navigation and ctrl+f
ruled. Now
> it's odd search engine that I'm not compatible with :-). It can give
zilions
> of matches, none of which helps. But probably I'm alone who doesn't
like it.
>
> Regards
> Edward
> > Best regards,
> > BoSCHoW.
>
boschow2003wrote:

It's perfectly clear now what you are trying to do. I hope it will be not
hard to locate flash programming code in AN3275SW.zip. If this AN doesn't
suit you then search look around at FSL page a little more. There are other
relevant AN's, aat least these; AN2720, AN3391, AN2546. I know not all these
are for C, but should be worth reading.

S12/S12X flash programming must be easy (even from scratch without any
sample) if you don't miss in docs 3 things:
1) Flash is not readable while it's being programmed, and
2) Vectors usually are keeped in flash. So for program erase time (since
memory is going to be "off" for a while) you should either a) disable
interrupts or b) move S12X vectors to using IVBR register to RAM/EEPROM. On
S12 you could overlap flash vectors by RAM or EEPROM. Of course disabling
interrupts is easier.
3) Your code should execute from RAM/EEPROM/ ext memory etc but not from the
block of flash you want to program. That's is the most troublesome for
enyone. You should know your C/asm toolset very well to be able to move some
code to RAM and execute from there. I hope AN3275 will demonstrate you how
to do this in CodeWarrior C.

Regards
Edward
> Hi again,
>
> is not that my code dosent work, the problem is that a friend send me
> a piece of code done in assembler. Sience i want to program in C i
> want every part of the code written in C language. I asked my friend
> why he had choosen assembler his response was that programing flash is
> a very delicate thing this is why. Thats why i am asking for some
> examples how this is done and i dont have any code written in C that
> access the ram area.
>
> Best regards,
> BoSCHoW.
>
> --- In 6..., "Edward Karpicz" wrote:
>>
>> "boschow2003" wrote:
>>
>> > Hi all,
>> > i am a student and i am trying to write a application on this micro
>> > controller in c programing language. Since i don't know how to write a
>> > code to access flash memmory i am asking you if you can help me with
>> I'm not sure what you are asking about. Don't you know how to load
> your code
>> to flash? Do you have necessary tools? Do you want bootloader? If
> the last
>> one then look for AN3275.pdf and AN3275SW.zip at following page. It
> looks
>> being done in C, probably CW:
> http://www.freescale.com/webapp/sps/site/overview.jsp?nodeId430Z5777K100
>> > this. Sample code would be most appreciated.
>>
>> Search Freescale page for application notes. I guess you are using
> CW? If
>> yes then it should have some examples. Use processor expert maybe.
>> Of course we can help you but we want just little more specific
> questions.
>> Show us your code that doesn't work, cite excerpt from the docs that
> you
>> don't understand. Ask were to look for information, though I'm also
> having
>> trouble with new FSL homepage. Previously all part relevant docs (ANs,
>> guides, datasheets) were on the same page. Navigation and ctrl+f
> ruled. Now
>> it's odd search engine that I'm not compatible with :-). It can give
> zilions
>> of matches, none of which helps. But probably I'm alone who doesn't
> like it.
>>
>> Regards
>> Edward
>> > Best regards,
>> > BoSCHoW.
>> Yahoo! Groups Links
--- In 6..., Jeff McKnight wrote:
>
> OK - sorry if there has been some confusion.
> Previously I said that INITRM was not getting
> reset out of a COP reset. It appears now that
> this was an incorrect statement. I don't think it
> was "illogical" - just a mistake. It is difficult
> to debug because when the MCU resets, the NoICE
> debugger loses communications.
>
> This is the problem that I still can't figure out :
>
> I am using the 9S12DG256. I am using the
> bootloader from Motorola AN2153. I am using it
[...]

OK, I think that is a very good explanation, thank you.

So do you mean that you wrote code that runs from FFFA (the COP
vector), or made sure that vector also has the same value as FFFE?

Where is INITRM relocating it to (what's the value), before the COP is
resetting? I guess I should freshen my memory by looking over the AN2153.
Jeff Smith wrote:
> --- In 6...





'




'












'