EmbeddedRelated.com
Forums

Flash MC9S12E via Serial Monitor Problem

Started by ymliao May 19, 2006
Hi,

I have been trying struggling for a week to flash micro via serial
monitor without success. I really appreciate if anyone could give me
some pointers.

I've tried to use ubug12, hc12mem and CodeWarrior's True-Time
Simulator and Real-Time Debugger, without much luck.

The micro is MC9S12E128. My board is not an eval board, and there is
no run/load switch. My project is created and built using "banked"
model in CodeWarrior 3.1 IDE. The target interface is "Motorola
Serial Monitor Hardware Debugging".

I am using a 8MHz crystal on the board. The bus frequency is 4MHz.
PLL is not set up in my project. SCI0 is not used neither (its
vector address not specified in prm file).

This is what I've done:

- Downloaded serial monitor source code (AN2548) from Freescale
website. Compiled and built it. Then loaded it to micro using a BDM.

- Converted .S19 file from banked format to linear output format
using SRecCvt.

- With either ubug12 or hc12mem, I could get device information or
erase flash.

- Tried to write flash with hc12mem, it started writing some blocks.
Then in the middle of the operation, it paused for a few seconds,
and gave me an error message "error: timeout - no connection with
target". And connection is lost from this point.

- Tried to write flash with ubug12, it started writing and finished
very fast. It gave a message "LOADED OKAY: 0.046875Sec. Transferrate
was 0KB/sec". So basically nothing was written to flash.

- With CW's True-Time simulator (without converting .S19 file
manually), I could see flash was erased. However, during writing,
got a connection error:
"The target cannot be accessed because the target does not respond
to communication requests! This may have several reasons:
- ...
- The communication parameter are not set correctly (baud rate)
- The target application
- may have been started immediately after reset
- is running with interrupts disabled
- run out of control
- changed the settings of the communication port
...
"

Well, the same project has been built for a "P&E ICD" target and
loaded to micro using BDM and worked fine. So I think there should
be no problem due to "interrupts disabled".

My questions are:
1) In my project, do I need to set up PLL to get a bus frequency of
24MHZ?
2) The micro reset pin is connected to an undervoltage reset chip
(MC33164). Do I need any other thing connected to this reset pin?
3) Any other thing that could make programming flash serially
successful?
4) I assume after it is done successfully, program resides on the
micro will run properly by itself after reset. Is it right?

Any help is greatly appreciated!

Amy

One thing to note with the serial monitor is that it remaps the RAM to a
reasonable (but non default) area just below 0x4000.
Well, this does not really explain what you see, but the memory setup of
you application has to be compatible with the serial monitor.
If you download to the RAM area just below 0x4000 using the monitor,
maybe it loads you code into its own stack?

Did you try to download the wizard generate app in CW, without any mods?

Daniel

ymliao wrote:
> Hi,
>
> I have been trying struggling for a week to flash micro via serial
> monitor without success. I really appreciate if anyone could give me
> some pointers.
>
> I've tried to use ubug12, hc12mem and CodeWarrior's True-Time
> Simulator and Real-Time Debugger, without much luck.
>
> The micro is MC9S12E128. My board is not an eval board, and there is
> no run/load switch. My project is created and built using "banked"
> model in CodeWarrior 3.1 IDE. The target interface is "Motorola
> Serial Monitor Hardware Debugging".
>
> I am using a 8MHz crystal on the board. The bus frequency is 4MHz.
> PLL is not set up in my project. SCI0 is not used neither (its
> vector address not specified in prm file).
>
> This is what I've done:
>
> - Downloaded serial monitor source code (AN2548) from Freescale
> website. Compiled and built it. Then loaded it to micro using a BDM.
>
> - Converted .S19 file from banked format to linear output format
> using SRecCvt.
>
> - With either ubug12 or hc12mem, I could get device information or
> erase flash.
>
> - Tried to write flash with hc12mem, it started writing some blocks.
> Then in the middle of the operation, it paused for a few seconds,
> and gave me an error message "error: timeout - no connection with
> target". And connection is lost from this point.
>
> - Tried to write flash with ubug12, it started writing and finished
> very fast. It gave a message "LOADED OKAY: 0.046875Sec. Transferrate
> was 0KB/sec". So basically nothing was written to flash.
>
> - With CW's True-Time simulator (without converting .S19 file
> manually), I could see flash was erased. However, during writing,
> got a connection error:
> "The target cannot be accessed because the target does not respond
> to communication requests! This may have several reasons:
> - ...
> - The communication parameter are not set correctly (baud rate)
> - The target application
> - may have been started immediately after reset
> - is running with interrupts disabled
> - run out of control
> - changed the settings of the communication port
> ...
> "
>
> Well, the same project has been built for a "P&E ICD" target and
> loaded to micro using BDM and worked fine. So I think there should
> be no problem due to "interrupts disabled".
>
> My questions are:
> 1) In my project, do I need to set up PLL to get a bus frequency of
> 24MHZ?
> 2) The micro reset pin is connected to an undervoltage reset chip
> (MC33164). Do I need any other thing connected to this reset pin?
> 3) Any other thing that could make programming flash serially
> successful?
> 4) I assume after it is done successfully, program resides on the
> micro will run properly by itself after reset. Is it right?
>
> Any help is greatly appreciated!
>
> Amy
>
>
>
--- In 6..., "ymliao" wrote:
>
> - Tried to write flash with ubug12, it started writing and finished
> very fast. It gave a message "LOADED OKAY: 0.046875Sec. Transferrate
> was 0KB/sec". So basically nothing was written to flash.
>

