سلام دوستان من یه جایی بدجور گیر کردم لطفا یکی کمک کنه<br>من میخوام یه مقداری رو از تاینی 13 به مگا32 ارسال کنم از هر راهی امتحان کردم نشد مثل uart و spi و ...<br>از کتابخانه i2cslave استفاده کردم حالا مگا32 که مسار هست اطلاعات درست میفرسته با اسلیو که تاینی 13 هست ولی تاینی13 فقط صفر میفرسته اینم از کد دو تا میکرو. لطفا یکی بگه مشکل از کجاست
'Master mega32
$Regfile="m32adef.dat"
$Crystal=4000000
config lcd=16*2
$Baud=4800
config lcdpin = PIN , DB4=pina.1 , DB5=pina.2 , DB6=pina.3 , DB7=pina.4 , RS=pina.5 , E=pina.6
dim ss as byte
cursor off
cls
config I2cdelay=40
config scl=portc.0
config sda=portc.1
I2cinit
dim Byte_(2) as byte
do
Err=0
Byte_(1)=133
I2cstart
I2cwbyte &H30
I2cwbyte 120
I2cstart
I2cwbyte &H31
I2crbyte Byte_(1),nack
I2cstop
waitms 25
if Err=0 then
ss=Byte_(1)
home
lcd "code is recive"
locate 2,1
lcd Byte_(1)
else
cls
home
lcd Err
endif
loop
end
'Slave Tiny13
$Regfile="attiny13a.dat"
$Crystal=4800000
$hwstack=32
$swstack=8
$framesize=16
$lib "i2cslave.lib"
config I2cslave=&H30,int=int0,timer=timer0
dim bfake as byte
dim aa as byte : aa=124
enable interrupts
config portb=input
do
loop
I2c_master_needs_data:
_a1=221
waitms 25
return
I2c_master_has_data:
bfake=_a1
config portb.4=output
if bfake=120 then
set portb.4
else
reset portb.4
endif
waitms 25
return
دیدگاه