AnsweredAssumed Answered


Question asked by vikas subramani on Jun 11, 2014
Latest reply on Jun 12, 2014 by ZhangJennie

Hi every body i am a new bie to MC9S08DN16 controller and i am facing problem in toggling the port the code is as below.


/* [sample program to toggle the port D of the micro controller ] */


#include <hidef.h> /* for EnableInterrupts macro */

#include "derivative.h" /* include peripheral declarations */

void port_initialize(void);

void delay(void);



void main(void)



  /* include your code here */




  PTED = 0x00; /* flashing 0's on to port D */

  delay();   /* delay function */

  PTED = 0xff; /* flashing 1's on to port D */

  delay(); /* delay function */


   /* loop forever */

  /* please make sure that you never leave main */




void port_initialize(void )


  PTEDD = 0xff; /* port D data direction register configured as output */

  PTEPE = 0x00; /* Internal pull-up/pull-down device disabled for port D */

  PTESE = 0x00; /* Output slew rate control disabled for port D */

// PTEPE = 0x00; /* Port disabled as interrupt */




void delay()


  unsigned int i,j;

  for(i=0; i<255; i++)

  for(j=0; j<255;j++);





The problem i am facing is that although the code is in infinate loop. when i run the program after few seconds the code will exit unexpectedly and will lead to a new window and displays the following.



#pragma NO_EXIT

__EXTERN_C void _Startup(void) {

/* set the reset vector to _Startup in the linker parameter file (*.prm):

    'VECTOR 0 _Startup'



    purpose:    1)  initialize the stack

                2)  initialize run-time, ...

                    initialize the RAM, copy down init data, etc (Init)

                3)  call main;

    called from: _PRESTART-code generated by the Linker


  INIT_SP_FROM_STARTUP_DESC(); /*lint !e960 MISRA 14.3 REQ, not a null statement (instead: several HLI statements) */


#ifndef  __ONLY_INIT_SP

  Init(); /*lint !e522 function 'Init' contains inline assembly */


#ifndef __BANKED__

  __asm JMP main;  /* with a C style main(); we would push the return address on the stack wasting 2 RAM bytes */


  __asm CALL main;