Debug doesnt stop at Program Entry point in S12X

cancel
Showing results for 
Search instead for 
Did you mean: 

Debug doesnt stop at Program Entry point in S12X

502 Views
cbhavi
Contributor II

Hello,

I have been having very strange problems with programming my controller.

I am currently using a S12X (MC9S12XS256) controller with CodeWarrior v5.9.0 and winIDEA with the iC300HS bluebox for debugging.

The aim here is to port a HCS12 project into the current controller.

To start with I have written a simple program which handles an external watchdog timer and reads values from 3 ADC channels.

The code is fine and so is the expected result from the program.

The 'very strange problems' are as follows...

Problem-1: When I download the output files to the target for debugging, the control doesnt stop at the program entry point (neither at Startup() nor at main()) even though the option has been enabled in the debugging tool). After the download is complete I get a warning message saying 'After download action cannot be performed if CPU is not stopped'.

(After I click OK, the controller looks like its running. I have measured the time interval of the watchdog retrigger, the ADC values etc and they are all as expected and that's how i know that the code is working fine. )

Problem-2: Everytime I have to debug after a change to the program, I have to explicitly Unsecure the flash and only then download the new files to the target. If i do not do this, the CPU seems to run in a random manner. If I stop execution at any moment, the control points to only one location (this is not the same every time) and doesnt seem to go anywhere else. There is no message which says 'Download failed' or anything related either!!

Problem-3: After I unsecure the flash and then download to the target and hit F5, if I create a breakpoint or stop execution, till that point I notice tat the ADC was working properly. But, after execution is resumed, the ADC doesnt convert its channel inputs at all. I have to reset the CPU for it to start working again!

I hope someone can help me on this. I have been struggling to get this working for a long time now.

The HCS12 controller also has a similar code, but that seems to work without any such problems.

Thanks in advance.

-Bhavya.

0 Kudos
4 Replies

90 Views
kef2
Senior Contributor IV


Bhavia,

S12X is 16-bit MCU, so the right forum for it is here https://community.freescale.com/community/16bit

It looks like either 1) your program defines security byte at 0xFF0F with security engaged or 2) you instructed debugger not to unsecure MCU (writing 0xFFFE word to 0xFF0E) after flash erase. This makes you unable to debug your program.

0 Kudos

90 Views
cbhavi
Contributor II

Thank you Edward.

The memory location 0xFF0E does show a value of 0xFFFE. However, the Flash Security Register shows the Security bits to be 10b which is the definition for Unsecured state of the flash!

So if the Flash security register says that it is unsecured, why am I not able to debug or program like normal?!

Is my understanding correct? or am I missing something?

0 Kudos

90 Views
kef2
Senior Contributor IV

Perhaps it has something to do with WinIDEA. S12XS and S12XE flashes are ECC protected and flash security is engaged as soon as there's an ECC error if I recall correctly in the same flash phrase which include NVSEC byte. In case flash is mass erased, and then debugger writes FFFE @ FF0E, and then you request programming any byte in FF08..FF0F, ECC error is triggered, which makes your MCU automatically secured, even though security bits read as b'10 - unsecured. I had the same problem with S12XE, Hiwave and P&E USB Multilink. Try looking for Hiwave solution on forums.

When you try downloading new empty project binary to the target, does WinIDE complain about secured MCU? If not, then try not defining bytes ff08..ff0f in your app and ask iSystem for solution.

90 Views
cbhavi
Contributor II

Hello Edward,

Extremely sorry for the late reply.

Your suggestion helped. iSystem somehow doesnt have any forums to post questions and so I contacted their technical support.

There reply was that there is a setting that had to be disabled in winIDEA in order to run the CPU.

Disable the option: Stop after reset, set breakpoints and resume; this is under the Emulation options->CPU Setup->Advanced tab.


Thank you very much!

0 Kudos