Hi, I have a FM24C04A (fram memory from ramtron), and I want to access it usin a 16f627. Here is the code I wrote to do some tests (it's part of a bigger code).
What I want to do is to write a 5 (decimal) in some adress and then read it and write it to a variable, then send the variable to a display.
I was experimenting with shiftout and shiftin, but I don't really know what I am doing.
The memory uses the same pin to read and write, I tried to use also only one pin on the pic, Is it possible?
@ DEVICE INTRC_OSC_NOCLKOUT, WDT_OFF, PWRT_OFF, MCLR_OFF, BOD_OFF, LVP_OFF, CPD_OFF, PROTECT_OFF
include "modedefs.bas"
define osc 4
TRISA = %00000000
TRISB = %01000110
intcon = 0
clear
num var byte
x var word
cuenta var byte
velocidad var word
circunferencia var byte
demora var byte
t1 var portb.4
t2 var portb.5
t3 var portb.3
sda var porta.7
scl var porta.6
timer con 9
OPTION_REG = %10000111
INTCON = %11100000
CMCON = 7
shiftout sda, scl, 5, [%10100000, %00000000, 5]
shiftout sda, scl, 5, [%10100000, %00000000, %10100001]
TRISA.7 = 1
shiftin sda, scl, 7, [circunferencia]
TRISA.7 = 0
x = circunferencia
display:
num = x dig 0 ; unidad de X y lo manda a num
porta = num
high t1
pause 3
low t1
num = x dig 1 ; decena de X y lo manda a num
porta = num
high t2
pause 3
low t2
num = x dig 2 ; centena de X y lo manda a num
porta = num
high t3
pause 3
low t3
goto display
Bookmarks