| ??? 07/05/01 16:56 Read: times |
#13052 - Circural buffer |
Can anybody help me?
When I am receiving a char from Pc to 8051 via Serial port, I am using a circular buffer. But it does not work as it should. When an interupt is triged an interupt rutine com_isr is called. With function com_getchar I read a char from a circular buffer. Everything worked ok, before i implemented a circular buffer. Buffer size is 64. void com_isr () /*interrupt 4 using 2*/ { /*------------------------------------------------ Received data interrupt. ------------------------------------------------*/ if (RI != 0) { RI = 0; if (r_in!=63) { if ((r_in + 1) != r_out) {rbuf[r_in++]=SBUF;}} else { r_in=0; if ((r_in + 1) != r_out) {rbuf[r_in++]=SBUF;} } } /*------------------------------------------------ Transmitted data interrupt. ------------------------------------------------*/ if (TI != 0) { TI = 0; if (t_out!=63){ if (t_in != t_out) {SBUF = tbuf[t_out++];} else t_disabled = 1; } else { t_out=0; if (t_in != t_out) {SBUF = tbuf[t_out++];} else t_disabled = 1; } } } char com_getchar() { char c; if (com_rbuflen () == 0) return (-1); EA = 0; /* Disable Interrupts */ if (r_out!=63) {c=rbuf[r_out++];} else {r_out=0; c=rbuf[r_out++];} EA = 1; /* Enable Interrupts */ return (c); } Thanks in advance! |
| Topic | Author | Date |
| Circural buffer | 01/01/70 00:00 | |
| RE: Circural buffer | 01/01/70 00:00 | |
| RE: Circural buffer | 01/01/70 00:00 | |
| RE: Circural buffer | 01/01/70 00:00 | |
| RE: Circular buffer | 01/01/70 00:00 | |
| RE: Circural buffer | 01/01/70 00:00 | |
RE: Circural buffer | 01/01/70 00:00 |



