EmbeddedRelated.com
Forums

S12 serial monitor on C32

Started by Unknown January 23, 2004
I'm trying to use the Tech Arts MOD12C32 (actually made by Motorola). As
shipped, this device contains the Motorola serial monitor in the top 2K of
flash. This monitor makes a nice platform for downloading code and doing
some basic debugging, but I have a question about loading user code into
the C32 with this monitor.

I have code I've downloaded using a BDM, org'ed to run at $8000. The BDM
blows away the monitor, loads the code at $8000, I press reset, and the
code runs. The C32's memory map at the instant my code gets control is as
described in the Motorola docs. Since PPAGE comes out of reset on the C32
holding 0, flash page 0 (fixed at $4000) also appears at $8000. This lets
me write my code to $8000, press reset, and have it execute properly.

I can restore the monitor using the BDM, then load the same code, again
org'ed at $8000. I see the code present at $8000. I also see my reset
vectors in the $f780 area, where they have been remapped by the monitor
during the download. When I switch the board to run mode and press reset,
nothing happens. The monitor is no longer running, but my code isn't
running, either.

I have looked through the monitor's assembly language listing at the
operations performed prior to my program getting control. I do not see
writes to PPAGE. I do see changes to INITRG and INITRM; the comments for
these two lines do not imply that the flash paging is disturbed.

Can someone enlighten me? The Tech Arts docs show that the C32 has a
broken memory map, with flash from $4000-$7fff and $8000-$ffff, but I don't
see what is preventing me from loading code into the $8000 area and running
it out of reset with the monitor present.

Karl ***************************************************************************
THIS E-MAIL AND ANY ATTACHED FILES ARE CONFIDENTIAL, PROTECTED BY COPYRIGHT
ANDMAY BE LEGALLY PRIVILEGED. If you are not the intended addressee or
have received the e-mail in error, any use of this e-mail or any copying,
distribution or other dissemination of it is strictly prohibited. If you
have received this transmission in error, please notify the sender
immediately and then delete the e-mail. E-mail cannot be guaranteed to be
secure, error free or free from viruses. Novar does not accept any
liability whatsoever for any loss or damage which may be caused as a result
of the transmission of this message by e-mail. If verification is required,
please request a hard copy version.
*************************************************************************** ________________________________________________________________________
This email has been scanned for all viruses by the MessageLabs Email
Security System. For more information on a proactive email security
service working around the clock, around the globe, visit
http://www.messagelabs.com
________________________________________________________________________




> Can someone enlighten me? The Tech Arts docs show that the C32 has
>a broken memory map

>Can someone enlighten me? The Tech Arts docs show that the C32 has a
>broken memory map, with flash from $4000-$7fff and $8000-$ffff,

I had the same problem. The FLASH is broken down as $4000 - $7FFF,
$C000 - $FFFF

The loader manipulate the PPAGE to program $4000 - $7FFF

You should write your code so that they reside at $4000 - $7FFF,
$C000 - $FFFF. This way you don't care about the PPAGE.

With monitor these needs to be init.

movb #$00,INITRG ;set registers at $0000
movb #$39,INITRM ;move and set ram to end at
$3fff



As you say, the flash is $4000-$7fff and $c000-$fff; my first post was
incorrect.

I cannot find any accesses of the PPAGE register in the initial monitor
code, so I still don't understand how (or even if) my code at $8000 is
moving.

I don't want to have to link my program in two 16K sections, nor should I
have to. The chip as it comes out of reset (without the monitor) has a
contiguous 32K flash map, even though the low 16K of this is actually a
mirror of the lowest, fixed, 16K section. Leaving the monitor intact
appears to break this somehow, and I'm trying to understand how.

Karl

"zeta_alpha2002"
<zeta_alpha2002@ To:
yahoo.com> cc:
Subject: [68HC12] Re: S12 serial monitor on C32
01/23/2004 08:08
AM
Please respond
to 68HC12
> Can someone enlighten me? The Tech Arts docs show that the C32 has
>a broken memory map

>Can someone enlighten me? The Tech Arts docs show that the C32 has a
>broken memory map, with flash from $4000-$7fff and $8000-$ffff,

I had the same problem. The FLASH is broken down as $4000 - $7FFF,
$C000 - $FFFF

The loader manipulate the PPAGE to program $4000 - $7FFF

You should write your code so that they reside at $4000 - $7FFF,
$C000 - $FFFF. This way you don't care about the PPAGE.

With monitor these needs to be init.

