eeprom command within case structure

mjy58

Member
Just modified some code to save data into eeprom so it can be used between power downs and go this compiler error:

eeprom 112,(4)
^
Error: EEPROM cannot be used within If blocks

This looks fairly fatal for this construct. Couldn't find it documented anywhere, is there any way round it?

Extract of relevant code:
Code:
if verify < 14 then                
    tagno=tagposition/14+1
    select case tagno
          case 1
          .
          .                    
    end select
    select case tagno    
    case 1,3
    .
    .
                        
    case 2,4                        
    .
    .
    case 5                            
    .
    .
    case 6                        
        dfeedcountlimit = foursecs / dmotortime
        eeprom 112,(4)
        cfeedcountlimit = sixsecs / cmotortime
        eeprom 113,(6)
        high Feed                
        pause onesec            
        inctime = inctime + 1        
        low feed                
    end select
endif
 

nick12ab

Senior Member
The eeprom command only writes data to EEPROM when the program is downloaded - to write data to EEPROM at runtime you must use the write command. You then need to use the read command at startup to retrieve the saved value.
 

mjy58

Member
The eeprom command only writes data to EEPROM when the program is downloaded - to write data to EEPROM at runtime you must use the write command. You then need to use the read command at startup to retrieve the saved value.
Thanks Nick, I had used read earlier, but somehow forgot about write:eek:

Malcolm
 
Top