Help for this page

Select Code to Download


  1. or download this
        |<--------- 16-bit config register ---------->|
        |                             |               |
    ...
        START    |       |      UNUSED      DATA
              CHANNEL    |
                      PIN SELECT
    
  2. or download this
        15:     Start conversation
                 0 - do nothing
    ...
        10-8:   Unused (Don't care bits)
    
        7-0:    Data
    
  3. or download this
        my $data = bit_on(0, 15);
    
  4. or download this
        say bit_count($data);
        say bit_bin($data);
    
  5. or download this
        16
        1000000000000000
    
  6. or download this
        # setting channel
    
        $data = bit_set($data, 13, 2, 0b11);
    
        # result: 1110000000000000
    
  7. or download this
        # setting pin
    
        $data = bit_set($data, 11, 2, 0b01);
    
        # result: 1110100000000000
    
  8. or download this
        # setting data
    
    ...
        # or: bit_set($data, 0, 8, 0b10111010);
    
        # result: 1110100010111010
    
  9. or download this
        $data = bit_off($data, 14);
    
        # result: 1010100010111010
    
  10. or download this
        my $value = bit_get($data, 15, 15);
        say bit_bin($value);
    
        # result: 1
    
  11. or download this
        # data
    
    ...
        # ensure the unused bits weren't set
    
        say bit_get($data, 10, 8);
    
  12. or download this
    
    # use a binary number directly:
    ...
    # convert a number to a binary string, and assign it
    
    my $bin = sprintf("%b", 127); # 1111111