News:

Let's find out together what makes a PIC Tick!

Main Menu

EREAD command

Started by CPR, Today at 08:10 AM

Previous topic - Next topic

CPR

Hi all, I have a string of bytes stored in EEPROM (PIC 18F26K22) To place them there I used a for next loop with Ewrite.

I'd dearly love to recover them in a similar manner using Eread. But it looks as if Eread isn't happy to accept a variable as it's argument?

I'd like to do this -

For i = 0 To 30                 
    stemp = stemp + Eread i                                                       
Next i

But the compiler errors with "inline commands not supported at this position"

Can anyone suggest an alternate method I can use to the above code? Or am I missing something obvious?

trastikata

#1
For i = 0 To 30   
    bTemp = Eread i           
    stemp = stemp + bTemp                                                 
Next

===================

However I prefer this way:

Dim sString As String * 30
Dim bCounter As Byte

Clear sString
For bCounter = 0 To 29
    sString[bCounter] = ERead bCounter
Next

==========================

if there's an offset, you can modify it like this:

Dim sString As String * 30
Dim bCounter As Byte
Dim bOffset As Byte

Clear sString
bOffset = 40
For bCounter = 40 To 69
    sString[bCounter - bOffset] = ERead bCounter
Next

CPR

Thank you Trastikata that works perfectly. Now I feel quite stupid - but on the positive side - I've learnt something. Onward and sideways! ;D