In SX Microcontrollers, SX/B Compiler and SX-Key Tool, Rsadeika wrote: Listed below is the JW SIRC program (IR remote control). The problem that I am encountering is that when I hook up the IR detector to any pin on the C port, the program does not behave as expected, IR detector does not respond. If I hook up the IR detector to any pin on port a or b, the program works as expected. I discovered the ?problem? while working on the I2C/UART dev board, then I checked it out on the SX28 tech board, same outcome. So, the question is, why does it not work on port c, but it works on port a and b. Since I am not using an SX48/52, I did not check out port d and e. Basically, is this a software problem or a hardware problem. I tried to decipher the asm part of the program to see if this was the problem, I did not have any luck. Maybe one of the asm pros can see something that I missed. Or is it simply that port c does not handle that kind of input. I thought that all ports were created equal in the basic configuration. If somebody makes the discovery, a clear and explicit explanation would be very appreciated. Thanks Ray ' ========================================================================= ' ' File...... XGbot.SXB ' Purpose... ' Author.... R Sadeika ' E-mail.... ' Started... ' Updated... ' ' ========================================================================= ' ------------------------------------------------------------------------- ' Program Description ' ------------------------------------------------------------------------- ' ------------------------------------------------------------------------- ' Device Settings ' ------------------------------------------------------------------------- DEVICE SX28, OSC4MHZ, TURBO, STACKX, OPTIONX FREQ 4_000_000 ' ------------------------------------------------------------------------- ' IO Pins ' ------------------------------------------------------------------------- 'IR VAR RB.7 IR var rb.7 ' ------------------------------------------------------------------------- ' Constants ' ------------------------------------------------------------------------- Power con 21 ChUp con 16 ChDn con 17 VolUp con 18 VolDn con 19 ' ------------------------------------------------------------------------- ' 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 ' ------------------------------------------------------------------------- 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 ' ========================================================================= PROGRAM Start ' ========================================================================= ' ------------------------------------------------------------------------- ' Subroutine Declarations ' ------------------------------------------------------------------------- LED1 sub ProcessCode sub Stop sub GoFore sub GoBack sub LF sub LB sub RF sub RB1 sub ' ------------------------------------------------------------------------- ' Program Code ' ------------------------------------------------------------------------- Start: ' initialization code here PLP_A = %0000 ' pull-up unused pins PLP_B = %00000000 TRIS_C = %00000000 ' make LED pins outputs OPTION = $88 ' interrupt, no prescaler Main: IF hasCmd = 0 THEN Main ' wait for new code ProcessCode hasCmd = 0 GOTO Main end ' ------------------------------------------------------------------------- ' Subroutine Code ' ------------------------------------------------------------------------- ProcessCode: IF cmdCode = Power then Stop 'Power = Stop IF cmdCode = ChUp then GoFore IF cmdCode = ChDn then GoBack IF cmdCode = VolUp then LED1 IF cmdCode = VolDn then LED1 IF cmdCode = 0 then LF IF cmdCode = 3 then LB IF cmdCode = 1 then RF IF cmdCode = 4 then RB1 return Stop: HIGH rc.3 'Wire 5 Red LS M1 HIGH rc.2 'Wire 6 Yellow LS M1 HIGH rc.1 'Wire 7 Black RS M2 HIGH rc.0 'Wire 8 White RS M2 return GoFore: LOW rc.3 'Wire 5 LS LOW = 0 HIGH rc.2 'Wire 6 LS HIGH = 1 HIGH rc.1 'Wire 7 RS LOW rc.0 'Wire 8 RS return GoBack: HIGH rc.3 'Wire 5 LS LOW rc.2 'Wire 6 LS LOW rc.1 'Wire 7 RS HIGH rc.0 'Wire 8 RS return LF: LOW rc.3 HIGH rc.2 return LB: HIGH rc.3 LOW rc.2 return RF: HIGH rc.1 LOW rc.0 return RB1: LOW rc.1 HIGH rc.0 return LED1: ' HIGH rb.2 HIGH rb.0 pause 2000 ' LOW rb.2 LOW rb.0 return ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=115428 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)