C51 pulse width detection program

Publisher:自由思考Latest update time:2015-05-06 Source: 51heiKeywords:C51 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
/**********************************************
  315 wireless module PT2262 1.5M 270KHz can measure the pulse width
  start time 5000us
  high level time 490us low level
  time 160us   HH=1   LL=0   LH=F ***************************************************/ #include typedef unsigned int uint; long plu; void delay(uint); main() {      TMOD=0x09; //0x0000 1001b       ET0=1; //Timer 0 interrupt enable // EX0 = 0; // Turn off INT0      EA=1; //CPU open interrupt     while(1)      {         TH0=0x00; //Counter high 8         TL0=0x00; //Counter low 8         TF0=0; //Counter 0 overflow flag set to 0         while(INT0==1); //Wait for P3.2 to become low         TR0=1; //Start the counter by INT0         while(INT0==0); //Wait for P3.2 to become highwhile         (INT0==1); //Wait for P3.2 to become low         againTR0=0; //T0 stops countingplu          =TH0*256+TL0; //Count valueif         (plu>4000) //Judge              P0=0x0c; //0x0000 1100b         else             P0=~0x0c;         P2=~P2;         delay(6635);  } } void delay(uint t) {  while(t--); }




 



























  





Keywords:C51 Reference address:C51 pulse width detection program

Previous article:KEIL-BANK Paging (H00, H01 ... H0x)
Next article:Design of signal source generator based on single chip microcomputer

Recommended ReadingLatest update time:2024-11-23 07:31

X5045 read and write integrated C51 program
void X5045SpiOpen(void); //Open X5045 chip select void X5045SpiClose(void);//Close X5045 chip select void X5045WriteEnable(void);//Software enables X5045 write operation void X5045WriteDisable(void);//Software disables X5045 write operation unsigned char X5045SpiSend(unsigned char val);//X5045 sends and receives SP
[Microcontroller]
About code, idata, xdata in C51
In terms of data storage type, the 8051 series has on-chip and off-chip program memory, on-chip and off-chip data memory. The on-chip program memory is also divided into direct addressing area and indirect addressing type, corresponding to code, data, xdata, idata and pdata type set according to the characteristics of
[Microcontroller]
C51 MCU Study Notes - IO Expansion (Serial to Parallel) Experiment - 74HC595
Purpose: To control the LED matrix to display in a row loop through the 74HC595 module. Compiler software: keil5 process: (1) First define the 74HC595 control pins and the dot array control port //Define 74HC595 control pins sbit SRCLK=P3^6; //Shift register clock input sbit RCLK=P3^5; //Storage register clock
[Microcontroller]
C51 MCU Study Notes - IO Expansion (Serial to Parallel) Experiment - 74HC595
An example of how to call an assembly function in KEIL C51 (v6.21)
There are many posts about how to call assembly in C51, but they usually only talk about the key points, and rarely describe the whole process in detail, which is not enough for beginners. Here, I will describe the process through a simple example, hoping to help beginners. Over the past few years, I have received gui
[Microcontroller]
C51 Software Implementation of Binary Tree Algorithm on Single Bus
introduction The single bus technology combines the address line, data line and control line into one line, and allows multiple single bus devices to be connected to the line. Its search ROM command can identify the registration code and device type of the device connected to the bus online, and can determine the nu
[Microcontroller]
C51 Software Implementation of Binary Tree Algorithm on Single Bus
C51---7 timer
Timer related registers Timer Control Register TCON Timer operating mode register TCON Code 1 Flashing water lights through timer, realizing key control mode of water lights main function #include REGX52.H #include "Timer0.h" #include "Key.h" #include INTRINS.H unsigned char KeyNum,LEDMode; void ma
[Microcontroller]
C51---7 timer
Homemade MCU 16…Convert text or graphics into C51 fonts used on LCD
In this lecture, I will talk about how to use the font extraction software to convert graphics into data. Many people have repeatedly asked me this question, so I will explain it in detail!   There are many font extraction software. Some can only convert text into font data, while others can convert text into fonts an
[Microcontroller]
MCU C51 serial port interrupt reception and transmission test routine (including communication protocol implementation)
Communication protocol: The first byte, MSB is 1, which is the first byte mark, the second byte, MSB is 0, which is the non-first byte mark, and so on... The last byte is the XOR checksum of the last 7 bits of the previous bytes. Test method: You can write 95 10 20 25 in the sending box of the serial port debugging a
[Microcontroller]
Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号