View previous topic :: View next topic |
Author |
Message |
bulut_01
Joined: 24 Feb 2024 Posts: 206
|
|
Posted: Mon Feb 24, 2025 8:16 am |
|
|
temtronic wrote: | One possible reason, though I can't test...
is that 1st line of the IOC handler you clear the interrupt.
that should allow more interrupts to happen within the handler, which could be bad
My understanding is that the compiler clears the interrupt when the handler is completed...... |
''clear_interrupt(INT_IOC);'' did not work even if I removed this data. It is interesting that the code that works with ext_int does not work with the ioc_a1 interrupt. |
|
 |
PrinceNai
Joined: 31 Oct 2016 Posts: 527 Location: Montenegro
|
|
Posted: Mon Feb 24, 2025 9:07 am |
|
|
I'm not close to my computer right now. I did try your code a day or two ago. You didn't copy it correctly, it doesn't compile. At least declaration of buffer is missing. I do not have your chip, so I tried, reluctantly, to do a IOC simulation in MPLABX. Either I don't know how to use it or it simulates IOC badly. I couldn't test what switching the edge with enable_interrupt does. To the point. Interrupt on both edges is actualy the desired behaviour. You didn't try the option I suggested. Set up IOC on both edges. With the if sentence I wrote make sure that you proceed to state2 ONLY when you detect a rising edge. Do not switch anything manually. The whole gymnastics with switching was there because int_ext doesn't automatically fire on both edges. Remove all that and enclose first state in that if. |
|
 |
PrinceNai
Joined: 31 Oct 2016 Posts: 527 Location: Montenegro
|
|
Posted: Mon Feb 24, 2025 11:45 am |
|
|
Quote: | It is interesting that the code that works with ext_int does not work with the ioc_a1 interrupt. |
I do not know about your chip, but I can confirm (tested) that with the changes described earlier the code using IOC works just fine on 18f46k22 with less complications in the code. Note that IOC on 18f46k22 always fires on both edges.
1. Set up IOC on the desired pin without direction, so without H2L
2. Remove ALL the manual direction changing
3. Put that if into GotRisingEdge state like this to proceed to the next state only after you've found a rising edge of the input signal:
Code: |
case GotRisingEdge: // we have a rising edge, could be start of the preamble
{
if(input_state(INPUT_PIN) == 1){ // input is 1 after interrupt, must be a transition from 0 to 1
set_timer0(0); // reset timer
TMR0_Overflow = 0; // and various counters
BitPosition = 0;
InputByteCounter = 0;
CurrentByte = 0;
Have_Data = 0; // and flags
DecodeSwitch = GotFallingEdge; // and go to GotFallingEdge to see if we have a preamble
}
break;
} |
|
|
 |
bulut_01
Joined: 24 Feb 2024 Posts: 206
|
|
Posted: Mon Feb 24, 2025 1:16 pm |
|
|
PrinceNai wrote: | Quote: | It is interesting that the code that works with ext_int does not work with the ioc_a1 interrupt. |
I do not know about your chip, but I can confirm (tested) that with the changes described earlier the code using IOC works just fine on 18f46k22 with less complications in the code. Note that IOC on 18f46k22 always fires on both edges.
1. Set up IOC on the desired pin without direction, so without H2L
2. Remove ALL the manual direction changing
3. Put that if into GotRisingEdge state like this to proceed to the next state only after you've found a rising edge of the input signal:
|
''if(input_state(inputs) == 1){ '' this worked, thank you buddy.
Last edited by bulut_01 on Mon Feb 24, 2025 1:48 pm; edited 1 time in total |
|
 |
PrinceNai
Joined: 31 Oct 2016 Posts: 527 Location: Montenegro
|
|
Posted: Mon Feb 24, 2025 1:28 pm |
|
|
 |
|
 |
bulut_01
Joined: 24 Feb 2024 Posts: 206
|
|
Posted: Mon Feb 24, 2025 1:48 pm |
|
|
 |
|
 |
bulut_01
Joined: 24 Feb 2024 Posts: 206
|
|
Posted: Mon Feb 24, 2025 1:55 pm |
|
|
@mr.temtronic wish was granted, page 20 is now available.  |
|
 |
temtronic
Joined: 01 Jul 2010 Posts: 9425 Location: Greensville,Ontario
|
|
Posted: Tue Feb 25, 2025 7:21 am |
|
|
Now that it works, you should post your completed code in the 'code library' here for others ! |
|
 |
bulut_01
Joined: 24 Feb 2024 Posts: 206
|
|
Posted: Tue Feb 25, 2025 8:38 am |
|
|
This code is compatible with my remote control. I don't think this code will work for anyone else. |
|
 |
temtronic
Joined: 01 Jul 2010 Posts: 9425 Location: Greensville,Ontario
|
|
Posted: Tue Feb 25, 2025 9:49 am |
|
|
well you can't be the only person in the world with that remote AND others could benefit from the manchester code, how to setup an IOC ISR, etc. |
|
 |
|