CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

manchester decode
Goto page Previous  1, 2, 3 ... 18, 19, 20
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
bulut_01



Joined: 24 Feb 2024
Posts: 206

View user's profile Send private message

PostPosted: Mon Feb 24, 2025 8:16 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Feb 24, 2025 9:07 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Feb 24, 2025 11:45 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Feb 24, 2025 1:16 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Feb 24, 2025 1:28 pm     Reply with quote

Very Happy
bulut_01



Joined: 24 Feb 2024
Posts: 206

View user's profile Send private message

PostPosted: Mon Feb 24, 2025 1:48 pm     Reply with quote

Cool
bulut_01



Joined: 24 Feb 2024
Posts: 206

View user's profile Send private message

PostPosted: Mon Feb 24, 2025 1:55 pm     Reply with quote

@mr.temtronic wish was granted, page 20 is now available. Very Happy Very Happy Very Happy
temtronic



Joined: 01 Jul 2010
Posts: 9425
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Feb 25, 2025 7:21 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Feb 25, 2025 8:38 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Feb 25, 2025 9:49 am     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2, 3 ... 18, 19, 20
Page 20 of 20

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group