Hello,
I am quite new in picbasic programming.
I am trying to figure out if it's possible to send bits to a dac (tc1321) form a pic16f876.
I want to send a 10bit serial word to the device.
I wrote this program:
SDA var byte
SCL var byte
ADDR var byte
VAL var word
i var word
TRISB.4 = 1 ' Pin B4ingresso
TRISC = 0 ' Porta C uscita
SDA = 12 ' Imposto l'uscita SDA sul pin C4
SCL = 11 ' Imposto l'uscita SCL sul pin C3
ADDR = %10010000 ' Indirizzo del TC1321
main:
if PORTB.4 then
goto inizia
else
goto main
endif
inizia:
val = %0000000000
for i=0 to 14
i2cwrite sda,scl,addr,[val]
val = val + %1000000
next
val = %1111111111
i2cwrite sda,scl,addr,[val]
while PORTB.4 = 0
i2cwrite sda,scl,addr,[val]
wend
goto inizia
end
Do you think it's right or I've done GREAT errors?
Thank you very much!!
Fabrizio
Bookmarks