Having experienced this message many times, it means that the S-record
being written to a memory locations are outside the PPAGE = $38 to $3F.

It tries to program but there are no valid flash that exist there.

>





Hi!

I checked the .19 file. You were right that the addresses were out
of range.

So I redid the conversion using SrecCvt from Banked format to Banked
format.

However, this time ubug12 could not start writing with the following
error message: "Error: Read Error: Timeout error".

> Did you try to download the wizard generate app in CW, without any
> mods?

Yes project was generated using CW Wizard. The only modification I
made was in the .prm file:
ROM_C000 = READ_ONLY 0xC000 TO 0xF77F; // it was 0xC000 to 0xFEFF

and RAM segment was generated by Wizard as
RAM = READ_WRITE 0x2400 TO 0x3FFF;

Thanks!

Amy

--- In 6..., "zeta_alpha2002"
wrote:
>
> --- In 6..., "ymliao" wrote:
> >
> > - Tried to write flash with ubug12, it started writing and
finished
> > very fast. It gave a message "LOADED OKAY: 0.046875Sec.
Transferrate
> > was 0KB/sec". So basically nothing was written to flash.
> >
>
> Having experienced this message many times, it means that the S-
record
> being written to a memory locations are outside the PPAGE = $38 to
$3F.
>
> It tries to program but there are no valid flash that exist there.
>
>





On Friday 19 May 2006 13:29, ymliao wrote:
> Hi,
>
> I have been trying struggling for a week to flash micro via serial
> monitor without success. I really appreciate if anyone could give me
> some pointers.
>
> I've tried to use ubug12, hc12mem and CodeWarrior's True-Time
> Simulator and Real-Time Debugger, without much luck.
>
> The micro is MC9S12E128. My board is not an eval board, and there is
> no run/load switch. My project is created and built using "banked"
> model in CodeWarrior 3.1 IDE. The target interface is "Motorola
> Serial Monitor Hardware Debugging".
> My questions are:
> 1) In my project, do I need to set up PLL to get a bus frequency of
> 24MHZ?

Yes, the PLL needs setup if you want 24MHz. I hacked the Freescale boot
loader code to set 24 MHz w a 4 MHz xtal. I'd be happy to send you my code.

> 2) The micro reset pin is connected to an undervoltage reset chip
> (MC33164). Do I need any other thing connected to this reset pin?

There should be a pullup resistor on the reset line. Possibly some BDM's have
this, and others do not...I don't know, but it might explain some of what you
experienced.

>From the doc's it looks like the 'E128 does not need an undervoltage reset
chip. However, the doc's are ambiguous about the need for a pullup resistor
on the reset line. My experience was that it will not work (i.e. come out of
reset) without a pullup.

Regards,

Donald E Haselwood
> 3) Any other thing that could make programming flash serially
> successful?
> 4) I assume after it is done successfully, program resides on the
> micro will run properly by itself after reset. Is it right?
>
> Any help is greatly appreciated!
>
> Amy
>




--- In 6..., "ymliao" wrote:
>
> However, this time ubug12 could not start writing with the following
> error message: "Error: Read Error: Timeout error".
>

The message usually mean that a FLASH location is in a non-erased
state. Most likely that a FLASH location is being re-programmed with
a different value. Perhaps the area $F800 - $FFFF are being reprogrammed?

Thanks to everyone who have replied.

I have found the problem. I forgot to change device specific NVM
definition in the S12erMonxrx.def file. Thus part of the flash was not
erased properly, which caused writing failed.

--- In 6..., "zeta_alpha2002"
wrote:
>
> --- In 6..., "ymliao" wrote:
> >
> > However, this time ubug12 could not start writing with the
following
> > error message: "Error: Read Error: Timeout error".
> > The message usually mean that a FLASH location is in a non-erased
> state. Most likely that a FLASH location is being re-programmed with
> a different value. Perhaps the area $F800 - $FFFF are being
reprogrammed?
>