movb #$00,INITRG ;set registers at
$0000
movb #$39,INITRM ;move and set ram
to end at
$3fff

--------------------To learn more about
Motorola Microcontrollers, please visit
http://www.motorola.com/mcu
o learn more about Motorola Microcontrollers, please visit
http://www.motorola.com/mcu
________________________________________________________________________
This email has been scanned for all viruses by the MessageLabs Email
Security System. For more information on a proactive email security
service working around the clock, around the globe, visit
http://www.messagelabs.com
________________________________________________________________________ ________________________________________________________________________
This email has been scanned for all viruses by the MessageLabs Email
Security System. For more information on a proactive email security
service working around the clock, around the globe, visit
http://www.messagelabs.com
________________________________________________________________________




First of all, just to set the record straight: the M68MOD912C32 was
designed and manufactured by Technological Arts for Motorola. The
unrelated company, Tech Arts, is a distributor of PC and networking
hardware, and has no connection to Technological Arts or Motorola.

Now to the code mystery:

You said you "load the same code", which gives me a clue to the
problem. When your program runs after being loaded by BDM, I assume it
doesn't relocate RAM, since you didn't mention it. If you then load and
run the same code with the monitor present, without modifying the stack
initialization (and any RAM variables you are using) to take into
account the monitor's relocation of RAM, your stack pointer will be
invalid, and your code will likely fail to execute properly. Check the
'C32 module's manual for the correct settings.

Best regards,
Carl Barnes
www.technologicalarts.com

wrote:
>
> I'm trying to use the Tech Arts MOD12C32 (actually made by Motorola).
> As
> shipped, this device contains the Motorola serial monitor in the top
> 2K of
> flash. This monitor makes a nice platform for downloading code and
> doing
> some basic debugging, but I have a question about loading user code
> into
> the C32 with this monitor.
>
> I have code I've downloaded using a BDM, org'ed to run at $8000. The
> BDM
> blows away the monitor, loads the code at $8000, I press reset, and
> the
> code runs. The C32's memory map at the instant my code gets control
> is as
> described in the Motorola docs. Since PPAGE comes out of reset on the
> C32
> holding 0, flash page 0 (fixed at $4000) also appears at $8000. This
> lets
> me write my code to $8000, press reset, and have it execute properly.
>
> I can restore the monitor using the BDM, then load the same code,
> again
> org'ed at $8000. I see the code present at $8000. I also see my
> reset
> vectors in the $f780 area, where they have been remapped by the
> monitor
> during the download. When I switch the board to run mode and press
> reset,
> nothing happens. The monitor is no longer running, but my code isn't
> running, either.
>
> I have looked through the monitor's assembly language listing at the
> operations performed prior to my program getting control. I do not
> see
> writes to PPAGE. I do see changes to INITRG and INITRM; the comments
> for
> these two lines do not imply that the flash paging is disturbed.
>
> Can someone enlighten me? The Tech Arts docs show that the C32 has a
> broken memory map, with flash from $4000-$7fff and $8000-$ffff, but I
> don't
> see what is preventing me from loading code into the $8000 area and
> running
> it out of reset with the monitor present.
>
> Karl
>
> ***************************************************************************
> THIS E-MAIL AND ANY ATTACHED FILES ARE CONFIDENTIAL, PROTECTED BY
> COPYRIGHT
> ANDMAY BE LEGALLY PRIVILEGED. If you are not the intended addressee
> or
> have received the e-mail in error, any use of this e-mail or any
> copying,
> distribution or other dissemination of it is strictly prohibited. If
> you
> have received this transmission in error, please notify the sender
> immediately and then delete the e-mail. E-mail cannot be guaranteed to
> be
> secure, error free or free from viruses. Novar does not accept any
> liability whatsoever for any loss or damage which may be caused as a
> result
> of the transmission of this message by e-mail. If verification is
> required,
> please request a hard copy version.
> ***************************************************************************
>
> ________________________________________________________________________
> This email has been scanned for all viruses by the MessageLabs Email
> Security System. For more information on a proactive email security
> service working around the clock, around the globe, visit
> http://www.messagelabs.com
> ________________________________________________________________________
>
> --------------------To learn more
> about Motorola Microcontrollers, please visit
> http://www.motorola.com/mcu
> o learn more about Motorola Microcontrollers, please visit
> http://www.motorola.com/mcu
>
> ---------------------------
> Yahoo! Groups Links
>
> * To

--
Best regards,
Carl Barnes
www.technologicalarts.com
toll-free: 1-877-963-8996 (USA & Canada)


