AnsweredAssumed Answered

Hello every one. i need some help regarding timer of 8 bit freescale microcontroller

Question asked by Gaurav Garg on Jul 23, 2013
Latest reply on Jul 25, 2013 by Gaurav Garg

hello everyone,

i am using freescale MC9S08GT16A microcontroller. i am beginner of using this microcontroller. could any one explain me how to give 30 sec delay in this microcontroller. during device initilization i have given delay of 2 sec. but i am confusing about delay of 30 sec. i am using code warrior software. my values for during device initilization is ..

 

prescaler   128

clk            4 mhz

modulo value  31249...

 

TPM1SC = 0x00;                       /* Stop and reset counter */

  TPM1MOD = 0x7A11;                    /* Period value setting */

  (void)(TPM1SC == 0);                 /* Overflow int. flag clearing (first part) */

  /* TPM1SC: TOF=0,TOIE=1,CPWMS=0,CLKSB=0,CLKSA=1,PS2=1,PS1=1,PS0=1 */

  TPM1SC = 0x4F;                       /* Int. flag clearing (2nd part) and timer control register setting */

  /* ### Init_GPIO init code */

  /* PTCDD: PTCDD1=1,PTCDD0=1 */

  PTCDD |= (unsigned char)0x03;

 

__interrupt void TIMER_OVF(void)

{

  /* Write your interrupt code here ... */

  PTCD_PTCD0=~PTCD_PTCD0;

  PTCD_PTCD1=~PTCD_PTCD1;

  PTCD_PTCD2=~PTCD_PTCD2;

 

 

 

 

 

  for (temp=0;temp<15;temp++) {

   

  TPM1SC; /* Clear the TOF flag */

  TPM1SC_TOF = 0;

  }

 

Thank you....

Outcomes