Shop OBEX P1 Docs P2 Docs Learn Events
Need help with this code. Trying to write/read from eeprom. — Parallax Forums

Need help with this code. Trying to write/read from eeprom.

I think I'm losing my mind over this. I used to be able to make this sort of thing work but now I can't.

I'm using Prop Proto board with AT512 eeprom (64K). I've also tried it on some other boards of mine that use a 64K eeprom.

I get 255 FF on the terminal display.

Help!
CON

  _clkmode        = xtal1 + pll16x                       ' Feedback and PLL multiplier   For Ver 2.0
  _xinfreq        = 5_000_000                          ' External oscillator = 10 MHz  For Ver 2.0
  
  MS_001   = 80_000_000 / 1_000

  EE_SCL = 28
  EE_SDA = 29

  EE_DEV_ADDR   = $A0                                  ' EEPROM assigments
  EE_BASE_ADDR  = $8000

VAR
  byte  credit
   
OBJ
  i2c      : "jm_i2c_driven"
  term     : "FullDuplexSerialDP_1"
  
PUB start

  term.start(31, 30, %0000, 115_200)                    ' start terminal using PST
  pause(1000)                                           ' pause for PST

  term.str(string("EEPROM Testing", 13))

  i2c.init(EE_SCL, EE_SDA)

  pause(1000)

  i2c.putbyte(EE_DEV_ADDR, EE_BASE_ADDR, $3F)

  pause(1000)
  
  credit := i2c.getbyte(EE_DEV_ADDR, EE_BASE_ADDR)

  term.dec(credit)
  term.tx(32)
  term.hex(credit, 2)


pub pause(ms) | t

  t := cnt
  repeat ms
    waitcnt(t += MS_001)

Comments

Sign In or Register to comment.