1 Reply Latest reply on Apr 26, 2011 4:40 AM by udayan.umapathi

    why does  the LED7SEG  not work ?

    chen.nate

       i tried to convert a analog signal to a digital one,using LED7SEG to show it ,but after adding the timer8 ,the system just don't work ,can you help?

         

      this is my code ,thank you !

         

      #include <m8c.h>        // part specific constants and macros
      #include "PSoCAPI.h"    // PSoC API definitions for all User Modules
      #pragma interrupt_handler timer
      int TimerCount=0;
      int iResult;
      int i;

         

      void main()
      {
         
          M8C_EnableGInt;
          PGA_1_Start(PGA_1_MEDPOWER);
          ADCINC12_1_Start(ADCINC12_1_MEDPOWER);
          ADCINC12_1_GetSamples(0);
          Timer8_1_Start();
          Timer8_1_EnableInt();
       
       
          LED7SEG_1_Start();
         
          while(1)
          {
           if(ADCINC12_1_fIsDataAvailable()!=0)
           {
            iResult=ADCINC12_1_iGetData()+2048;
            ADCINC12_1_ClearFlag();
            iResult=iResult*5000.0/4096.0;
            
            LED7SEG_1_DispInt(i,1,4);
            
            if(iResult>2000)
            {
             PWM8_1_Start();
            }
            
            if(iResult<=2000)
            {
             PWM8_1_Stop();
            }
           }
          }// Insert your main routine code here.
      }

         


       void timer()
       {
        TimerCount+=1;
        if(TimerCount==128)
         {
         i=iResult;
         TimerCount=0;
         }
       }