gabriellimhj
Junior Member level 3
- Joined
- Oct 30, 2013
- Messages
- 30
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 6
- Activity points
- 181
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Code C - [expand] 1 TI_1 = ES1 = 0;
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 //ISR if(RI == 1){ uard_rd[i] = SBUF; i++; if(i > dataLength)process = 1; } //main() while(1){ if(process){ if((uart_rd[0] == 'A') && (uart_rd[1] == 'B'))LED = 1; else LED = 0; process = 0; i = 0; } }
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 #include <absacc.h> sbit mybit = P1^4; unsigned char code start_header = '!'; unsigned char code end_header = '@'; unsigned char inforstart = 0; unsigned char infor[20]; unsigned char inforcount = 0; unsigned char i = 0; void main(void){ TMOD = 0x20; SCON0 = 0x50; TH1 = 0xFD; //9600 bps TR1 = 1; } //send data as "!A@" and test void serial_int (void) interrupt 4{ { if(RI_0); //check RI until set { infor[i++] = SBUF0; if (infor[0] =='!') { inforstart = 1; inforcount = 0; } if(inforstart == 1) { if (infor[2] =='@') { inforstart = 0; if(infor[1] == 'A')mybit = 1; else mybit=0; i = 0; } } } RI_0 = 0; }
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 sbit mybit at P1_4_bit; unsigned char infor[5]; unsigned char i = 0; void SerialInterrupt() iv IVT_ADDR_ES ilevel 0 ics ICS_AUTO{ if(RI_bit); { infor[i] = SBUF; i++; RI_bit = 0; } RI_bit = 0; } void main(){ P1 = 0x00; P3 = 0x03; TMOD = 0x20; SCON = 0x50; TH1 = 0xFD; TR1_bit = 1; EA_bit = 1; ES_bit = 1; while(1){ /* SBUF = 'K'; while(TI_bit == 0); TI_bit = 0; */ if(i >= 3){ if((infor[0] == '!') && (infor[1] == 'A') && (infor[2] == '@')) { mybit = 1; } else mybit = 0; i = 0; } } }
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 sbit mybit at P1_4_bit; unsigned char infor[30]; unsigned char i = 0; unsigned short j, count = 0; void SerialInterrupt() iv IVT_ADDR_ES ilevel 0 ics ICS_AUTO{ if(RI_bit); { infor[i] = SBUF; i++; RI_bit = 0; } RI_bit = 0; } void main(){ P1 = 0x00; P3 = 0x03; TMOD = 0x20; SCON = 0x50; TH1 = 0xFD; TR1_bit = 1; EA_bit = 1; ES_bit = 1; while(1){ //SBUF = 'K'; //while(TI_bit == 0); //TI_bit = 0; if(i >= 30){ for(j = 0; j < 30; j + 3){ if((infor[j] == '!') && (infor[j + 1] == 'A') && (infor[j + 2] == '@')) count++; } for(j = 0; j < 30; j++) infor[j] = '\0'; //Clear array if(count == 10)mybit = 1; else mybit = 0; count = 0; //Reset counter } } }