Ooops, sorry. Just saw that the write procedure *does* wait for the write to 
complete. Waiting after issuing the write command is a little inefficient, 
however. The jallib library waits *before* each eeprom read or write for a 
possible previous write to complete. That means, when a single byte is written, 
no wait is needed at all. In extreme cases, the write can take as long as 64000 
machine instructions, so the time might be worth saving ;-)

Looking again at your code it seems to be correct after all. Can you read out 
the data eeprom using your programmer, to find out if the write or the read 
fails?

Greets,
Kiste




________________________________
 Von: Oliver Seitz <[email protected]>
An: "[email protected]" <[email protected]> 
Gesendet: 7:03 Montag, 24.Februar 2014
Betreff: Re: [jallib] read / write eeprom 18f452
 


Hi!

The problem might be, that you don't wait for the last write to finish the 
hardware internal programming sequence, before issuing another write.

Try using the pic_data_eeprom.jal library from the jallib package, it has all 
the safety measures included.

Greets,
Kiste





________________________________
 Von: phil heintz <[email protected]>
An: [email protected] 
Gesendet: 17:50 Sonntag, 23.Februar 2014
Betreff: [jallib] read / write eeprom 18f452
 


Hello

I try to store some datas in the 18f452 EEPROM, but I have this bug:

18F452 lib is: from jal 0.9.0

include 18f452   -- target PICmicro
pragma target clock 10_000_000           -- oscillator frequency
-- configuration settings (fuses)
pragma target OSC      HS                    -- HS crystal or resonator
pragma target WDT      disabled            -- no watchdog
pragma target
 DEBUG    disabled          -- no debugging
pragma target LVP      disabled             -- no Low Voltage Programming
pragma target PWRTE    enabled          -- pwr-up timer on: 72ms   (p197)
pragma target BROWNOUT enabled      -- brown-out reset on      (p197)
pragma target VOLTAGE  v42                -- brown-out reset at 4.2v (p197)
T0CON= 0b_0000_0111                         --TMR0=OFF/ 16bit / prescaler=1/256 
 debord 6,7s
INTCON= 0b_1110_1000                        --enable
 interupt: tmr0, RB port change
ADCON0= 0b_0000_0000                     --disable ADC
ADCON1= 0b_0000_0111                     --digital I/O
-------------------------------------------------------------------------------------------------------------------------------------------
The eeprom library: 

procedure eeprom_w(byte in Address, byte in Data) is
   assembler
        bank movf Address,w         ;
        movwf EEADR                  ; load memory address
        bank movf Data,w       
       ;
        movwf EEDATA                 ; Data to write in eeprom
        bcf  EECON1_EEPGD       ; Point to DATA memory
        bcf  EECON1_CFGS         ; Access program FLASH or Data EEPROM memory
        bsf  EECON1_WREN        ; Enable writes
        bcf  INTCON_GIE              ; Disable interrupts
        bcf  INTCON_GIE              ; Again, according to Josef
        movlw
 0x55                       ;
        movwf EECON2                ; Write 55h
        movlw 0xAA                      ;
        movwf EECON2                 ; Write AAh
        bsf  EECON1_WR             ; Set WR bit to begin write
        nop                                  ; Two nops, according to
 Stef
        nop
        bsf INTCON_GIE               ; Enable interrupts
        bcf EECON1_WREN         ; Disable writes on write complete (EEIF set)
  end assembler
  while EECON1_WR loop end loop ; wait for write completion
end procedure


-- --------------------------------------------------------------------
-- reading of Data-EEprom
-- --------------------------------------------------------------------
procedure eeprom_r( byte in Address, byte out Data ) is
  assembler
        bank movf Address,w         ;
        movwf EEADR            
      ; Data Memory Address to read
        bcf EECON1_EEPGD        ; Point to DATA memory
        bcf EECON1_CFGS          ; Access program FLASH or Data EEPROM memory
        bsf EECON1_RD               ; EEPROM Read
        movf EEDATA,w                ; w = EEDATA
        bank movwf Data               ; w -> Data
  end assembler
end procedure


Here is my program test:
eeprom_w (0,0)   --write data=0 at address 0
eeprom_w (1,1)
eeprom_w (2,2)
eeprom_w
 (3,3)

eeprom_r(0,x1),     ( x1,x2,x3,x4  are deffined as byte)
eeprom_r(1,x2)
eeprom_r(2,x3)
eeprom_r(3,x4)

serial_sw_write(x1)
serial_sw_write(x2)
serial_sw_write(x3)
serial_sw_write(x4)

And monitoring thre result with via MicTerm, I have: "3333"

Perhaps somebody could give me a way to understand?

Thanks in advance 
Phil


-- 
You received this message because you are subscribed to the Google Groups 
"jallib" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/jallib.
For more options, visit https://groups.google.com/groups/opt_out.



-- 
You received this message because you are subscribed to the Google Groups 
"jallib" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/jallib.
For more options, visit https://groups.google.com/groups/opt_out.

-- 
You received this message because you are subscribed to the Google Groups 
"jallib" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/jallib.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to