| Posted: 10:02am 10 Jun 2025 |
|
|
|
Cutdown version.' 24C32 EEPROM tester 3.bas ' Test program to fill 4 pages of a 24C32 EEPROM. Dim Integer n, m, dummy, I2C.addr, Mem.addr Dim D$, R$, txt$
For n = &H50 To &H58 'find the I2C address I2C CHECK n If Not MM.I2C Then ' test for slave response. 1 = no response I2C.addr = n Print "I2C.addr = &H";Hex$(I2C.addr), EndIf Next Print
' Write to 4 32 byte pages on 24C32 EEPROM Print "Writing to EEPROM. Page 0 = 32 0s to page 3 = 32 3s."
For n = 0 To 3 'make 32 byte pages Mem.addr = n * 32 'set the memory pointer D$="" For m = 0 To 31 : Inc D$, Str$(n) : Next 'make a page D$ = Chr$(Mem.addr>>8) + Chr$(Mem.addr And 255) + D$ 'Add 2 byte Mem. address to the start of the Data' I2C WRITE I2C.addr,0,Len(D$),D$ 'write 2 memory address bytes + data bytes Print Right$(d$,32); 'show the pages written Pause 6 'allow time to write Next
Print :Print :Print "Data read from EEPROM" Read_24C32_All
Sub Read_24C32_All ' Read all data from 24C32 EEPROM I2C WRITE I2C.addr, 0, 2, 0, 0 'return the pointer to 0 I2C read I2C.addr, 0, 128, R$ 'print all data, 4 pages per line, showing non-ASCII characters as "." Print R$ End Sub
End Output> RUN &H50 Writing to EEPROM. Page 0 = 32 0s to page 3 = 32 3s. 00000000000000000000000000000000111111111111111111111111111111112222222222222222222222222222222233333333333333333333333333333333
Data read from EEPROM 00000000000000000000000000000000111111111111111111111111111111112222222222222222 > Edited 2025-06-10 20:09 by phil99 |