In SX Microcontrollers, SX/B Compiler and SX-Key Tool, Rsadeika wrote: Here is my latest code for the remote control program. I am having problems getting the get bits part to work. For some reason it's not getting the corect bits, or no bits at all. I guess it nust be something simple that I am not seeing. Any corrections would be appreciated. *****code ' ========================================================================= ' ' File...... Test1.sxb ' Purpose... SX/B Programming Template ' Author.... ' E-mail.... ' Started... ' Updated... ' ' ========================================================================= ' ------------------------------------------------------------------------- ' Program Description ' ------------------------------------------------------------------------- ' ------------------------------------------------------------------------- ' Device Settings ' ------------------------------------------------------------------------- DEVICE SX28, OSC4MHZ, TURBO, STACKX, OPTIONX FREQ 4_000_000 ' ------------------------------------------------------------------------- ' IO Pins ' ------------------------------------------------------------------------- ' ------------------------------------------------------------------------- ' Constants ' ------------------------------------------------------------------------- ' ------------------------------------------------------------------------- ' Variables ' ------------------------------------------------------------------------- led1 var rb.0 irpin var rc.0 irpulse var byte temp1 var byte idx var byte ' ------------------------------------------------------------------------- INTERRUPT ' ------------------------------------------------------------------------- ISR_Start: ' ISR code here ISR_Exit: RETURNINT ' {cycles} ' ========================================================================= PROGRAM Start ' ========================================================================= ' ------------------------------------------------------------------------- ' Subroutine Declarations ' ------------------------------------------------------------------------- ledon sub getcode sub processcode sub 1 gofore sub ' ------------------------------------------------------------------------- ' Program Code ' ------------------------------------------------------------------------- Start: do ledon 'Turn on LED getcode processcode temp1 'goto stop loop getcode: pause 1000 'Turn on LED, to make sure I got here ledon do pulsin irpin, 0, irpulse loop while irpulse < 240 'Does not work with 220 'Get bits temp1 = 0 'Temp1 is a byte, 8 bits long for idx = 1 to 8 'Step through eight times temp1 = temp1 >> 1 'Right shift by one pulsin irpin, 0, irpulse 'Get the pulse if irpulse > 120 then '1.2 ms = binary 1, 0.6 ms = binary 0 temp1 = 1 'Store value in bit space ?? else temp1 = 0 'Store value in bit space ?? endif next 'Next bit 'irpulse = temp1 'if irpulse < 10 then 'irpulse = irpulse + 1 'endif 'if irpulse = 10 then 'irpulse = 0 'endif return temp1 processcode: irpulse = temp1 if irpulse = 16 then ' If ChUp button was pushed gofore 'Turn on the LED endif return ledon: tris_b=0 led1 = 0 pause 1000 led1 = 1 return gofore: pause 1000 'Turn on LED to make sure I got here ledon return stop: sleep ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=97532#m97871 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)