Lauris
Newbie level 6
- Joined
- Apr 24, 2012
- Messages
- 11
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Location
- Lithuania, Vlinius
- Activity points
- 1,355
Hello eeryone,
one question apeared while trying to make full I2C(TWI) interupt based driver. main problem is after transmitting nACK when I can set it back inside ISR(); and don't leave I2C hanging with nACK in register that way uC being isolated from i2C line.
would it make sence what I wrote ahead that nACK writed to registers, transfer started and after that swiching nACK flag back to ACK - sill nACK would be transfered? if not then how to do that inside interupt function. Any ideas?
P.S. this case is writed for Atmega8
Laurynas.
one question apeared while trying to make full I2C(TWI) interupt based driver. main problem is after transmitting nACK when I can set it back inside ISR(); and don't leave I2C hanging with nACK in register that way uC being isolated from i2C line.
Code:
case 0x40: //SLA+R has been transmitted, ACK has been received
if (cnt_R >= TWI_rcv_sz)
TWCR &= ~(1 << 6); //transmit nACK to inform about last receiving byte
TWCR |= (1 << 7); //Eanble TWI, to continue transmition
if (TWCR & (1 << 6))
TWCR |= (1 << 6); //reseting TWEA back to ACK
break;
P.S. this case is writed for Atmega8
Laurynas.