In SX Microcontrollers, SX/B Compiler and SX-Key Tool, Rsadeika wrote: Peter, I am not sure if this is what you requseted. As much as I can understand of this, I think Jon's code is really pretty good; I kind of like his coding style. The first snippet is basically an SX/B version of getting the code from the irpin. The second snippet is the asm version. Both of these work, so, that is what I used to eliminate a board problem. Some where along the line I will have to sit down and study this code, and see what it really means. Thanks Ray ******CODE This is a snippet of the SX/B SIRCS_ISR program non-asm version, in here lies the pulsin command, somewhere. '_________________________________________________________________________ INTERRUPT NOPRESERVE '_________________________________________________________________________ ISR_Start: if hasCmd = 1 then ISR_Exit if rxCmd = 1 then Check_Bit if irpin = 1 then ISR_Exit Start_Packet: rxCmd = 1 rxBit = 1 cmdWork = 0 bitWidth = 0 bitCount = 0 goto ISR_Exit Check_Bit: if irpin = 0 then Update_BitWidth if rxBit = 0 then ISR_Exit rxBit = 0 if bitCount > 0 then Test_DBit Test_SBit: if bitwidth > 74 then Next_Bit rxCmd = 0 goto ISR_Exit Test_DBit: cmdWork = cmdWork >> 1 if bitWidth < 34 then Next_Bit cmdWork.6 = 1 Next_Bit: bitwidth = 0 inc bitCount if bitCount < 8 then ISR_Exit hasCmd = 1 cmdCode = cmdWork rxCmd = 0 goto ISR_Exit Update_Bitwidth: inc bitWidth rxBit = 1 ISR_Exit: returnint 104 ******************* This is a snippet of the asm version of the SIRCS_ISR program, in here lies the pulsin command also. This is a cut from Jon's original code. The variables apply to both snippets. ' ------------------------------------------------------------------------- ' Variables ' ------------------------------------------------------------------------- cmdCode VAR Byte ' IR command code (7 bits) cmdWork VAR Byte ' work space for cmd byte bitCount VAR Byte ' track bits received bitWidth VAR Byte ' measure bit width flags VAR Byte rxCmd VAR flags.0 ' receiving command rxBit VAR flags.1 ' measuring bit width? hasCmd VAR flags.2 ' command code available temp1 VAR Byte ' subroutine work vars temp2 VAR Byte temp3 VAR Byte ' ------------------------------------------------------------------------- INTERRUPT NOPRESERVE ' ------------------------------------------------------------------------- ISR_Start: ASM JB hasCmd, ISR_Exit ' exit if holding command JB rxCmd, Check_Bit ' receiving now? JB IR, ISR_Exit ' exit if IR line idle Start_Packet: SETB rxCmd ' set rx flags SETB rxBit CLR cmdWork ' clear work vars CLR bitWidth CLR bitCount JMP ISR_Exit Check_Bit: JNB IR, Update_BitWidth ' still in bit? JNB rxBit, ISR_Exit ' in idle period? CLRB rxBit ' no, clear bit flag CJA bitCount, #0, Test_DBit ' start or data bit? Test_SBit: CJA bitWidth, #74, Next_Bit ' proper start bit? CLR rxCmd ' no, reset JMP ISR_Exit Test_DBit: CLC RR cmdWork ' prep for next bit CJB bitWidth, #34, Next_Bit ' "1" bit? SETB cmdWork.6 ' yes, set it Next_Bit: CLR bitWidth ' clear for next bit INC bitCount ' update count CJB bitCount, #8, ISR_Exit ' done? SETB hasCmd ' set available flag MOV cmdCode, cmdWork ' copy work to output CLRB rxCmd ' clear rx flag JMP ISR_Exit Update_BitWidth: INC bitWidth ' else inc width SETB rxBit ' refresh in bit flag ENDASM ISR_Exit: RETURNINT 104 ' 26 uS @ 4 MHz ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=102740#m102864 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2005 (http://www.dotNetBB.com)