Menu

Help with arrays

Help
2010-05-13
2013-05-30
  • Nobody/Anonymous

    Hello.
    I seem to have trouble with compiling the code below;
    It is just a simple increment loop with arrays involved, it outputs

    Error in EEADRINC at 1: Array/Function EEADR has not been declared
    Error in EEADRINC at 1: Invalid variable name: EEADR(0)
    Error in EEADRINC at 2: Array/Function EEADR has not been declared
    Error in EEADRINC at 2: Invalid variable name: EEADR(1)
    Error in EEADRINC at 3: Array/Function EEADR has not been declared
    Error in EEADRINC at 3: Invalid variable name: EEADR(1)
    Error in EEADRINC at 4: Array/Function EEADR has not been declared
    Error in EEADRINC at 4: Invalid variable name: EEADR(0)
    Error in EEADRINC at 6: Array/Function EEADR has not been declared
    Error in EEADRINC at 6: Invalid variable name: EEADR(0)
    Error in EEADRINC at 7: Array/Function EEADR has not been declared
    Error in EEADRINC at 7: Invalid variable name: EEADR(1)
    Error in EEADRINC at 8: Array/Function EEADR has not been declared
    Error in EEADRINC at 8: Invalid variable name: EEADR(0)
    

    Below is the code used:

    ;Chip Settings
    #chip 16F88,0.5
    #config MCLR=OFF, OSC=INTRC_IO
    ;Defines (Constants)
    #define WREN 6
    #define WRITE 2
    #define RDSR 5
    #define READ 3
    ;Variables
    Dim EEADR(2)
    Dim i As byte
    Dir PORTA.0 OUT
    Dir PORTB.0 OUT
    DIR PORTB.1 IN
    DIR PORTB.2 OUT
    DIR PORTB.4 OUT
    Set PortB.0 Off
    SPIMode MasterFast
    Set PortB.0 On
    'Main
    loop:
    EEADRINC
    Wait 1 s
    goto loop
    Sub EEADRINC
        EEADR(0) = EEADR(0) + 1
        If EEADR(1) = 255 Then
            EEADR(1) = 0
            EEADR(0) = 0
        End If
        If EEADR(0) = 255 Then
            EEADR(1) = EEADR(1) + 1
            EEADR(0) = 0
        End If
    End Sub
    
     
  • gcha44

    gcha44 - 2010-05-13

    Hi,
    I think you must try to give another name for your array < EEADR(2) >
    and for <WREN> you define as constant 6
    Indeed , if you look at  eeprom.h in "GCBASIC / include / low level "   you'll notice that EEADR is already defined as ALIAS
    In 16F88 chipdata , EEADR is 269
    Likewise WREN is EECON1,2E !
    Then , the compiler gets confused !
    GC

     
  • Nobody/Anonymous

    Thanks a lot, I seem to have unconsciously chosen those names.
    WREN was the instruction name for Write in the 25LC256 EEPROM, so I had chosen that. EEADR, well shorter term for EEPROM's address.
    Thanks again for digging those up.

     

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.