PICAXE 18M2 test board
Fig. 1 Schematic to my home built test board minus I/O resistors.

PICAXE 18M2 Microcontroller Operating 24LC08 EEPROM

by Lewis Loflin

This demo demonstrates the use of the PICAXE 18M2 internal EEPROM and a separate program using the 24LC08 external EEPROM. It's similar to a program I wrote for the Arduino micro-controller. The second program also shows how to use indirect addressing (bptr) with the PICAXE chip. both programs use the terminal in the PICAXE compiler.

DS1307-24LC08 module
Fig. 2 DS1307-24LC08 test board.

This is a module I constructed to combine an EEPROM and the DS1307 RTC. One could just connect only the 24LC08 section by itself. Don't connect the 1 Hz out pin to C.0 on the PICAXE if just using the EEPROM section.

Pullup resistors DS1307.
Fig. 3 These pullup resistors must be connected between the PICAXE and DS1307 module.

These 4.7k pullup resistors must be connected as shown between the module in Fig. 2 and the PICAXE.

Program 1 Internal EEPROM

; uses internal EEPROM

; PICAXE- 18M2 Program memory 1792 up to 2048 is EEPROM 0 to 255

#picaxe 18m2 ; type chip used
#terminal 4800 ; set default baud rate serial terminal and open

EEPROM 0,("Hello World   "); save string values in internal EEPROM


   for b0 = 0 to 12   ; start a loop
     read b0,b1  ; read value from EEPROM
     sertxd (b1)  ; transmit to serial 
   next b0  ; next character
 sertxd(13,10) ; LF-CR
 pause 500
 goto main

Program 2 External 24LC08 EEPROM

; demonstrate use of I2C with 24L08 EEPROM
; use storage variables from 28- 255 (0x1C - 0xFF)
; Use indirect addressing
; Page references pertain to PICAXE Manual 2 Basic Commands

#picaxe 18m2 ; type chip used
#terminal 4800 ;set baud rate serial terminal and open

symbol SW1 = pinC.5 ; use for input
symbol LED1 = C.7 ; optional LED to ground
symbol LED2 = C.6 ; optional LED to ground
symbol val = b13  ; user variable if needed

hi2csetup i2cmaster,  %10100000,  i2cfast,  i2cbyte  ; 24LC08 1kb p. 76

hi2cout 0, ("Hello World!   ",13,10)  ; initialize EEPROM message p. 76


if SW1 = 0   then new_message ; jump to write new message

bptr = 50
; read EEPROM message ref. p. 72
hi2cin 0,(@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,

bptr = 50

for bptr = 50 to 63  ;enter upto 16 char plus LF-CR 
if @bptr = 10 then EXIT ; exit after LF-CR

next bptr

pause 1000 ; wait a while

goto main



sertxd("Input name: ")


for bptr = 28 to 44

serrxd [1000],@bptr  

sertxd(@bptr) ; echo input

if @bptr = 10 then EXIT  ; break loop on LF-CR

next bptr 


bptr = 28 ; @bptrinc will inc bptr by 1 

hi2cout 0, (@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,

pause 500  ; wait for EEPROM


goto main

Picaxe Micro-controller Projects!

The PICAXE series of micro-controllers rank as the easiest and most cost effective way to use Microchip processors. I wanted an easier and less expensive way to introduce my students to the "PIC" micro-controller. Here I hope to get those starting out past poorly written literature and lack of simple working code examples.

See How I got into Electronics