??? 11/07/06 03:29 Read: times |
#127471 - Interrupt serial. |
Hi, I am using keil and cannot do that it works.
I want to do is that when receives a zero in the serial cleans a record E of count. . this is the code #include <Reg52.h> #include <stdio.h> char uart_data; void Entrada(); void Salida(); sbit s1 = P2^0; sbit s2 = P2^1; sbit s3 = P0^0; char R1; long int E=0x00; long int S=0x00; void main(void) { #ifndef MONITOR51 SCON = 0x52; TMOD |= 0x20; TH1 = 0xFD; TL1 = 0xFD; TR1 = 1; TI = 1; ES = 1; EA = 1; #endif while(1); } void serial_IT(void) interrupt 4 { if (RI==1) { RI = 0; uart_data = SBUF; if(uart_data==0x00) E = 0; TI = 1; SBUF = uart_data; } else TI = 1; if(s1==0) { while(s2==1); if(s3==1)Entrada(); while(s1==0 || s2==0); } if(s2==0) { while(s1==1); if(s3==0)Salida(); while(s1==0 || s2==0); } } void Entrada(void) { E++; printf ("\n%10li",E); } void Salida(void) { S++; printf ("\n%106li",S); } Thank. |
Topic | Author | Date |
Interrupt serial. | 01/01/70 00:00 | |
Format the code | 01/01/70 00:00 | |
How to post code | 01/01/70 00:00 | |
Don't printf from the isr | 01/01/70 00:00 | |
Do a search for 'circular buffer' | 01/01/70 00:00 | |
Does it work in the Simulator? | 01/01/70 00:00 | |
Now know who work the Simulator. | 01/01/70 00:00 |