1 2 3 Previous Next 63 Replies Latest reply on Jan 6, 2012 3:48 PM by user_1377889

    Timer interrupt

    rathod.dharmendrasinh

       I want to use the timer interrupt of say 50ms... .. how to configure for this..i didnt ger the logic,,, 

         

       

         

      i have give 1 Mhz clock to timer midule,, and write the 50000 count in period.. so it is 50ms count period.. but i am getting interrupt on every count... i have configured interrupt on tc mode...

         

      so i think i should get interrupt on zero count if it is down counter,, but i am not getting..

        • 1. Re: Timer interrupt
          rathod.dharmendrasinh

           my code is like this..

             

           

             

           

             

          LCD_Char_1_Start();

             

          Timer_1_Start();

             

          Timer_1_WritePeriod(50000);

             

          isr_1_Enable();

             

          isr_1_Start();

             

           

             

          LCD_Char_1_Position(0,0);

             

          LCD_Char_1_PrintString("      WELCOME      ");

             

          CYGlobalIntEnable;    /* Uncomment this line to enable global interrupts. */

             

              for(;;)

             

              {

          • 3. Re: Timer interrupt
            rathod.dharmendrasinh

             i have configured like this.. i have attache image

            • 4. Re: Timer interrupt
              gautam.das.g

              Hi Dharmin,

                 

               

                 

              You can set the interrupt on Terminal Count on as shown in the figure below.

                 

               

                 

               

                 

               

                 

               

                 

               

                 

              Next in the isr.c file generated, the "Timer_1.h" file has to be included and the variables which are to be used between the isr and the main( ) are declared as extern. Example, a variable named "flag" is declared as extern. 

                 

              This section has to be written between the #START and #END section. If written outside this section, it will be erased upon build. The snap below shows the same.

                 

               

                 

                 

               

                 

               

                 

               

                 

              Now, the code which has to be implemented in the ISR has to be written within CY_ISR( ) function between the #START and #END section.

                 

              Care must be taken to read the Status Register of the Timer Component in order to clear the Interrupt bit (as it is a sticky bit). Then the code can be written as per your logic. The snap-shot is provided below.

                 

               

                 

                 

               

                 

              This should get your project working.

                 

               

                 

              Another way would be to connect the Interrupt component directly to the TC Terminal present on the Timer component. In this case, it is not required to enable Interrupt in the Timer component and also reading the Status Register in the ISR is not required.

              • 5. Re: Timer interrupt
                rathod.dharmendrasinh
                        hello sir, i am using stepper motor controller using the cypress appilcation note, and code i have one que: how to decide the clock of the PWM module for given RPM, i am not able to get full 200 rpm by your application code,,,,   
                • 6. Re: Timer interrupt
                  udayan.umapathi

                  The speed at which a stepper motor rotates is determined by many factors. One of them is the rate at which the coils are pulsed. In the PSoC3 project a timer generates periodic interrupts that generate each step (or microstep) of the motor. This timer can be used to run the motor at a specific speed, or to a specific position (exact number of steps). To set the speed of the motor, the interrupt period of the timer is updated by firmware.

                     

                  Also note that every motor has its own limit on speed due its construction, size, number widning in coil and so on. The same will be mentioned in the datasheet of the motor.

                  • 7. Re: Timer interrupt
                    rathod.dharmendrasinh

                    but if i am changing the PWM clock, perforamance changed,,,, if i increse the PWM clock,, higher RPM can get,, so what is the rule?

                    • 8. Re: Timer interrupt
                      gautam.das.g

                      Hi Dharmin,

                         

                       

                         

                      The speed of a stepper motor depends on the delay between two subsequent steps. Smaller the delay, faster the steps and hence higher the speed.

                         

                      If you want to increase the speed, then decrease the Time Period in the Timer Component.

                         

                      The calculation will become straight forward once you get the specifications of the stepper motor from its datasheet. If it moves 1.8 degrees per step, then 200 such sequence will give one complete rotation (360 degrees).

                         

                      You can use the appropriate clock depending upon the speed required in your application.

                      • 9. Re: Timer interrupt
                        rathod.dharmendrasinh

                        i know this about the timer to change the RPM, but the problem is with PWM clock,, if i change the timer interupt according to 150RPM ,torque of motor reduced, and at 200 RPM it need the starting torqe,, if i change the PWM clock,, the reulse get better,, but no proper,, still torque is so low..

                        • 10. Re: Timer interrupt
                          simon.han

                          Hi dasg, is there any complete PSoC3/5 example code on how to use timers?

                          • 11. Re: Timer interrupt
                            ki.leung

                            PSoC timer is very easy to use. I think the best way is to build a simple application with a timer to turn on/off an LED. The software should be very straght forward. and should get you hands on experience.

                            • 12. Re: Timer interrupt
                              udayan.umapathi

                              For each component in PSoC Creator, there is an associated simple code example. This can be found as follows,

                                 

                              component (right click) --> Find Example project. I hope this helps. Moreover reading through the component datsheet will explain the operation and configuration of the timer component.

                              • 13. Re: Timer interrupt
                                donghua.gu

                                I can not see any pictures in dasq's post, does anyone else have silimar problem?

                                   

                                Anyway, I need to build timer, so I configure the count down to be 0.5sec. However, the interrupt stop being triggered after a while. If I raise the timer priority, then the UART interrupt wouldn't be triggered. It seems that I always have problem with the lowest priority interrupt. Any suggestions?

                                • 14. Re: Timer interrupt
                                  donghua.gu

                                  some update, I change the timerISR priority to be 5, higher than UART interrupt and my DAC_I2C. When I am running in debug mode, the interrupt triggered fine, however, if I let it run freely for a while, then I hit pause, then set break point inside timer interrupt, it will not trigger any more.

                                  1 2 3 Previous Next