Deine Infos sind zu dürftig, um genauer helfen zu können.
Ich denke mal, dass du die PSoC4 TCPWM Komponente einsetzt.
Da vermisse ich in der ISR schon mal die Ermittlung der IR-Quelle.
Vlt. kann der Auszug meiner ISR aus einer Drehzahlmessung(Periodendauer)
helfen.
1 | CY_ISR(CounterISR){
|
2 | /* Variable to store the Counter Status register. The bits in this register determined which caused the
|
3 | Interrupt (either Terminal Count or Capture). */
|
4 | uint32 counterStatus = 0u;
|
5 |
|
6 | counterStatus = Counter_GetInterruptSource(); //read counter status register
|
7 |
|
8 | /* Check if the Counter interrupt source.
|
9 | * The defines Counter_INTR_MASK_TC and Counter_INTR_MASK_CC_MATCH can be seen in Counter.h file.
|
10 | * These defines indicate the type of interrupt*/
|
11 | if ((counterStatus & Counter_INTR_MASK_TC) == Counter_INTR_MASK_TC) //counter overflow (TC)
|
12 | {
|
13 | speedMeter_1.counterOverflowCount++; //increment overflow counter
|
14 | Counter_ClearInterrupt(counterStatus & Counter_INTR_MASK_TC); //clear TC interrupt
|
15 | }
|
16 |
|
17 | /* Check if the Counter interrupt is caused by Capture Event */
|
18 | if ((counterStatus & Counter_INTR_MASK_CC_MATCH) == Counter_INTR_MASK_CC_MATCH)
|
19 | {
|
20 | speedMeter_1.capturedCount = Counter_ReadCapture(); //capture event occurred
|
21 | /* Set the ISR_flag to TRUE to indicate the occurrence of CC Interrupt */
|
22 | speedMeter_1.capturedIsr_Flag = TRUE;
|
23 |
|
24 | /*Clear the Interrupt*/
|
25 | Counter_ClearInterrupt(counterStatus & Counter_INTR_MASK_CC_MATCH);
|
26 | }
|
27 | }
|
Ist sicher nicht der einzigste und auch sicher nicht der optimalste
Code, läuft aber sicher;-)
Reiner