PICAXE 08M2 using a 24LC16B EEPROM
This is a DEMO of a PICAXE 08M2 using a 24LC16B EEPROM I2C memory
The 128x64 OLED 0.96 inch white display is also connected via the I2C bus. Uses a SSD1315 controller chip.
The program first writes a font array to the memory, then reads it back, displaying the stored data as a HEX dump on the OLED.
This code will be part of a library of functions to create more advanced microcontroller projects.
Photos





Figure
109PICAXE 08M2+ using a 24LC16B EEPROM

Figure
110Close-up of HEX dump on OLED display

Figure
111OLED radioSPARKS Logo Display. Needs 1kB of EEPROM.

Figure
112OLED radioSPARKS Mascot (Don't have a name for it)

Figure
113OLED radioTINKER Logo of my other web site.

Photo is for illustrative purposes only. Please refer to the description.
Code Sample
To copy code:
Hover over the right top corner of the code panel.
Click COPY button, the code will be COPIED to the clipboard.
; ------------------------------------------------------------------------------
; I2C EEPROM Memory Write/Read Test PICAXE 08M2+
; for 24LC16B 8 Pages of 256 Bytes (2kB)
; PAGE Buffer = 16 Bytes
; --------------------------------------------------- ---------------------------
; rhb.20230620
; Erase Entire Memory - working
; Write BIG Number Array - working 8)
; ------------------------------------------------------------------------------
; InitialiseOLED, 8X16 BIGNUMBER array, 6X8 ASCII array - rhb.20230623
; by radioSPARKS
; ------------------------------------------------------------------------------
; ------------------------------------------------------------------------------
; Compiler Directives
; ----------------------- -------------------------------------------------------
#PICAXE 08M2 ; Target MCU
;#no_data ; Do not download data EEPROM values
#simspeed 0
; ---------------------------------------------------------------------- --------
; Symbol Constants
; ------------------------------------------------------------------------------
symbol PULLUPS = %1100 ; %1100 for 08M2
; %11000 for 14M2
; %10100000 for 20M2
symbol WR ITEDELAY = 5 ; ms at 4 MHz ?
symbol RAM_STACK_TOP = $1C ; STACK TOP
symbol OLED_COMMAND = $00 ; This is a Command start -- Commands are preceeded by a zero(0) filled byte
symbol OLED_DATA = $40 ; 01000000 (C/O = 0, D/C = 1) -- Not a command, but data follows
symbol I2CSPEED = I2CFAST ; I2CSLOW / I2CFAST
symbol RAM_STACK = $1C ; STACK TOP
symbol EEPROM_ADDR = $A0 ; PAGE 0 EEPROM - MAP other pages shift left - 0-7 * 2 OR
symbol SSD13 06_ADDR = $78 ; This is the I2C address $3C << 1 [$78]
; Slave Write Address: $3C/$78 : bit 0 = 0
; Slave Read Address : $3D/$7A ; bit 0 = 1
symbol SSD1306_WIDTH = 128
symbol SSD1306_HEIGHT = 64 ; 32 for 128 x32 display : 64 for 128x64 display
symbol SSD1306_PAGES = SSD1306_HEIGHT / 8 ; 4 pages for 32 : 8 pages for 64
symbol SSD_1306_GDRAM = SSD1306_WIDTH * SSD1306_PAGES
symbol SSD1306_SETCONTRAST = $81
symbol contrastVal = $8F ; $ 8F for 32 : $CF for 64
symbol SSD1306_DISPLAYALLON_RESUME = $A4
symbol SSD1306_DISPLAYALLON = $A5
symbol SSD1306_NORMALDISPLAY = $A6
symbol SSD1306_INVERTDISPLAY = $A7
symbol SSD1306_DISPLAYOFF = $AE
symbol SSD1306_DISPLAYON = $AF
symbol SSD1306_SETDISPLAYOFFSET = $D3 ; (RESET $00)
symbol SSD1306_SETCOMPINS = $DA
symbol comPinsVal = $12 ; $02 for 32 : $12 for 64
symbol SSD1306_SETVCOMDETECT = $DB ; VCOMH Select Voltage Level (RESET $20)
symbol SS D1306_SETDISPLAYCLOCKDIV = $D5
symbol SSD1306_SETPRECHARGE = $D9
symbol SSD1306_SETMULTIPLEX = $A8
symbol SSD1306_MULTIPLEXVALUE = SSD1306_HEIGHT - 1 ; for display height : $3F = 63 : $1F = 31
symbol SSD1306_SETLOWCOLUMN = $00
symbol SSD1306_SETHIGHCOLUMN = $10
symbol SSD1306_SETSTARTLINE = $40
symbol SSD1306_MEMORYMODE = $20 ; RAM Memory Address Mode (RESET = $02)
; $00, Horizontal Addressing Mode
; $01, Vertical Addressing Mode
; $02, Page Addressing Mode (RESET)
symbol SSD1306_COLUMNADDR = $21 ; Column Range 0 to 127
symbol SSD1306_PAGEADDR = $22 ; Page Range 0 to 7
symbol pageEndAddr = SSD1306_PAGES - 1 ; 7 for 64 : 3 for 32
symbol SSD1306_COMS CANINC = $C0
symbol SSD1306_COMSCANDEC = $C8
symbol SSD1306_SEGREMAP = $A0 | 1
symbol SSD1306_CHARGEPUMP = $8D
symbol SSD1306_EXTERNALVCC = $1
symbol SSD1306_SWITCHCAPVCC = $2
symbol SCREENCLEAR = SSD_1306_GDRAM / 16
; Scrolling symbols - not used
symbol ACTIVATE_SCROLL = $2F
symbol DEACTIVATE_SCROLL = $2E
symbol SET_VERTICAL_SCROLL_AREA = $A3
symbol RIGHT_HORIZONTAL_SCROLL = $26
symbol LEFT_HORIZONTAL_SCROLL = $27
symbol VERT_AND_RIGHT_HO RIZONTAL = $29
symbol VERT_AND_LEFT_HORIZONTAL = $2A
; ------------------------------------------------------------------------------
; Symbol Register Variables
; ------------------------------------------------------------------------------
; b0-b3 are re-used for temporary loops
symbol i = b0
symbol j = b1
symbol k = b2
symbol m = b3
symbol t1 = b15
symbol t2 = b16
symbol t3 = b17
symbol t4 = b18
symbol t5 = b19
symbol STACK_PTR = b20 ; RAM_STACK
symbol ADDR_PTR = b22
symbol temp = b4
symbol tempb = b5
symbol tempw = w3 ; word = b7 : b6
symbol row = b8
symbol col = b9
symbol char = b10
symbol subchar = b11
symbol aBYTE = b12
symbol index = b13
symbol rowptr = b14
symbol maxvar = b27
maxvar = 99
symbol i2cdata = b0
symbol PAGE = b26
symbol ADDR = b27
symbol NU MIDX = b24
symbol FILL = b23
symbol PAGESELECT = b21
symbol MeMADDR = $50 * 2 ; byte shift left
; Memory 256 Byte Page
symbol MeMPage_0 = MeMADDR
symbol MeMPage_1 = MeMADDR | $02 ; set page address bits
symbol MeMPage_2 = Me MADDR | $04
symbol MeMPage_3 = MeMADDR | $06
symbol MeMPage_4 = MeMADDR | $08
symbol MeMPage_5 = MeMADDR | $0A
symbol MeMPage_6 = MeMADDR | $0C
symbol MeMPage_7 = MeMADDR | $0E
; NOTE: SCL C.1 and SDA C.2 weak pullup required if not pr ovided on I2C bus
pullup %1110
; ------------------------------------------------------------------------------
; ERASE ENTIRE MEMORY - Remove REM to enable
; Use with caution, ALL DATA ERASED !!!
REM call ERASE_MEM
; ------------------- -----------------------------------------------------------
; ------------------------------------------------------------------------------
; WRITE DATA to Memory
; ------------------------------------------------------------------------------
; S et slave address, can only have one memory on bus - not addressable
hi2csetup i2cmaster, MeMPage_0, i2cfast, i2cbyte
for NUMIDX = 0 to 10
ADDR = NUMIDX * 16
; unREM if programming for the first time
call BIGNUM
pause 10 ; Set maxium write delay for reliablity
next
Call InitialiseOLED
Call clearDISPLAY
Call HEX_dump
; ------------------------------------------------------------------------------
; READ DATA from Memory
; ------------------------------------------------ ------------------------------
; Set slave address, can only have one memory on bus - not addressable
hi2csetup i2cmaster, MeMPage_0, i2cfast, i2cbyte
; Set PAGE Block to Read
for ADDR = $00 to $A0 step $0F
hi2cin ADDR, (b2,b3,b4,b5,b6, b7,b8,b9,b10,b11,b12,b13,b14,b15,b16,b17)
debug
pause 5000
next
; ------------------------------------------------------------------------------
end
; ------------------------------------------------------------------------------
; - -----------------------------------------------------------------------------
; DATA to be written to memory
; ------------------------------------------------------------------------------
BIGNUM:
; 8X16 FONT close packed - 15 bytes per number
on NUMIDX goto BN0,BN1,BN2,BN3,BN4,BN5,BN6,BN7,BN8,BN9,BNX
BN0: hi2cout ADDR,($00,$F8,$FC,$0C,$0C,$0C,$FC,$F8, $00,$3F,$7F,$60,$60,$60,$7F,$3F): return ; 0
BN1: hi2cout ADDR,($00,$00,$00,$F8,$FC,$00,$00,$00, $00,$00,$00,$7F,$3F,$00,$00,$00): retu rn ; 1
BN2: hi2cout ADDR,($00,$00,$84,$8C,$8C,$8C,$FC,$F8, $00,$3F,$7F,$61,$61,$61,$61,$20): return ; 2
BN3: hi2cout ADDR,($00,$08,$8C,$8C,$8C,$8C,$FC,$F8, $00,$20,$61,$61,$61,$61,$7F,$3F): return ; 3
BN4: hi2cout ADDR,($00,$F8,$FC,$80,$80,$80,$FC, $F8, $00,$01,$01,$01,$01,$01,$7F,$3F): return ; 4
BN5: hi2cout ADDR,($00,$F8,$FC,$8C,$8C,$8C,$84,$00, $00,$21,$61,$61,$61,$61,$7F,$3F): return ; 5
BN6: hi2cout ADDR,($00,$F8,$FC,$8C,$8C,$8C,$84,$00, $00,$3F,$7F,$61,$61,$61,$7F,$3F): return ; 6
BN7: hi2cout ADDR,($00,$08,$0C,$0C,$0C,$0C,$FC,$F8, $00,$00,$00,$00,$00,$00,$7F,$3F): return ; 7
BN8: hi2cout ADDR,($00,$F8,$FC,$8C,$8C,$8C,$FC,$F8, $00,$3E,$7F,$61,$61,$61,$7F,$3E): return ; 8
BN9: hi2cout ADDR,($00,$F8,$FC,$8C,$8C,$8C,$FC,$F8, $00,$00, $41,$61,$61,$61,$7F,$3F): return ; 9
BNX: hi2cout ADDR,("X","X","X"): return ; X terminator
return
InitialiseOLED:
; ---------------------------------------
; DEFAULT SETTINGS
; hi2cout OLED_COMMAND,( $AE, $D5,$80, $A8,$3F, $D3,$00, $40, $20,$00, $A1, $C8, $DA,$12 )
; change $DA $02 Sequential COM to default $12 Alternative COM for ZOOM function
; hi2cout OLED_COMMAND,( $81,$7F, $D9,$22, $DB,$20, $A4, $A6, $21,$00,$7F, $22,$00,$07, $8D,$14, $AF )
; -------------------------- -------------
;PAUSE 2000 ; Allow display to power up before trying to talk to it.
hi2csetup I2CMASTER, SSD1306_ADDR, I2CSPEED, I2CBYTE
for index = 0 TO 24: read index, aBYTE: hi2cout OLED_COMMAND,( aBYTE ): next
eeprom 0, (SSD1306_DIS PLAYOFF) ; $AE
eeprom 1, (SSD1306_SETDISPLAYCLOCKDIV) ; $D5
eeprom 2, ( $80 ) ; [RESET $80]
eeprom 3, (SSD1306_SETMULTIPLEX) ; $A8
eeprom 4, (SSD1306_MULTIPLEXVALUE) ; $3F for 64 : $1F for 32 display height
eeprom 5, (SS D1306_SETDISPLAYOFFSET) ; $D3
eeprom 6, ( $00 ) ; [RESET $00] no offset
eeprom 7, (SSD1306_SETSTARTLINE) ; [RESET $40] line #0
eeprom 8, (SSD1306_CHARGEPUMP) ; $8D
eeprom 9, ( $14 ) ; INTERNAL VCC
eeprom 10, (SSD1306_ MEMORYMODE) ; RAM Memory Address Mode (RESET = $02)
eeprom 11, ( $00 ) ; Horiz mode $00
eeprom 12, (SSD1306_SEGREMAP) ; $A1
eeprom 13, (SSD1306_COMSCANDEC) ; $C8
eeprom 14, (SSD1306_SETCOMPINS) ; $DA
eeprom 15, ( comPins Val ) ; $02 for 32 : $12 for 64
eeprom 16, (SSD1306_SETCONTRAST) ; $81
eeprom 17, ( $7F ) ; was $CF
eeprom 18, (SSD1306_SETPRECHARGE) ; $D9
eeprom 19, ( $22) ; was $F1
eeprom 20, (SSD1306_SETVCOMDETECT) ; $DB
eepro m 21, ( $20 ) ;
eeprom 22, (SSD1306_DISPLAYALLON_RESUME) ; $A4
eeprom 23, (SSD1306_NORMALDISPLAY) ; $A6
eeprom 24, (SSD1306_DISPLAYON) ; $AF
return
; -----------------------------------------
; Send pixel bytes for ASCII [ch ar] via I2C
; -----------------------------------------
displayCHARbig:
hi2cout OLED_COMMAND,( SSD1306_COLUMNADDR, i, j, SSD1306_PAGEADDR, k, m )
displayCHAR:
subchar = char AND $0F ; mask lower 4 bits of [char]
char = char / 16 ; Character group
hi2cout OLED_DATA,($00) ; Inter-digit gap
on char goto udef,cons,syms,nums,ucus,ucxs,lcus ;,lcxs
udef: ; User-definable characters (0 - 7) in upper RAM
bptr = subchar AND 7 * 5 + 28 ; mask lower 3 bits of [subchar] - Up to location 67
hi2cout OLED_DATA,(@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc)
return
cons: ; User-definable characters (16 - 31) in EEPROM
char = subchar * 5 + 16 ; 16 chars to location 95
subchar = char + 4 ; End of cell
for char = char to subchar
read char, tempb
hi2cout OLED_DATA,( tempb ) ; 5 columns
next
return
; COCO Font MODs : https://damieng.com/blog/2016/08/09/typography-in-bits-for-a-few-pixels-more/
; rhb.20230606
syms:
on subchar goto sym0,sym1,sym2,sym3,sym4,sym5,sym6,sym7,sym8,sym9,symA,symB,symC,symD,symE
symF: hi2cout OLED_DATA,($20, $10, $08, $04, $02) : r eturn ; /
sym0: hi2cout OLED_DATA,($00, $00, $00, $00, $00) : return ; Sp
sym1: ;hi2cout OLED_DATA,($00, $00, $5f, $00, $00) : return ; ! edit
sym2: ;hi2cout OLED_DATA,($00, $07, $00, $07, $00) : return ; "
sym3: ;hi2cout OLED_DATA,($14, $7f, $14, $7 f, $14) : return ; #
sym4: ;hi2cout OLED_DATA,($24, $2a, $7f, $2a, $12) : return ; $
sym5: ;hi2cout OLED_DATA,($23, $13, $08, $64, $62) : return ; %
sym6: ;hi2cout OLED_DATA,($36, $49, $55, $22, $50) : return ; & maybe change?
sym7: ;hi2cout OLED_DAT A,($00, $08, $07, $03, $00) : return ; ' edit
sym8: ;hi2cout OLED_DATA,($00, $1c, $22, $41, $00) : return ; (
sym9: ;hi2cout OLED_DATA,($00, $41, $22, $1c, $00) : return ; )
symA: hi2cout OLED_DATA,($14, $08, $3E, $08, $14) : return ; *
symB: hi2cout OLED_DATA,($08, $08, $3E, $08, $08) : return ; +
symC: ;hi2cout OLED_DATA,($00, $80, $70, $30, $00) : return ; , edit
symD: hi2cout OLED_DATA,($08, $08, $08, $08, $08) : return ; -
symE: hi2cout OLED_DATA,($30, $30) : return ; . edit
nums:
on s ubchar goto num0,num1,num2,num3,num4,num5,num6,num7,num8,num9,numA,numB,numC,numD,numE
numF: ;hi2cout OLED_DATA,($02, $01, $51, $09, $06) : return ; ?
num0: hi2cout OLED_DATA,($3E, $51, $49, $45, $3E) : return ; 0 edit
num1: hi2cout OLED_DATA,($00, $42, $7F, $40, $00) : return ; 1
num2: hi2cout OLED_DATA,($72, $49, $49, $49, $46) : return ; 2 edit
num3: hi2cout OLED_DATA,($22, $41, $49, $49, $36) : return ; 3 edit
num4: hi2cout OLED_DATA,($18, $14, $12, $7F, $10) : return ; 4
num5: hi2cout OLED _DATA,($27, $45, $45, $45, $39) : return ; 5
num6: hi2cout OLED_DATA,($3C, $4A, $49, $49, $30) : return ; 6
num7: hi2cout OLED_DATA,($01, $71, $09, $05, $03) : return ; 7
num8: hi2cout OLED_DATA,($36, $49, $49, $49, $36) : return ; 8
num9: hi2cout OL ED_DATA,($06, $49, $49, $29, $1E) : return ; 9
numA: hi2cout OLED_DATA,($00, $36, $36, $00, $00) : return ; :
numB: ;hi2cout OLED_DATA,($80, $76, $36, $00, $00) : return ; ; edit
numC: ;hi2cout OLED_DATA,($08, $14, $22, $41, $00) : return ; <
numD: ; hi2cout OLED_DATA,($14, $14, $14, $14, $14) : return ; =
numE: ;hi2cout OLED_DATA,($41, $22, $14, $08, $00) : return ; >
ucus:
on subchar goto ucu0,ucu1,ucu2,ucu3,ucu4,ucu5,ucu6,ucu7,ucu8,ucu9,ucuA,ucuB,ucuC,ucuD,ucuE
ucuF: hi2cout OLED_DATA,($ 3E, $41, $41, $41, $3E) : return ; O
ucu0: ;hi2cout OLED_DATA,($32, $49, $79, $41, $3E) : return ; @
ucu1: hi2cout OLED_DATA,($7C, $12, $11, $12, $7C) : return ; A 65 edit
ucu2: hi2cout OLED_DATA,($41, $7F, $49, $49, $36) : return ; B edit
ucu3: hi2 cout OLED_DATA,($3E, $41, $41, $41, $22) : return ; C
ucu4: hi2cout OLED_DATA,($41, $7F, $41, $22, $1C) : return ; D edit
ucu5: hi2cout OLED_DATA,($7F, $49, $49, $41, $41) : return ; E edit
ucu6: hi2cout OLED_DATA,($7F, $09, $09, $01, $01) : return ; F edit
ucu7: hi2cout OLED_DATA,($3E, $41, $41, $49, $79) : return ; G edit
ucu8: hi2cout OLED_DATA,($7F, $08, $08, $08, $7F) : return ; H
ucu9: hi2cout OLED_DATA,($00, $41, $7F, $41, $00) : return ; I
ucuA: hi2cout OLED_DATA,($30, $40, $40, $40, $3F) : return ; J edit
ucuB: hi2cout OLED_DATA,($7F, $08, $14, $22, $41) : return ; K
ucuC: hi2cout OLED_DATA,($7F, $40, $40, $40, $40) : return ; L
ucuD: hi2cout OLED_DATA,($7F, $02, $0C, $02, $7F) : return ; M
ucuE: hi2cout OLED_DATA,($7F, $04, $08, $1 0, $7F) : return ; N
ucxs:
on subchar goto ucx0,ucx1,ucx2,ucx3,ucx4,ucx5,ucx6,ucx7,ucx8,ucx9,ucxA,ucxB,ucxC,ucxD,ucxE
ucxF: ;hi2cout OLED_DATA,($40, $40, $40, $40, $40) :
inc rowptr : hi2cout OLED_COMMAND,( SSD1306_PAGEADDR, rowptr, pageEndAdd r, SSD1306_COLUMNADDR, 0, 126): return ; _ underscore to force a new row
ucx0: hi2cout OLED_DATA,($7F, $09, $09, $09, $06) : return ; P
ucx1: hi2cout OLED_DATA,($3E, $41, $51, $21, $5E) : return ; Q
ucx2: hi2cout OLED_DATA,($7F, $09, $19, $29, $46) : return ; R
ucx3: hi2cout OLED_DATA,($26, $49, $49, $49, $32) : return ; S edit
ucx4: hi2cout OLED_DATA,($01, $01, $7F, $01, $01) : return ; T
ucx5: hi2cout OLED_DATA,($3F, $40, $40, $40, $3F) : return ; U
ucx6: hi2cout OLED_DATA,($07, $18, $60, $18, $07) : return ; V edit
ucx7: hi2cout OLED_DATA,($3F, $40, $38, $40, $3F) : return ; W
ucx8: hi2cout OLED_DATA,($63, $14, $08, $14, $63) : return ; X
ucx9: hi2cout OLED_DATA,($07, $08, $70, $08, $07) : return ; Y
ucxA: hi2cout OLED_DATA,($61, $51, $4 9, $45, $43) : return ; Z 90
ucxB: ;hi2cout OLED_DATA,($00, $7F, $41, $41, $00) : return ; [ 91
ucxC: ;hi2cout OLED_DATA,($02, $04, $08, $10, $20) : return ; \ 92
ucxD: ;hi2cout OLED_DATA,($00, $41, $41, $7F, $00) : return ; ] 93
ucxE: ;hi2cout OLED_ DATA,($04, $02, $01, $02, $04) : return ; ^ 94
return
lcus:
on subchar goto lcu0,lcu1,lcu2,lcu3,lcu4,lcu5,lcu6,lcu7,lcu8,lcu9,lcuA ;,lcuB,lcuC,lcuD,lcuE
lcu0: return
lcu1: hi2cout OLED_DATA,($00,$F8,$FC,$0C,$0C,$0C,$FC,$F8,$00,$3F,$7F,$60,$60, $60,$7F,$3F): return ; 0 a
lcu2: hi2cout OLED_DATA,($00,$00,$00,$F8,$FC,$00,$00,$00,$00,$00,$00,$7F,$3F,$00,$00,$00): return ; 1 b
lcu3: hi2cout OLED_DATA,($00,$00,$84,$8C,$8C,$8C,$FC,$F8,$00,$3F,$7F,$61,$61,$61,$61,$20): return ; 2 c
lcu4: hi2cout OL ED_DATA,($00,$08,$8C,$8C,$8C,$8C,$FC,$F8,$00,$20,$61,$61,$61,$61,$7F,$3F): return ; 3 d
lcu5: hi2cout OLED_DATA,($00,$F8,$FC,$80,$80,$80,$FC,$F8,$00,$01,$01,$01,$01,$01,$7F,$3F): return ; 4 e
lcu6: hi2cout OLED_DATA,($00,$F8,$FC,$8C,$8C,$8C,$84,$00,$00 ,$21,$61,$61,$61,$61,$7F,$3F): return ; 5 f
lcu7: hi2cout OLED_DATA,($00,$F8,$FC,$8C,$8C,$8C,$84,$00,$00,$3F,$7F,$61,$61,$61,$7F,$3F): return ; 6 g
lcu8: hi2cout OLED_DATA,($00,$08,$0C,$0C,$0C,$0C,$FC,$F8,$00,$00,$00,$00,$00,$00,$7F,$3F): return ; 7 h
lcu9: hi2cout OLED_DATA,($00,$F8,$FC,$8C,$8C,$8C,$FC,$F8,$00,$3E,$7F,$61,$61,$61,$7F,$3E): return ; 8 i
lcuA: hi2cout OLED_DATA,($00,$F8,$FC,$8C,$8C,$8C,$FC,$F8,$00,$00,$41,$61,$61,$61,$7F,$3F): return ; 9 j
hi2cout OLED_DATA,($14, $08, $3E, $08, $1 4) : return ; *
stop ; just in case ;)
ERASE_MEM:
; ---------------------------
; For specific EEPROM 24LC16B
; PAGE Buffer = 16 Bytes
; ---------------------------
FILL = $FF ; Memory fill pattern
for PAGE = 0 to 7
; Set MeM Page
PAGESELECT = PAGE * 2 | MeMADDR
;i2cslave PAGESELECT, i2cfast, i2cbyte
hi2csetup i2cmaster, PAGESELECT, i2cfast, i2cbyte
for ADDR = $00 to $FF step $0F ; 16 bytes less then page size 0f 256 bytes
hi2cout ADDR, (FILL,FILL,FILL,FILL,FI LL,FILL,FILL,FILL,FILL,FILL,FILL,FILL,FILL,FILL,FILL,FILL)
pause 10 ; Set maxium write delay for reliablity
next
next
return
HEX_dump:
for i = 0 to 3
; Set slave address setup, can only have one 24LC16B on the buss - not addr essable
hi2csetup i2cmaster, MeMPage_0, i2cfast, i2cbyte
bptr = RAM_STACK_TOP
ADDR_PTR = i * 16
hi2cin ADDR_PTR, ( _
@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc, _
@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptri nc,@bptrinc,@bptrinc,@bptrinc )
; OLED slave address setup - INIT OLED before or no display
hi2csetup I2CMASTER, SSD1306_ADDR, I2CSPEED, I2CBYTE
bptr = RAM_STACK_TOP
for j = 0 to 15
char = "." ; half-space 4 bits
call displayCHAR
temp = @bptrinc
char = temp / 16 + "0"
if char > "9" then
char = char + 7
end if
call displayCHAR
char = temp & $0F + "0"
if char > "9" then
char = char + 7
end if
call displayCHAR
if j = 7 then
char = "_" ; new force CR/LF control
call displayCHAR
end if
next j
if i < 3 then
char = "_" ; new force CR/LF control
call displayCHAR
end if
next i
return
Set_Cursor:
; 5x7 font 21 characters x 8 rows using horizontal cur sor mode ( 4 rows for a 32 height display )
; ! remember this sets a Font Window Area
; SSD1306_COLUMNADDR ; ($21) bit range 0 to 127
i = col * 6 ; columns per character range 0 to 20
j = 125
; SSD1306_PAGEADDR ; ($22) range 0 to 7 (64 MUX) 0 to 3 (32 MUX)
k = row
m = pageEndAddr
call Set_Window_Area
rowptr = row
return
print:
for index = i TO j: read index, char: call displayCHAR: next index
return
Set_Window_Area:
; Use of temp variables
; On RESET disp lay set to maximum extents row=0-127 page=0-7 (64 bit height) (4 if 32 bit height)
; i - row start - Row Value Range: 0 to 127
; j - row end
; k - page start - Value Range: 0 to 7
; m - page end
; always set start less than end
; Note: A pa ge is 8 bits in height. Bits running top to bottom LSb to MSb.
hi2cout OLED_COMMAND,( SSD1306_COLUMNADDR, i, j, SSD1306_PAGEADDR, k, m )
return
Font_Window_Area:
i = 0: j = 125: k = 0: m = pageEndAddr
call Set_Window_Area
return
cl earDISPLAY:
i = 0: j = 127: k = 0: m = pageEndAddr
call Set_Window_Area
j = SCREENCLEAR ; calc display RAM to clear loop
for i = 0 to j
hi2cout OLED_DATA,( $00,$00,$00,$00, $00,$00,$00,$00, $00,$00,$00,$00, $00,$00,$00,$00 ) ; Clear 16 columns per loop
next i
row = 0: col = 0
call Set_Cursor
return
Schematic

Video
Bill of Materials (BOM)
Comments
Links
posted/edited by Ralph [VE3XRM] | 20250502 | 12:30
NOTE:
These projects require simple skills in electronics assembly and programming.
Minimal instructions might be provided.
These projects require simple skills in electronics assembly and programming.
Minimal instructions might be provided.
36 Page Views [1]