I have two atmega8i which needed to communicate with each other, so I used TWI Protocol it works for some seconds and after that, it stops randomly at some pattern of TWI signal, why this happening?
transmitter :
Code: Select all
TWI_Init(100000) DDB7_bit = 1 ' initialize TWI communication
TWI_Start() ' issue TWI start signal
TWI_Write(1) ' send byte (address of EEPROM location)
TWI_Stop() timer1_init() ' issue TWI stop signal
while TRUE
inc(jk)
TWI_Start() ' issue TWI start signal
TWI_Write(jk) ' send byte (address of EEPROM location)
TWI_Stop()
Delay_ms(100)
wend
reciver
Code: Select all
TWI_Init(100000)
while TRUE
TWI_Start()
if TWI_Busy =0 then
' issue TWI start signal
target_min=TWI_Read(1) ' read data (NO acknowledge)
end if
TWI_Stop()
Display_Number(target_min)
Delay_ms(10)
wend