AnsweredAssumed Answered

Problem with S12ZVC startup code

Question asked by Amit Dhand on Sep 1, 2015
Latest reply on Sep 2, 2015 by Amit Dhand

Hello,

 

I have a created a short code to initialise MCU clock before going to _Startup code.

 

Here is the code.

 

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

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

#include <starts12z.h>

 

void PLL_init();

 

void interrupt VectorNumber_Vreset Vreset_ISR();

void interrupt VectorNumber_Vreset Vreset_ISR()

{

    PLL_init();

}

 

void main(void)

{

 

  EnableInterrupts;

  /* include your code here */

 

 

 

  for(;;) {

    __RESET_WATCHDOG();    /* feeds the dog */

   

  } /* loop forever */

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

 

}

 

void PLL_init()

{

    CPMUCLKS_PLLSEL = 1;                //FBUS = FPLL/2.   FBUS = 32MHz,

    CPMUREFDIV_REFFRQ = 1;                //Reference clock between 2MHZ and 6MHZ.   

    CPMUREFDIV_REFDIV = 0x1;            //FREF=8/(1+1) = 4MHZ       

    CPMUSYNR_VCOFRQ = 0x1;                 //FVCO is between 48MHZ and 80MHZ   

    CPMUSYNR_SYNDIV = 0x7;                //FVCO = 2xFREFx(SYNDIV+1)   =   FVCO = 2x4x(7+1) = 64MHZ

    CPMUPOSTDIV_POSTDIV = 0x0;            //FPLL = FVCO/(POSTDIV+1).  FPLL = 64MHZ/(0+1)    FPLL = 64MHz   

    CPMUOSC_OSCE = 1;                    //External oscillator enable. 8MHZ.        FREF=FOSC/(REFDIV+1)       

    while(!CPMUIFLG_LOCK){}                // Wait for LOCK.         

    CPMUIFLG = 0xFF;                    // clear CMPMU int flags - not needed but good practice

   

    __asm(jmp _Startup);                   /* Jump to C startup code */

}

 

I commented this part of code from LCF file

VECTOR 0 _Startup /* reset vector: this is the default entry point for a C/C++ application. */

 

But the issue is now every time I debug the code with the setting as program entry point, it always jump into the startup code. It never comes to this function PLL_init.

I would like to know how S12ZVC microcontroller is configured for the program startup.

 

Thank you,

Amit Dhand

Outcomes