Very strange reset in different conditions on MC9S12XEP100

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Very strange reset in different conditions on MC9S12XEP100

610 Views
Rhapsody
Contributor III

Hi all,

I have a strange problem that is driving me crazy.

I' developing an embedded system on the MC9S12X composed by two parts:

1. firmware loader

2. firmware

 

The firmware loader is loaded with the BDM interface, while the firmware itself is loaded through serial port using the firmware loader.

The firmware is taking control over motors, thermal printers, photosensors, and so on.

I have routines for printing graphical data on thermal paper.

 

When I call the routine for printing something on the thermal paper from a well specified point within the firmware flow, and the BDM is not connected, I get a reset everytime.

 

When I connect the BDM and do assembler step by step, then all is working fine (or at least, it seams.)

 

When I call the *SAME* routine from another point of the firmware, again everything seems to work.

 

I don't want a solution for that (it will be impossibile with what I've just written), but only some hints on what I can double check to solve this problem.

 

Any help will be very appreciated.

 

Regards,

AA

Labels (1)
0 Kudos
Reply
1 Reply

400 Views
Lundin
Senior Contributor IV

BDM connected or not connected often suggests that the problem might be related to "write-once" registers. These registers are found here and there in the various peripherals of the S12, and their nature is such that they can only be written to once in normal single chip mode. In special single chip mode, that is when the BDM is connected, you can write to them several times.

 

Which registers that are write-once is poorly documented, basically you will have to read through the whole manual page by page to find them. To save you from that pain, here is a list of write-once registers in the S12 D family. S12X or other S12 derivates may have additional ones.

 

000A             PEAR

000B             MODE

000E             EBICTL

0010              INITRM

0011              INITRG

0012              INITEE

0013              MISC

001E             INTCR

0039              CLKSEL

003C             COPCTL

00E8             DLCBCR1

00EC             DLCBARD

00ED             DLCBRSR

0100              FCLKDIV

0110              ECLKDIV

0141              CAN0CTL1

0181              CAN1CTL1

01C1             CAN2CTL1

0201              CAN3CTL1

0281              CAN4CTL1

 

For example, you could perhaps have code for your bootloader, writing to the FCLKDIV register like this:

 

FCLKDIV = some_calculated_value;

FCLKDIV |= PRDIV8;   /* will work with BDM connected, otherwise not = flash prescaler clock will go haywire */

 

This seems to be a somewhat common bug on S12 devices, and it is incredibly hard to find.

 

---

 

Other causes apart from this could be something related to your BKGD and reset pin circuitry, but that is less likely.

 

Also make sure that you aren't writing to a flash page from a routine executed in the same flash page: this doesn't work, although when single-stepping through such code with a BDM, it might -seem- to work.

0 Kudos
Reply