9 Replies Latest reply on Jun 1, 2010 11:27 AM by ganesh.raaja.maharajan

    Timer8 program

    vishnu.kumar

      hi i am trying to use timers .

         

      i have seen 1 example project in cypress. i've used that code, but i am unable to get the output. LED is continuously glowing.

         

      please help me.

         

      here is the code

         

       

         

       

         

      //-------------------------------------------------------------------

         

      // Include Files

      //-------------------------------------------------------------------

         

      #include

         

       

         

      <m8c.h> // part specific constants and macros

         

      #include

         

      //-------------------------------------------------------------------

      // C Interrupt Handlers

      //-------------------------------------------------------------------

              "PSoCAPI.h"        // PSoC API definitions for all User Modules   

      #pragma

          interrupt_handler Timer8_1_ISR_C   

      //-----------------------------------------------------------------------------

      // FUNCTION NAME: Main

      //

      // DESCRIPTION:

      // Main function. Performs system initialization and loops infinitely.

      //

      //-----------------------------------------------------------------------------

      //

      // ARGUMENTS: None

      // RETURNS: None.

      // SIDE EFFECTS: None.

      //

      // THEORY of OPERATION or PROCEDURE:

      // 1) Start the user modules

      // 2) Loop Infinitely

      //

      //-----------------------------------------------------------------------------

      //

         

      void

      {

       

          mainc()    //Enable the Global Interrupt   

      M8C_EnableGInt;

       

       

          //Enable the Timer interrupt and Start the UM   

      Timer8_1_EnableInt();

      Timer8_1_Start();

       

          //infinte loop. Processing done only at Timer_ISR.   

       

      }

          while    (1);   

      //-----------------------------------------------------------------------------

      // FUNCTION NAME: Timer8_1_ISR_C

      //

      // DESCRIPTION:

      // Interrupt Service routine of Timer8_1 usermodule written in C.

      // The _Timer8_1_ISR subroutine In the Timer8_1INT.asm file,

      // redirects the flow to this subroutine.

      //-----------------------------------------------------------------------------

      //

      // ARGUMENTS: None

      // RETURNS: None.

      // SIDE EFFECTS: None.

      //

      // THEORY of OPERATION or PROCEDURE:

      // A Terminal Count interrupt occurs at an interval of 0.5 secs.

      // The state of pin P2[0] is determined and reversed.

      //

      //

         

      void

      {

       

          Timer8_1_ISR_C()    //Read Port2 and XOR it with 0x01 to change the status from On to Off and vice-versa.   

      PRT2DR ^= 0x01;

      }