- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, I am trying to read the capture value of the counter when it gets interrupted by the timer, I am not able to trace where I am going wrong. So can anyone help me for getting this. I have attached the file for your reference. Basically I am trying to get he dutycycle of the PWM in terms of RPM.
Solved! Go to Solution.
- Labels:
-
PSoC 5LP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
... and the file?
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Your reset pin on counter is not routed to anything ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@danaknight, yes i have routed the reset pin of the counter to 0 but still there are some issues with the coding in the main.c, can you help me for how to read the value of counter when interrupt occours i.e. how to read capture value from counter.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The basic codeing is an api shown in datasheet -
uint8/16/32 Counter_ReadCapture(void)
Description: This function returns the contents of the capture register or the output of the FIFO (UDB only).
Parameters: None
Return Value: uint8/16/32: Current capture value. For 24-bit Counters, the return type is uint32.
Side Effects: None
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Well, without the settings of all your usermodules it is more or less a guess:
isr_1 set to rising edge? in initialization something like isr_1_StartEx(YoutInterruptRoutine) executed??
In YourInterruptRoutine
uint8 Status = Counter_1_ReadStatusRegister();
followed by a check of FIFONEMP - bit set ?
*ALL* fifo-values read off?
To provide us with all the information so we do not have to guess would be to upload the complete project here not only a picture of the schematic.When the procect contains some disclosured material, try to build an excerpt that you may show us openly which produces the error.
Use the Creator-function "Create Workspace Bundle" and upload the relulting archive here.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can you also tell us what the problem is? Just stating 'don't see where I'm wrong' doesn't help. Do you get no result, wrong results, is the program stuck?
Also, with this setup you won't get the duty cycle of the PWM, just its frequency. (The duty cycle is the fraction of each PWM period during which the output is high). But 'RPM' suggests you want to get the frequency - what is it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
the way you have it set up should work. Just make sure it is configured at rising edge, that you have the right gate from the timer and that you reset the counter for the next reading.
Would like to help more but it is kind of imposible without knowing what is actually the problem, is it entering to the ISR, is it getting wrong values?, no value at all? We could only gyess without more details
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
A basic approach -
1) Set up PWM as a gate to counter count input (basically enable), PWM positive pulse will serve
as counter time resolution. So 1 sec pulse high would give counter a 1 Hz resolution, 100 mS =
10 Hz resolution. Width of counter >= max freq to be measured. Clock to PWM and PWM period
set to yield PWM output high pulse width = gate period.
2) Add ISR to PWM out, trigger off falling edge PWM. When ISR fires set a flag. In main() test flag,
read counter (it is stopped because PWM output is 0 stopping counter), then reset counter. PWM,
when it goes high again, will automatically restart counter.
Regards, Dana.