Timer configuration

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Hi Cypress Team, 

   

I want to configure timer in my project with 1 Micro second .

   

i used timer function block , set the clk at 2 MHz and count is 2, so it is showing 1us .

   

but i want to reconfigure timer in my state machine many times with different time configuration (1,3,20us and 125us).

   

so in the ISR , written code   

   

   CY_ISR(Timer_ISR)
{
    Timer_ISR_ClearPending();

   

 //Timer_1ms_ClearFIFO();

   

BottomTemperatureControl();

   

}

   

void BottomTemperatureControl(void)

   

{

   

//here am calling reload timer function with different timer time configuration.

   

ReloadTimer(Number of us timer configuration); 

   

}

   

 

   

void ReloadTimer(int nTimerInMicroSeconds)
{
  Timer_1ms_Stop();
    nTimerInMicroSeconds = nTimerInMicroSeconds * 2;
   Timer_1ms_WritePeriod(nTimerInMicroSeconds);
    Timer_1ms_Start();
   
}

   

if i want to set 3us timer, then i will pass 3 to the reloadTimer function and calculate the period count value inside the reload functon.

   

for 2 counts, 1us timer 

   

for 3 us, 2*3 = Count value(6).

   

if high set this value for 100us ,50us its working fine but for 3us timer , getting 40us pulse.

   

 

   

kindly help me in this.

   

I am not able to configure 16, 24 ,32 bit resolution for  the attached  timer function block .

   

it is showing error if I select 16,24 bit resolution.

   

please find the attached images for timer configuration. 

0 Likes
3 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Can you please post your complete project, so that we all can have a look at all of your settings. To do so, use
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file.

   

 

   

Bob

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

thank you for immediate response , please find the attached project code

   

Regards,

   

Ambarish

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Your function BottomTemperatureControl() consumes some more time than just a few µs. Or do you want to have a ms timer? having one million interrupts per second will bust any CPU.

   

 

   

Bob

0 Likes