Shop OBEX P1 Docs P2 Docs Learn Events
Data output problems — Parallax Forums

Data output problems

JWoolstonJWoolston Posts: 4
edited 2008-03-27 05:41 in Propeller 1
I have a board with a number of I2C devices on two seperate busses. To test the communication, I have LEDs that can blink code the data out, one that signals data valid, the other that signals the data bit. I am testing it on the demo board with the boot eeprom using a stripped down version of i2cdemoApp from the object exchange. To compare, I am using its serial output through the terminal in the basic stamp environment. The problem is the binary numbers blinked out by the leds dont match the binary numbers on the terminal, and I cant understand why? I have included the code for the eeprom demo method, the only one i modified. I did make sure that the led output pins are set as outputs. Could someone shed some light?

PRI EEPROM_Demo | eepromData, eepromLocation, ackbit, i 
' demo the i2c Serial EEPROM (Microchip's 24LC512 (64kb)) 
debug.strln(string("EEPROM DEMO")) 

' ***** EEPROM read/Write example ***** 
eepromLocation := EEPROM_Base 
eepromData := 0 

repeat 10 
'' write long 
'eepromData += 100 
'i2cObject.WriteLong(i2cSCL, EEPROMAddr, eepromLocation, eepromData) 
' read long 
eepromData :=0 
eepromData := i2cObject.ReadLong(i2cSCL, EEPROMAddr, eepromLocation) 
' debug 
debug.str(string("Read Location=")) 
debug.decx(eepromLocation,5) 
debug.str(string(", data=")) 
debug.bin(eepromData,32) 
debug.putc(13) 
repeat i from 0 to 31 
outa[noparse][[/noparse]22] := 1 
outa[noparse][[/noparse]16] := eepromData[noparse][[/noparse]31-i] 
waitcnt(clkfreq + cnt) 
outa[noparse][[/noparse]22] := 0 
outa[noparse][[/noparse]16] := 0 
waitcnt(clkfreq/2 + cnt) 

' next 
eepromLocation +=4 
' slowit 
waitcnt(clkfreq + cnt) 

' done 
debug.strln(string("EEPROM demo done.")) 


·Thanks,

Jared
·

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-03-27 04:00
    The subscript notation used in "eepromData[noparse][[/noparse] 31-i ]" causes array access with "eepromData" assumed to be a 32 byte array. You may have confused this with the same notation applied to certain specific I/O registers like OUTA / OUTB / DIRA / DIRB / INA / INB which accesses specific bits or groups of bits. Try using "eepromData >> (31 - i)" instead.
  • JWoolstonJWoolston Posts: 4
    edited 2008-03-27 05:41
    thanks for the help mike, it works as expected now

    Jared
Sign In or Register to comment.