Hi ,
i am working on usart in atmega 8;
i wanna transmit some byte to another mega . i can do that from other way . but i want to use TXCIE interrupt to check that shift register is emty and then send new byte;
but it seem s dosent work . i dont know why , or i dont know what is my wrong.please guide me;
Atmel Studio
'------------------------------------
int i , t , m;
ISR(USART_TXC_vect)
{
m = 1;
}
//-----
int main(void)
{
/* Replace with your application code */
sei();
UCSRB = 0x48;
UBRRL = 51;
UCSRC = (1<<URSEL) | (0<<UMSEL) | (0<<UPM1) | (0<<UPM0) | (1<<USBS) | (1<<UCSZ1) | (1<<UCSZ0) | (0<<UCPOL);
//-----
UDR = 30;
while(1)
{
if ( m == 1 )
{
i++;
UDR = i;
m = 0;
t = 0;
}
}
}
------------------------------------
but this block of code works:
'-------
int i , t , m;
//----
ISR(USART_TXC_vect)
{
i++;
UDR = i;
}
//------
int main(void)
{
/* Replace with your application code */
sei();
UCSRB = 0x48;
UBRRL = 51;
UCSRC = (1<<URSEL) | (0<<UMSEL) | (0<<UPM1) | (0<<UPM0) | (1<<USBS) | (1<<UCSZ1) | (1<<UCSZ0) | (0<<UCPOL);
UDR = 30;
while(1)
{
}
}
thank you;