2 Replies Latest reply on Dec 15, 2017 6:55 AM by petrescu.c.n_2989616

    Blink LED with timer

    petrescu.c.n_2989616

      Hello everybody,

       

      I am trying to blink a led using a timer. My configuration is very simple:

       

      On timer component

       

      clock: 32Khz

      period: 32000

      trigger mode: node

      capture:

      enable mode: software

      run mode: continuous.

       

      The problem is that after uploading the led lights but is not blinking.

       

      Here is the c code:

      The commented lines is what i tried. Thank you in advance.

       

       

      /* ========================================

      *

      * Copyright YOUR COMPANY, THE YEAR

      * All Rights Reserved

      * UNPUBLISHED, LICENSED SOFTWARE.

      *

      * CONFIDENTIAL AND PROPRIETARY INFORMATION

      * WHICH IS THE PROPERTY OF your company.

      *

      * ========================================

      */

      #include "project.h"

       

      int array[4]={1,2,4,8};

      volatile _Bool state=0;

       

       

      CY_ISR(TMR_ISR_HANDLER){

          if(state==1){

              state=0;

              LED_1_Write(1);

             

          }

          else{

              state=1;

              LED_1_Write(0);

          }

          //TMR_WritePeriod(32000);

          //TMR_Stop();

          //TMR_WritePeriod(5000);

          //TMR_Start();  

      };

       

       

      int main(void)

      {

          CyGlobalIntEnable; /* Enable global interrupts. */

         

          TMR_ISR_StartEx(TMR_ISR_HANDLER);

          TMR_Start();

       

       

          /* Place your initialization/startup code here (e.g. MyInst_Start()) */

       

       

          for(;;)

          {

         

              /* Place your application code here. */

          }

      }

       

       

      /* [] END OF FILE */