7 Replies Latest reply on May 18, 2017 4:11 AM by JoMe_264151

    timer +input

      hi every one 


      I wish to read a pwm signal by using only an input pin + timer, so I make an interruption relied to my pin and then I make a delay of 1ms but when I send the data to my application to read it, its send to me 0 value, I think my interruption doesn't work correctly, any suggestion please thank you ^^

        • 1. Re: timer +input

          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. Please be a bit more clear what you want to perform, delay the signal by 1 ms?





          • 2. Re: timer +input

            hi bob


             I want to read a pwm signal like you see in my project, I want to read the frequency (counting the number of pulses in a period).




            thank you bob


            • 3. Re: timer +input

              Your interrupts are not associated with a signal or a component, you just call the handlers from software. This might not be what you want.


              A component is connected to an interrupt handler by using the Component_StartEx() API.





              • 4. Re: timer +input

                hi bob, thank you for your answear :)


                i want to read a pwm signal, thats why i use the bloc of TCPWM juste only for test, and then i send it to --->read_PWM_MOT, and the interrupt nam isr_1, sow i make my interruption on a rising edge like this :




                and then i call it : " isr_1_StartEx(isr_speed);"


                and when i send the value of the counter in my buffer is send to me 000 




                thank you for your answear ^^

                • 5. Re: timer +input

                  To "read" a PWM signal you probably mean to measure pulse width. This is done best using a Timer Counter component. Configure that for capture on falling edge and a count input. Set interrupts on capture and on terminal count.


                  Connect your signal to measure to both capture and count inputs, select the clock frequency as desired.


                  Write an interrupt handler that reads the captured value, stops the counter, set counter to zero and starts counter again.





                  1 of 1 people found this helpful
                  • 6. Re: timer +input

                    hi bob thank u for your answer, can u take a look plz, i juste make the modification  that u suggeste, but my buffer usb =0x00


                    thank u 


                    • 7. Re: timer +input

                      Connect your CounterISR to the interrupt signal on Counter_Spd.


                      Configure Counter_Spd to reload at tc and cc


                      In CY_ISR(cont_handler) you need to read the isr cause (see datasheet) to clear the interrupt and decide if it was a tc (no input signal) or a cc.





                      1 of 1 people found this helpful