In SX Microcontrollers, SX/B Compiler and SX-Key Tool, Matthias09 wrote: Bean, thanks for the idea. I will implement it. I am curious: what are the advantages to use two pins? so far I see the following ones: - shorter interrupt routine, less interrupts are skipped therefore - due to I now have two pins detecting the signal in different ports, that are alternating interrupting the program, the second interrupt is put into waitlist, when the first one is processed, rather than just ignored and: the problem with the rising/falling edge detection I had initially started this topic for solved itself with a new coding of the program. It was just a software bug. For all who are interested: this is the working encoder routine: [code] ISR_Start: WKPND_B = int_storage IF int_storage = %0001 THEN 'Channel A Interrupt: count only, if A alone fires (other possible combinations: 0010: index fires, 0011: index + A fires) IF edge = 1 THEN 'change edge detection mode with every interrupt of A, no matter of B WKED_B = %11111111 'alter edge detection to falling edge on A edge = 0 'change edge detection mode variable to 0 for next interrupt ELSE WKED_B = %00000000 'alter edge detection to rising edge on A edge = 1 'change edge detection mode variable to 1 for next interrupt ENDIF IF signal_B = 1 THEN 'count only, if B is high IF edge = 1 THEN 'check the current edge detection mode, here: rising edge angle = angle + 1 'increment ??? recheck how to count toggle led3 ELSE angle = angle - 1 'decrement ??? recheck how to count toggle led4 ENDIF ENDIF ELSE 'Index Channel Interrupt. if index fires (no mater if A also fires), then reset angle to 90 deg. WKEN_B = %11111100 'enable channel A interrupt (actually only has to be done after the first fire (as A is initally disabled). 'but to a routine would slow the process, which is not good. angle = 90 'reset angle Toggle Led2 'show that ENDIF ISR_Exit: WKPND_B = %00000000 'clear pending register, ALL bits RETURNINT 'end of interrupt handler [/code] Matthias ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=375331#m375596 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2009 (http://www.dotNetBB.com)