You are here

Timer interrupt | Cypress Semiconductor

Timer interrupt

Summary: 64 Replies, Latest post by prabhu05fe_1711731 on 07 Sep 2016 08:38 AM PDT
Verified Answers: 0
Last post
Log in to post new comments.
Dharmin's picture
User
7 posts

 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..

 

 

 

 

 

 

Attachments: 
Dharmin's picture
User
7 posts

 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(;;)

    {

Dharmin's picture
User
7 posts
Dharmin's picture
User
7 posts

 i have configured like this.. i have attache image

dasg's picture
Cypress Employee
730 posts

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.

Dharmin's picture
User
7 posts

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,,,,

U2
uday's picture
Cypress Employee
569 posts

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.

Dharmin's picture
User
7 posts

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?

dasg's picture
Cypress Employee
730 posts

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.

Dharmin's picture
User
7 posts

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..

user_106453651's picture
User
7 posts

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

Log in to post new comments.