I've been trying to rewrite the Hardware serial core files to make transmit buffered and interrupt driven. I got my code to compile, but have had weird issues with the interrupts. When I tried to use the data ready interrupt it seems to work fine. I can get the examples to compile and run correctly. Unfortunately I need to use the TWI. Somehow my changes cause the wire library to hang in twi_writeTo at the line
// wait for write operation to complete
while(wait && (TWI_MTX == twi_state)){
continue;
}
My guess is that the USART interrupt is somehow interfering with the TWI one. I have no idea why this should be the case.
When I try to use the transmit complete interrupt the uC resets which seems to imply the compiler isn't including the interrupt properly.
I enable the interupts by adding sbi(_ucsrb, _txcie); and the appropriate code to set the variables after
sbi(_ucsrb, _rxen);
sbi(_ucsrb, _txen);
sbi(_ucsrb, _rxcie);
and use the SIG_USART_TRANS vector.
I'm using the atmega328p.
Anyone have any insight into what might cause these errors? I'll post the complete code later, but it's pretty long. If someone has already written code to do this that would be appreciated as well.