MC9S08PA4 not working properly

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

MC9S08PA4 not working properly

Jump to solution
1,537 Views
JohnnyS2K
Contributor III

Hi everybody, 

 

So, I have decided to make a new project using the MC9S08PA4 to replace a MC9S08SH8 in a project that a I have done some time ago, until then everything was ok. The problem begins when I have started to test the new PA4 that I have ordered (samples). With this sample parts, I simply can't debug or run the code that I have made, even a simple led blink code (as below) does not work as it should...

 

#include <hidef.h> /* for EnableInterrupts macro */ #include "derivative.h" /* include peripheral declarations */  void main(void)  {   unsigned int Loop = 0;   volatile unsigned char ST = 0;    ST = SYS_SRS;    SYS_SOPT1 = 0b00001100; // RESET and BKGD active    WDOG_CS1 = 0; // disable WDT    PORT_PTAOE = 0b00000001;   PORT_PTAIE = 0b11111110;   PORT_PTAPE = 0b11001110;    PORT_PTAD_PTAD0 = 0;    for(;;)    {        PORT_PTAD_PTAD0 = 1;         for(Loop=0;Loop<50000;Loop++);         PORT_PTAD_PTAD0 = 0;         for(Loop=0;Loop<50000;Loop++);   }  }

 

 

The LED is connected on PTA0 (pin 20) with a 1K resistor to GND.

 

Everytime that I need to program the microcontroller (on run or debug) I must power off and power on the power supply.

When I try to debug, I can run the program step by step until line 23, after this point the program lost itself and I get the message "Target request failed: HC/RS/S12Z GDI Protocol Adapter : Stop failed. Non Fatal Error.".

When I try to run the code the LED stays lit forever.

 

I'm have tested this code with the CW 10.4 and CW 10.5 using the CYCLONE PRO via USB to program the microcontroller and the results are the same.

 

Any help is welcome!

 

Thanks!

Labels (1)
Tags (3)
1 Solution
675 Views
michaelsteffenf
NXP Employee
NXP Employee

Try this code to disable the WDT:

/Unlocking Watchdog Registers

WDOG_CNT = 0xC520;                           // write 0xC520 to the 1st unlock word

WDOG_CNT = 0xD928;                           // write 0xD928 to the 2nd unlock word

//Disable Watchdog

WDOG_CS1 = 0;                                // disable Watchdog

WDOG_CS2 = 0;

WDOG_TOVAL = 0xFFFF;

WDOG_WIN = 0x0000;

Mike

View solution in original post

6 Replies
675 Views
motorcontrol
Contributor I

hi jonny

i have got similar problems with mc9s08pt32 . i think there is a problem with disabling wdt. i can not disable wdt. probably wdt resets your system during step by step working.

and while i programming each time it asks me to power up the system.

and while running i can not stop the code clicking the stop button on the screen.

regards

0 Kudos
676 Views
michaelsteffenf
NXP Employee
NXP Employee

Try this code to disable the WDT:

/Unlocking Watchdog Registers

WDOG_CNT = 0xC520;                           // write 0xC520 to the 1st unlock word

WDOG_CNT = 0xD928;                           // write 0xD928 to the 2nd unlock word

//Disable Watchdog

WDOG_CS1 = 0;                                // disable Watchdog

WDOG_CS2 = 0;

WDOG_TOVAL = 0xFFFF;

WDOG_WIN = 0x0000;

Mike

675 Views
Ingo_Michael
Contributor II

Hello,

I had the same Problem on an S08PT60. I use Assembly language and according to Mike´s solution

I want to post my assembly code here. Thank you Mike, it works for me too!

After Startup:

_Startup:
            LDHX   #RAMEnd+1        ; initialize the stack pointer
            TXS
            SEI                                    ; disable interrupts
             lda #%00001100
             sta SYS_SOPT1  
             jsr Watchdog_disable

             bra mainLoop

mainLoop:

               bra mainLoop


Watchdog_disable:
  

               psha

               ldhx #$C520

               sthx WDOG_CNT

               ldhx #$D928

               sthx WDOG_CNT

               lda #$00

               sta WDOG_CS1

               lda #$00

               sta WDOG_CS2

               ldhx #$FFFF

               sthx WDOG_TOVAL

               ldhx #$0000

               sthx WDOG_WIN

               pula

               rts

0 Kudos
675 Views
JohnnyS2K
Contributor III

Sorry for the delay, michaelsteffenfae, thanks for your answer, now it worked very well!


Thanks!

0 Kudos
675 Views
motorcontrol
Contributor I

thanks michael

i missed that fact at the features of wdt. i looked at register definitions directly. we always try to make development quickly. but freescale must put a note in the register definitions that these resisters should be unlocked before altering them.

regards

675 Views
JohnnyS2K
Contributor III

yuksel celik, that's a good idea, this could help more people that are beginning working with PA/PT families.


Thanks!

0 Kudos