关于C8051F020 红外信号发射~
是22.1184MHZ的晶振,不能发射信号。求高人指点。。。
#include <C8051F020.H> #include "string.h" #include "INTRINS.H" #define uint unsigned int #define uchar unsigned char uchar flag,count,GW,DW; sbit P3_5 = P3^5; void delay(uint n) { uint i; while(n--) { for(i = 0;i < 100;i++) { ; } } } void fs() { uchar n,i,temp; count = 0; n = 16; flag = 1; do{}while(count < n); //9ms count = 0; n = 8; flag = 1; do{}while(count < n); //4.5ms temp = GW; for(i = 0;i < 8;i++) { n = 1; count = 0; flag = 1; do{}while(count < n); if(temp-(temp/2)*2) { n = 3; } else { n = 1; } count = 0; flag = 0; do{}while(count < n); } temp = ~GW; for(i = 0;i < 8;i++) { n = 1; count = 0; flag = 1; do{}while(count < n); if(temp-(temp/2)*2) { n = 3; } else { n = 1; } count = 0; flag = 0; do{}while(count < n); } temp = DW; for(i = 0;i < 8;i++) { n = 1; count = 0; flag = 1; do{}while(count < n); if(temp-(temp/2)*2) { n = 3; } else { n = 1; } count = 0; flag = 0; do{}while(count < n); } temp = ~DW; for(i = 0;i < 8;i++) { n = 1; count = 0; flag = 1; do{}while(count < n); if(temp-(temp/2)*2) { n = 3; } else { n = 1; } count = 0; flag = 0; do{}while(count < n); } n = 1; count = 0; flag = 1; do{}while(count < n); flag = 0; } void main() { //OSCICN = 0x08; WDTCN = 0xde; WDTCN = 0xad; EA = 1; TMOD = 0x01; TH0 = 0xFF; TL0 = 0x98; ET0 = 1; TR0 = 1; flag = 0; while(1) { GW = 0x40; DW = 0x05; delay(1); P4 = 0x00; fs(); P4 = 0xff; delay(2000); } } void time0() interrupt 1 { TH0 = 0xFF; TL0 = 0x98; count++; if(flag == 1) { P3_5 = ~P3_5; } else P3_5 = 0; }