Atmega88 RX IT
Fuzesi Arnold
arno at externet.hu
Wed May 11 12:05:04 CEST 2005
Sziasztok!
Van tippetek arra miert "fagy" egy atmega 88 néha, ha az RXC interrupt
engedelyezve van?
Tipikusan ha glitch megy a rx vonalra, akkor teszi ezt.
Nem ertem miert... :(
Igy nez ki az IT:
#pragma vector=USART_RX_vect
__interrupt void USART_RX_handler(void)
{
uchar temp;
/* if(gbi(UCSR0A,FE0)){ //framing error
while(gbi(UCSR0A,RXC0)) temp=UDR0;
return;
}
if(gbi(UCSR0A,DOR0)){ //overrun error
while(gbi(UCSR0A,RXC0)) temp=UDR0;
return;
}
*/
temp=UDR0;
comm_ibyte0=temp;
comm_newbyte0=1;
}
A fenti kikommentezett reszben van a bibi.
Ha ki van kommentezve akkor minden rendben. Csak neha hibazik.
Ha nincs, akkor fagyas van.
(gbi() makro teszteli az adott bitet, annyit csinal)
Adatlap szerint:
Flushing the Receive Buffer The receiver buffer FIFO will be flushed when
the Receiver is disabled, i.e., the buffer
will be emptied of its contents. Unread data will be lost. If the buffer has
to be flushed
during normal operation, due to for instance an error condition, read the
UDRn I/O loca-tion
until the RXCn Flag is cleared. The following code example shows how to
flush the
receive buffer.
azaz:
"read the UDRn I/O loca-tion
until the RXCn Flag is cleared."
Ez hivatott erre a fentiből:
while(gbi(UCSR0A,RXC0)) temp=UDR0;
Annyit még, hogy a proci ICP, INT0, RX laba ossze van kotve. (tobbfele
program lehet a kutyuben, es mindegyik mast hasznal)
De mindegyik bemenet, es csak az RX-en van felhuzo bekapcsolva.
Tobbi megszakitas tiltva.
A bufferelt clockout a portb.0-n (ICP) elvileg tiltva, 1-ben all a neki
megfelelo fuse.
(0x62 a ra vonatkozo fusebyte)
Total nem ertem.....
Arnold
More information about the Elektro
mailing list