CPU = 16F876 MHZ = 10 CONFIG 16254 ;*********************************************** ; http://www.basicmicro.com ; Title : 25c040.bas ; Author : Dale Kubin ; Date : 04/29/02 ; Shiftin / Shiftout commands. Read and write to ; a SPI serial eeprom. ;*********************************************** temp var byte cntr var word cntr = 0 SCK con B1 SO con B3 SI con B2 CS con B0 low SCK ;sets chip in a known state high CS main low CS shiftout SI,SCK,MSBPRE,[0x06\8] ; sets 25c040 for a write high CS low CS shiftout SI,SCK,MSBPRE,[0x02\8] shiftout SI,SCK,MSBPRE,[cntr\8] ; sends address location for write shiftout SI,SCK,MSBPRE,[cntr\8] ; using the value of address as the value to be writen high CS pause 5 low CS shiftout SI,SCK,MSBPRE,[0x03\8,cntr\8] ; sets 25c040 for a read shiftin SO,SCK,MSBPOST,[temp\8] ; reads and stores results in temp high CS serout c0,i9600,["Hello",dec temp,13] ; prints value stored in temp to terminal window cntr = cntr + 1 goto main