how to access and set bits in a byte array?


Results 1 to 10 of 10

Threaded View

  1. #9
    Join Date
    May 2013
    Location
    australia
    Posts
    2,651


    Did you find this post helpful? Yes | No

    Default Re: how to access and set bits in a byte array?

    out of curiosity I had a look at what happens when you access an array just by using its name with no index []
    and pbp addresses the first var in the array as the type of var specified in the array declaration .
    I would not recommend the practice though

    Code:
    ****************************************************************
    '*  Name    : UNTITLED.BAS                                      *
    '*  Author  : [select VIEW...EDITOR OPTIONS]                    *
    '*  Notice  : Copyright (c) 2014 [select VIEW...EDITOR OPTIONS] *
    '*          : All Rights Reserved                               *
    '*  Date    : 7/2/2014                                          *
    '*  Version : 1.0                                               *
    '*  Notes   : 16f1825                                                 *
    '*          :                                                   *
    '****************************************************************
                                
    #CONFIG
       __config _CONFIG1, _WDTE_ON    & _FOSC_INTOSC   &_MCLRE_ON    &_PWRTE_ON 
       __config _CONFIG2,              _LVP_OFF 
    #ENDCONFIG
    
    
     
     
     
          DEFINE OSC 32
     
       osccon=$70    '32 mhz
             anselA=0        'dig i/o 
             ANSELC=0
          
           TRISA= %11111110
         APFCON0.7=0
                 
               
                  so var porta.0
    so=1
    pause 4000 
                 
                 myarry var word[8]
     
       myarry[0]=$ffff 
       myarry[1]=$ffff  
       serout2 so,84,[ "ready ",13,10]      
       main:      
        pause 4000       
       
        
       
        
        serout2 so,84,[ #myarry[0]," ",#myarry[1],13,10] 
        
        
       
        
        myarry=0
        
        serout2 so,84,[ #myarry[0]," ",#myarry[1],13,10]  
      goto main
    result

    ready
    65535 65535
    0 65535
    Last edited by richard; - 14th September 2014 at 03:35. Reason: clean up code

Similar Threads

  1. How do I check (or set) a group of consecutive bits within a byte?
    By HankMcSpank in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 2nd April 2012, 08:13
  2. Problem with bits in byte array....
    By HenrikOlsson in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 19th October 2011, 06:27
  3. Access array in PBP and .asm
    By JEC in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 6th September 2008, 00:35
  4. reading first four bits of a byte
    By kamet in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 2nd January 2007, 08:50
  5. Word array behaving like byte array.... wierd
    By forgie in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 2nd August 2005, 15:43

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts