Timer without Interrupt

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

cross mob
msnaeem89
Level 2
Level 2
10 sign-ins 5 replies posted 5 sign-ins

Hallo. I want to use timer to generate delay for example 50ms and toggle the Pin. I have done with CyDelay and Interrupt which is working but i want to do it using timer delay. For example it took 250 count to generate 50ms. i set the total period at 255 count or 51ms. This is my function to generate the delay

Timer_1_WriteCounter(0) ;
Timer_1_Start() ;
while(Timer_1_ReadCounter() < 250);
Timer_1_Stop();

It should generate 50ms but it dont. It only generate 200us high and low pulse. Can you pleasw help me how generate 50ms pulse using this delay method?

Note: If using Interrupt. it is working properly.

 

0 Likes
1 Solution
msnaeem89
Level 2
Level 2
10 sign-ins 5 replies posted 5 sign-ins

  Thanks for your reply.
Your project is good for PWM but i wanted to implement 50ms wait in my safety relevant code.
Actualy i did it using interrupt before but my code always jumps from one line to another and i have set variables to wait which was not good idea. so i wanted to wait in while loop until 50ms wait time does not pass.

So, before i was using Timer V2.80 now when i tried Timer Counter(TCPWM mode) i am able to generate 50ms delay/wait. with Timer V2.80 i was not able access Timer_1_ReadCounter API.

View solution in original post

0 Likes
4 Replies
Len_CONSULTRON
Level 9
Level 9
Beta tester 500 solutions authored 1000 replies posted

@msnaeem89 ,

What PSoC4 are you planning on using?

Depending on which PSoC4 will determine what resources you have available.

Len
"Engineering is an Art. The Art of Compromise."
0 Likes

I am using it on CY8C-042 or CY8C4245AXI-483

 

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

@msnaeem89 ,

Attached is a very simple project with three timing events each producing a 50ms ON pulse that cycle every 1 second.

Timer event resources:

  • HW TCPWM fixed component.   This is the most accurate with the least amount of pulse jitter.
  • SW SysTick ISR that makes use of the SsTick resource and doesn't consume any timer resources.   This has more timing jitter than the HW method.
  • SW CyDelay() generation.  This has the most amount of timing jitter.

Note:  These event cycle every 1 sec.   They can be fairly easily changed to start the pulse event on a trigger if desired.

Len
"Engineering is an Art. The Art of Compromise."
msnaeem89
Level 2
Level 2
10 sign-ins 5 replies posted 5 sign-ins

  Thanks for your reply.
Your project is good for PWM but i wanted to implement 50ms wait in my safety relevant code.
Actualy i did it using interrupt before but my code always jumps from one line to another and i have set variables to wait which was not good idea. so i wanted to wait in while loop until 50ms wait time does not pass.

So, before i was using Timer V2.80 now when i tried Timer Counter(TCPWM mode) i am able to generate 50ms delay/wait. with Timer V2.80 i was not able access Timer_1_ReadCounter API.

0 Likes