Menu

Cannot use binary numbers in table

2018-06-19
2018-06-20
  • Robert Rioja

    Robert Rioja - 2018-06-19

    This works:
    Table MyTable as byte
    2
    End Table

    This does not work:
    Table MyTable as byte
    0b00000010
    End Table

    The table item is always read as 0. Can anyone tell me why?

    Thanks,
    Robert

     
  • Anobium

    Anobium - 2018-06-19

    Not sure. The following works here.

    #chip 16F628
    
        'Read table item
        'Must use ReadTable and a variable for the index, or the table won't be
    '    downloaded to EEPROM
    
        TableLoc = 2
        ReadTable TestDataSource, TableLoc, SomeVar
    
        'Write to table , this is not required
        EPWrite 1, 45
    
        'Table of values to write to EEPROM
        'EEPROM location 0 will store length of table
        'Subsequent locations will each store a value
    
        Table TestDataSource Store Data
            12
            0b00000010
            36
            48
            60
            72
        End Table
    

    This generatesa table as expected.

    TableTESTDATASOURCE equ 0
      de  6, 12, 2, 36, 48, 60, 72
    
     END
    

    So, version of compiler please. Post your actual code. I think you have not shared the error, what is happening that is not expected.

    More inormation please.

     
  • stan cartwright

    stan cartwright - 2018-06-20

    This prints 2's

        #chip mega328p,16
        #option explicit
        #define USART_BAUD_RATE 9600
        #define USART_TX_BLOCKING
        #define USART_DELAY 10 ms
    
    dim temp as byte
    do
        readtable mytable,1,temp
        HSerPrint str(temp)
    loop
    
    table MyTable as byte
        0b00000010
    End Table 
    

    edited do but same results
    I think @Robert uses a uno from other posts

     

    Last edit: stan cartwright 2018-06-20

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.