Initially I org my code to start from $8000. That is how I ran into
a problem with the Monitor. To get around it I re-org my code to
start at $4000 and set MCUez parameters for non-banked.

When my program were org at $8000 I did used the Monitor to run it.
The reason it ran is that the monitor already manipulated the PPAGE.
However when having the switch move to RUN the PPAGE hasn't been
initialize so that the program that were there seem to vanish. Ergo
nothing works.

I haven't done this but maybe you could try org your code at $C000
then set PPAGE appropiately then jmp or jsr into $8000.

Maybe Gordon may have an answer? Is there a fix to monitor for the
9S12C32?

I played around with the 9S12C128 with monitor and there is no
problem as far as I am aware. --- In , karl.lunt@a... wrote:
> As you say, the flash is $4000-$7fff and $c000-$fff; my first post
was
> incorrect.
>
> I cannot find any accesses of the PPAGE register in the initial
monitor
> code, so I still don't understand how (or even if) my code at $8000
is
> moving.
>
> I don't want to have to link my program in two 16K sections, nor
should I
> have to. The chip as it comes out of reset (without the monitor)
has a
> contiguous 32K flash map, even though the low 16K of this is
actually a
> mirror of the lowest, fixed, 16K section. Leaving the monitor
intact
> appears to break this somehow, and I'm trying to understand how.
>
> Karl >
>

> "zeta_alpha2002"

> <zeta_alpha2002@ To:

> yahoo.com>
cc:

> Subject: [68HC12]
Re: S12 serial monitor on C32
> 01/23/2004
08:08

>
AM

> Please
respond

> to
68HC12

>

>

>
> > Can someone enlighten me? The Tech Arts docs show that the C32
has
> >a broken memory map
>
> >Can someone enlighten me? The Tech Arts docs show that the C32 has
a
> >broken memory map, with flash from $4000-$7fff and $8000-$ffff,
>
> I had the same problem. The FLASH is broken down as $4000 - $7FFF,
> $C000 - $FFFF
>
> The loader manipulate the PPAGE to program $4000 - $7FFF
>
> You should write your code so that they reside at $4000 - $7FFF,
> $C000 - $FFFF. This way you don't care about the PPAGE.
>
> With monitor these needs to be init.
>
> movb #$00,INITRG ;set
registers at
> $0000
> movb #$39,INITRM ;move and
set ram
> to end at
> $3fff >
>
> --------------------To learn
more about
> Motorola Microcontrollers, please visit
> http://www.motorola.com/mcu
> o learn more about Motorola Microcontrollers, please visit
> http://www.motorola.com/mcu >
>
______________________________________________________________________
__
> This email has been scanned for all viruses by the MessageLabs Email
> Security System. For more information on a proactive email security
> service working around the clock, around the globe, visit
> http://www.messagelabs.com
>
______________________________________________________________________
__
______________________________________________________________________
__
> This email has been scanned for all viruses by the MessageLabs Email
> Security System. For more information on a proactive email security
> service working around the clock, around the globe, visit
> http://www.messagelabs.com
>
______________________________________________________________________
__


My apologies on the name; I was using Tech Arts as an abbreviation for
Technological Arts. I'll be more specific in the future.

As to the RAM assignments: I had modified the linker script (this is the
GCC tool set) to allow for the monitor's reassignment of RAM. I will
double-check the stack assignment.

Karl

Carl Barnes
<techart@inter To:
log.com> cc:
Subject: Re: [68HC12] S12 serial monitor on C32
01/23/2004
02:24 PM
Please respond
to 68HC12
First of all, just to set the record straight: the M68MOD912C32 was
designed and manufactured by Technological Arts for Motorola. The
unrelated company, Tech Arts, is a distributor of PC and networking
hardware, and has no connection to Technological Arts or Motorola.

Now to the code mystery:

You said you "load the same code", which gives me a clue to the
problem. When your program runs after being loaded by BDM, I assume it
doesn't relocate RAM, since you didn't mention it. If you then load and
run the same code with the monitor present, without modifying the stack
initialization (and any RAM variables you are using) to take into
account the monitor's relocation of RAM, your stack pointer will be
invalid, and your code will likely fail to execute properly. Check the
'C32 module's manual for the correct settings.

Best regards,
Carl Barnes
www.technologicalarts.com

wrote:
>
> I'm trying to use the Tech Arts MOD12C32 (actually made by Motorola).
> As
> shipped, this device contains the Motorola serial monitor in the top
> 2K of
> flash. This monitor makes a nice platform for downloading code and
> doing
> some basic debugging, but I have a question about loading user code
> into
> the C32 with this monitor.
>
> I have code I've downloaded using a BDM, org'ed to run at $8000. The
> BDM
> blows away the monitor, loads the code at $8000, I press reset, and
> the
> code runs. The C32's memory map at the instant my code gets control
> is as
> described in the Motorola docs. Since PPAGE comes out of reset on the
> C32
> holding 0, flash page 0 (fixed at $4000) also appears at $8000. This
> lets
> me write my code to $8000, press reset, and have it execute properly.
>
> I can restore the monitor using the BDM, then load the same code,
> again
> org'ed at $8000. I see the code present at $8000. I also see my
> reset
> vectors in the $f780 area, where they have been remapped by the
> monitor
> during the download. When I switch the board to run mode and press
> reset,
> nothing happens. The monitor is no longer running, but my code isn't
> running, either.
>
> I have looked through the monitor's assembly language listing at the
> operations performed prior to my program getting control. I do not
> see
> writes to PPAGE. I do see changes to INITRG and INITRM; the comments
> for
> these two lines do not imply that the flash paging is disturbed.
>
> Can someone enlighten me? The Tech Arts docs show that the C32 has a
> broken memory map, with flash from $4000-$7fff and $8000-$ffff, but I
> don't
> see what is preventing me from loading code into the $8000 area and
> running
> it out of reset with the monitor present.
>
> Karl
***************************************************************************
> THIS E-MAIL AND ANY ATTACHED FILES ARE CONFIDENTIAL, PROTECTED BY
> COPYRIGHT
> ANDMAY BE LEGALLY PRIVILEGED. If you are not the intended addressee
> or
> have received the e-mail in error, any use of this e-mail or any
> copying,
> distribution or other dissemination of it is strictly prohibited. If
> you
> have received this transmission in error, please notify the sender
> immediately and then delete the e-mail. E-mail cannot be guaranteed to
> be
> secure, error free or free from viruses. Novar does not accept any
> liability whatsoever for any loss or damage which may be caused as a
> result
> of the transmission of this message by e-mail. If verification is
> required,
> please request a hard copy version.
>
***************************************************************************
>
> ________________________________________________________________________
> This email has been scanned for all viruses by the MessageLabs Email
> Security System. For more information on a proactive email security
> service working around the clock, around the globe, visit
> http://www.messagelabs.com
> ________________________________________________________________________
>
> --------------------To learn more
> about Motorola Microcontrollers, please visit
> http://www.motorola.com/mcu
> o learn more about Motorola Microcontrollers, please visit
> http://www.motorola.com/mcu
>
> ---------------------------
>
________________________________________________________________________
This email has been scanned for all viruses by the MessageLabs Email
Security System. For more information on a proactive email security
service working around the clock, around the globe, visit
http://www.messagelabs.com
________________________________________________________________________ ________________________________________________________________________
This email has been scanned for all viruses by the MessageLabs Email
Security System. For more information on a proactive email security
service working around the clock, around the globe, visit
http://www.messagelabs.com
________________________________________________________________________



I spent some time this weekend on the problem, and understand it better
now. Remember that this is a 'c32 platform; I haven't used the serial
monitor on any other 'hc12 variant.

Code ORG'ed at $4000 or at $c000 loads properly using the serial monitor.
Upon reset, both code sets execute as expected.

Code ORG'ed at $8000 does not load. The monitor writes the first two bytes
of code to $8000 and $8001, then goes wild. Attempts to reset or otherwise
communicate with the monitor fail. The only thing that restores comm with
the monitor is power-cycling the target. I tried manually setting PPAGE
prior to such a load, with no improvement.

As it happens, I was developing a Win32 app that uses the serial monitor to
download code to a 'c32 target. After repeatedly seeing the above failure
mode, I recoded the app to handle writes to the paged block ($8000-$bfff)
differently. If loading an S19 record would cause a write to an address in
that page, the loader (called binload) instead writes that byte to the
corresponding address in the lower fixed block ($4000-$7fff). For example,
a write of $a9 to $8040 would instead go to $4040.

This technique works because, following reset in RUN mode, the low bit of
PPAGE is cleared, duplicating the lower fixed block to the paged block.
Since the conents of that block were compiled to appear at $8000, the
addresses are all correct. Naturally, this technique won't work too well
with other 'hc12 variants. :-)

