MCU C language bit definition

Publisher:sheng44Latest update time:2015-12-30 Source: eefocusKeywords:MCU Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
In the internal data memory of the 80C51 microcontroller, 20H~2FH is the bit operation area, in which each bit has its own bit address, and each bit can be operated. The bit address space is 00H~07FH, a total of 16*8=128 bits. The lowest bit of 20H is 00H, and the highest bit of 2FH is 7FH. For each bit of the special function register whose byte address is divisible by 8, it also has an addressable bit address, and its bit address system starts from 80H. The address of the special register is the same as the number of its lowest bit address. For example, if the address system of port P0 is 80H, then the lowest bit address system of port P0 is also 80H. Here, we need to distinguish between the address and the bit address. The former is the address of port P0, which has 8 bits, and each bit has a bit address. The lowest bit address is 80H, followed by 81H. They are separated in physical structure.

In C language we should define it like this:

bit a,c,d;   

uchar bdata put_1;   

sbit buzzer=put_1^0;

sbit led1=put_1^1;

sbit led2=put_1^2;

sbit led3=put_1^3;

sbit led4=put_1^4;

sbit run=put_1^5;

sbit up=put_1^6;

sbit down=put_1^7;

sbit led=P1^1;  

Directly using labels in programming can bring convenience to programming.


Keywords:MCU Reference address:MCU C language bit definition

Previous article:51 single chip temperature and humidity sensor DHT11
Next article:High-speed reading method of 51 MCU without hardware SPI

Recommended ReadingLatest update time:2024-11-17 05:50

MCU serial communication subroutine
Description: Crystal oscillator 11.0592MHZ, baud rate 9600 generated by timer 1 (T1), serial port interrupt working mode 1    #include math.h #define uchar unsigned char #define uint unsigned int uchar ge; sbit bin=P3^7; uchar flag; void init_com() {   TMOD=0x20;            //T1 working mode 2   PCON=0
[Microcontroller]
Hangshun Chip's automotive-grade MCUs are rapidly expanding, accelerating the deployment of high-end automotive applications
As the automotive industry moves towards electrification and intelligence , the market demand for automotive MCUs continues to grow. Especially for electric vehicles, the implementation of each function requires the support of complex chip solutions - such as the control of car door and window controls, reverse brake
[Automotive Electronics]
Hangshun Chip's automotive-grade MCUs are rapidly expanding, accelerating the deployment of high-end automotive applications
AVR microcontroller learning basics
Introduction: The cost performance of AVR microcontroller is much higher than that of 51 microcontroller. 1. High speed, RISC, and the main frequency can reach up to 20MHZ. 2. Low power consumption and wide voltage (1.8V---5.5V). The lowest full-speed operation power consumption is 300uA. 3. Strong I/O driving capabil
[Microcontroller]
AVR microcontroller learning basics
51 microcontroller timer interrupt basics
1. The concept of interruption Interrupts are set up to enable the microcontroller to process external or internal random events in real time. Think of yourself as the CPU of a microcontroller. You are washing clothes, but suddenly the courier guy calls you and asks you to pick up the courier, so you stop washing the
[Microcontroller]
The simplest 51 single chip multitasking code
;The principle of this 51 multi-task program is to set multiple stack locations and rewrite the stack pointer in the interrupt to switch tasks.  ;Since multiple stacks are used, there should not be too many nested calls when calling, so as not to exceed the stack work area (48 bytes) and cause program errors.  ;This
[Microcontroller]
51 MCU serial communication principle explanation
Today I studied the serial port communication of 51 single-chip microcomputer. The single-chip microcomputer used is the Puzhong Technology Development Board, but in fact the hardware used is the same as that of other brands of single-chip microcomputers, there is no difference. Let me summarize my understanding and
[Microcontroller]
51 MCU serial communication principle explanation
Doorbell microcontroller c program
            #include reg51.h             sbit p10=P1^0;             sbit p17=P1^7;             unsigned char c;             unsigned char k;             unsigned int k2,k1;             bit p;             main()             {           void delay();             TR0=0;             TMOD=0X01;             TH
[Microcontroller]
Application of MSP430 microcontroller in power supply control
The MSP430 series microcontroller is a new generation of 16-bit microcontroller produced by TI in the United States. It is an ultra-low power mixed signal processor (MixedSignal Processor). It has the advantages of low voltage, ultra-low power consumption, powerful processing capability, stable system operation, ric
[Power Management]
Application of MSP430 microcontroller in power supply control
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
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号