... and the file?
Your reset pin on counter is not routed to anything ?
@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.
The basic codeing is an api shown in datasheet -
Description: This function returns the contents of the capture register or the output of the FIFO (UDB only).
Return Value: uint8/16/32: Current capture value. For 24-bit Counters, the return type is uint32.
Side Effects: None
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??
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.
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?
@hli, actually I am trying convert the sensor pulses interfaced to the 8CY8C050 PSoC 5 kit in to RPM. For this i have used a timer and a counter combination. My aim is to get the speed of the motor in RPM from the pulses.
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
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.