I've completed work (for now) on the binload utility and placed it on my
website at www.seanet.com/~karllunt. I've also uploaded a pdf version of
the user's manual. binload is a menu-based DOS-style Win32 app. When it
runs, you see a DOS-style window with a command prompt. binload is not a
debugger, more of a loader. It does let you view and change bytes or words
of memory, but it doesn't do trace or disassembly or other fancy stuff. It
was built solely to move S19 files into a 'c32 target.

binload also takes a set of command-line options that let you do a series
of commands without ever opening the DOS window. Using the proper options,
you can reset the target, erase flash, download code, and quit binload
without ever having to enter a command or even see the command prompt.
This lets you do rapid development cycles and even some production
downloads.

If you find any problems with binload, drop me an email at Karl

"zeta_alpha2002"
<zeta_alpha2002@ To:
yahoo.com> cc:
Subject: [68HC12] Re: S12 serial monitor on C32
01/23/2004 02:37
PM
Please respond
to 68HC12
Initially I org my code to start from $8000. That is how I ran into
a problem with the Monitor. To get around it I re-org my code to
start at $4000 and set MCUez parameters for non-banked.

When my program were org at $8000 I did used the Monitor to run it.
The reason it ran is that the monitor already manipulated the PPAGE.
However when having the switch move to RUN the PPAGE hasn't been
initialize so that the program that were there seem to vanish. Ergo
nothing works.

I haven't done this but maybe you could try org your code at $C000
then set PPAGE appropiately then jmp or jsr into $8000.

Maybe Gordon may have an answer? Is there a fix to monitor for the
9S12C32?

I played around with the 9S12C128 with monitor and there is no
problem as far as I am aware. --- In , karl.lunt@a... wrote:
> As you say, the flash is $4000-$7fff and $c000-$fff; my first post
was
> incorrect.
>
> I cannot find any accesses of the PPAGE register in the initial
monitor
> code, so I still don't understand how (or even if) my code at $8000
is
> moving.
>
> I don't want to have to link my program in two 16K sections, nor
should I
> have to. The chip as it comes out of reset (without the monitor)
has a
> contiguous 32K flash map, even though the low 16K of this is
actually a
> mirror of the lowest, fixed, 16K section. Leaving the monitor
intact
> appears to break this somehow, and I'm trying to understand how.
>
> Karl >
>

> "zeta_alpha2002"

> <zeta_alpha2002@ To:

> yahoo.com>
cc:

> Subject: [68HC12]
Re: S12 serial monitor on C32
> 01/23/2004
08:08

>
AM

> Please
respond

> to
68HC12

>

>

>
> > Can someone enlighten me? The Tech Arts docs show that the C32
has
> >a broken memory map
>
> >Can someone enlighten me? The Tech Arts docs show that the C32 has
a
> >broken memory map, with flash from $4000-$7fff and $8000-$ffff,
>
> I had the same problem. The FLASH is broken down as $4000 - $7FFF,
> $C000 - $FFFF
>
> The loader manipulate the PPAGE to program $4000 - $7FFF
>
> You should write your code so that they reside at $4000 - $7FFF,
> $C000 - $FFFF. This way you don't care about the PPAGE.
>
> With monitor these needs to be init.
>
> movb #$00,INITRG ;set
registers at
> $0000
> movb #$39,INITRM ;move and
set ram
> to end at
> $3fff >
>
> --------------------To learn
more about
> Motorola Microcontrollers, please visit
> http://www.motorola.com/mcu
> o learn more about Motorola Microcontrollers, please visit
> http://www.motorola.com/mcu >
>
______________________________________________________________________
__
> This email has been scanned for all viruses by the MessageLabs Email
> Security System. For more information on a proactive email security
> service working around the clock, around the globe, visit
> http://www.messagelabs.com
>
______________________________________________________________________
__
______________________________________________________________________
__
> This email has been scanned for all viruses by the MessageLabs Email
> Security System. For more information on a proactive email security
> service working around the clock, around the globe, visit
> http://www.messagelabs.com
>
______________________________________________________________________
__ --------------------To learn more about
Motorola Microcontrollers, please visit
http://www.motorola.com/mcu
o learn more about Motorola Microcontrollers, please visit
http://www.motorola.com/mcu

________________________________________________________________________
This email has been scanned for all viruses by the MessageLabs Email
Security System. For more information on a proactive email security
service working around the clock, around the globe, visit
http://www.messagelabs.com
________________________________________________________________________ ________________________________________________________________________
This email has been scanned for all viruses by the MessageLabs Email
Security System. For more information on a proactive email security
service working around the clock, around the globe, visit
http://www.messagelabs.com
________________________________________________________________________