- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@Len_CONSULTRON 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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What PSoC4 are you planning on using?
Depending on which PSoC4 will determine what resources you have available.
"Engineering is an Art. The Art of Compromise."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am using it on CY8C-042 or CY8C4245AXI-483
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
"Engineering is an Art. The Art of Compromise."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@Len_CONSULTRON 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.