gabriellimhj
Junior Member level 3
- Joined
- Oct 30, 2013
- Messages
- 30
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 6
- Activity points
- 181
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 #include <reg51.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; SCON = 0x50; TH1 = 0xFD; TR1 = 1; EA=1; ES=1; mybit=0; while(1); } //send data as "!A@" and test void serial_int(void)interrupt 4{ if(RI); { infor[i++] = SBUF; if(i >= 3){ if((infor[0] == start_header) && (infor[1] == '!') && (infor[2] == end_header))mybit = 1; else mybit = 0; i = 0; } } RI = 0; }
do u know how to debounce the switch on zigbee
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 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++; } if(i == 3){ ES_bit = 0; EA_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){ 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 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 #include <ABSACC.h> #include <reg51.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 serial_int (void); #define PortA 0x4000 //LCD data #define PortB 0x4001 //LCD RS, RW, E #define PortC 0x4002 //Keypad #define ControlReg 0x4003 void Delay(int time) { int i, j; for(i = 0; i < time; i++) for(j = 0; j < 200; j++); } void LCD_WriteInstructionReg(unsigned char Instruction) { XBYTE[PortB] = 0x00; XBYTE[PortB] = 0x04; Delay(20); XBYTE[PortA]= Instruction; XBYTE[PortB] = 0x00; } void LCD_WriteDataReg(unsigned char Value) { XBYTE[PortB] = 0x01; XBYTE[PortB] = 0x05; Delay(20); XBYTE[PortA] = Value; XBYTE[PortB] = 0x00; } void InitialiseLCD(void) { LCD_WriteInstructionReg(0x38); //8 bits bus mode, 2 line display, 5x7 dots format LCD_WriteInstructionReg(0x0E); //TurnOn display, cursor on, no blink LCD_WriteInstructionReg(0x01); //ClearDisplay LCD_WriteInstructionReg(0x06); //Increase cursor to right LCD_WriteInstructionReg(0x02); //ReturnHome } void LCD_DisplayString(char *String) { int i = 0; while (String[i]) { LCD_WriteDataReg(String[i++]); } } void main(void){ TMOD = 0x20; SCON = 0x50; TH1 = 0xFD; //9600 bps PCON=0x80; TR1 = 1; EA=1; ES=1; mybit=0; serial_int(); Delay(5000); //waiting for PPI to reset XBYTE[ControlReg] = 0x81; InitialiseLCD(); LCD_DisplayString("Zigbee"); while(1){ infor[3] = '\0'; LCD_WriteInstructionReg(0xC0); LCD_DisplayString(infor); } } //send data as "!A@" and test void serial_int (void) interrupt 4{ if(RI==1); { infor[i++] = SBUF; if (infor[0] =='!') { inforstart = 1; inforcount = 0; } if(inforstart == 1) { if (infor[2] =='@') { inforstart = 0; if((infor[0]=='!')&&(infor[1] == 'A')&&(infor[2]=='@')) { mybit = 1; } else mybit=0; i=0; } } } RI = 0; }
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?