Menu

Problem loading bit setting with variable

Help
2007-03-19
2013-05-30
  • Nobody/Anonymous

    'Dear sirs, I intend to load the remote control stream of bits into CM variable and I don't know why
    'I get only "8", no matter of button I press. Verify if I can't use a variable istead of 0-7 in sustitution
    'of bit in a variable.
    'If every things were OK, I would get the command byte of every key in remote control in CM variable
    'Instead I'll get an "8" every time. I suspect that I can't use variables in bit setting, but, why not!

    'NOTE: as you will see, I use 2 line LCD, is fantastic for testing.                                                                                       
    'I use a RCA SYSTEMLINK 4 remote control with NEC TV code 003

          #chip 12F675, 4 
          #config BODEN_OFF, MCLRE_OFF, INTRC_OSC_NOCLKOUT
          ADOff

         #Define LCD_IO 2             ' Two line LCD
         #Define LCD_DB GPIO.1   ' Data Bit
         #Define LCD_CB GPIO.2   ' Clock Bit

          dim ik as byte 
          dim CM as byte
          dir gpio b'00001000'
          CM = 0

          GetBits:
          while gpio.3 = 1 : wend                                 'wait the remote stream
          for ik = 0 to 7                                         'I need 8 bits word
             while gpio.3 = 0 : wend                              'I don't need 0 bits because It have it
             while gpio.3 = 1 : SET CM.IK ON : wend               'flip ik bit in CM
          next                           

          cls
          LCDint CM
          wait 250 ms
          goto GetBits
      
          end

                                     ' Pablo Curvelo S.

     
    • Stefano Bonomi

      Stefano Bonomi - 2007-03-20

      You can use Rotate instruction to obtain what you need. Your routines will be:

      GetBits:
      while gpio.3 = 1 : wend 'wait the remote stream
      for ik = 0 to 7 'I need 8 bits word
      while gpio.3 = 0 : wend 'I don't need 0 bits because It have it
      while gpio.3 = 1 : wend 'flip ik bit in CM
      set CM.7 ON
      rotate CM Right Simple
      next 

      I really don't understand what your code do; first of all it pause until gpio.3 becomes ON and then sets the corresponding bit to 1.
      If I am right, at the end you will always have an FF or 11111111 value in your CM variable.....

      Greetings

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.