Position relationship of bit fields in bytes in C51

Publisher:幸福时刻Latest update time:2016-11-23 Source: eefocusKeywords:C51 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

 typedef struct
  {
    uchar DC0_ALA:1; //Power supply 0 alarm
    uchar DC1_ALA:1; //Power supply 1 alarm
    uchar AC_ALA:1; //Power failure alarm
    uchar UN_H_ALA:1; //Same frequency channel machine unlock alarm
    uchar UN_L_ALA:1; //Inter-frequency channel machine unlock alarm
    uchar FAR_ALA:1; //Remote communication failure alarm
  uchar OPEN_ALA:1; //Door placket alarm
  uchar x:1;
  }ALARM; //System alarm structure definition
This structure occupies one byte width, and its order is:

  typedef struct
  {
    D0: uchar DC0_ALA:1; //Power supply 0 alarm
    D1: uchar DC1_ALA:1; //Power supply 1 alarm
    D2: uchar AC_ALA:1; //Power failure alarm
    D3: uchar UN_H_ALA:1; //Same frequency channel machine unlock alarm
    D4: uchar UN_L_ALA:1; //Inter-frequency channel machine unlock alarm
    D5: uchar FAR_ALA:1; //Remote communication failure alarm
    D6: uchar OPEN_ALA:1; //Door placket alarm
    D7: uchar x:1;
  }ALARM;//System alarm structure definition

do you understand?


Keywords:C51 Reference address:Position relationship of bit fields in bytes in C51

Previous article:Solution to the problem of Keil c51 U3 character display misalignment
Next article:How to use bit field function in C51?

Recommended ReadingLatest update time:2024-11-16 03:28

C51 Programming Interrupts and Register Usage
If registers are used in the interrupt service function ISR, the use of using must be handled properly: 1. The interrupt service function uses using to specify a register bank different from the main function (the main function generally uses Register bank 0). 2. ISRs with the same interrupt priority can use using to
[Microcontroller]
C51 MCU addressing structure
I have been using uc/os recently and need to learn assembly
[Microcontroller]
C51 MCU addressing structure
[C51 code] MAX7219 driver
/***************max7219.h****************/ #ifndef _max7219_h_ #define _max7219_h_ #include Atmel/AT89X51.h #include "link.h" /***************Control pin definition****************/ sbit _7219_DIN = P2^0; sbit _7219_CS = P2^1; sbit _7219_CLK = P2^2; /***************Control word definition****************/
[Microcontroller]
C51 programming 1-output level (light up LED 1)
In the 51 single-chip microcomputer, there are 4 groups of I/O ports, namely P0, P1, P2, and P3; I/O (Input/Output) port, Input represents input level signal, and Out represents output level signal. In digital circuits, there are two levels: high and low levels, that is, the I/O port can input or output high and low l
[Microcontroller]
C51 programming 1-output level (light up LED 1)
【C51 MCU】99-second countdown with digital tube
C51 MCU digital tube to achieve 99 seconds countdown (combined with timer) - STC89C52 MCU code show as below: #include reg52.h typedef unsigned char u8; typedef unsigned int u16; sbit b1 = P2^2; sbit b2 = P2^3; sbit b3 = P2^4; u8 duan = {0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x6f, 0x77, 0x7c, 0x39
[Microcontroller]
C51 Manual Calculation Timer Interrupt Introduction
The following is calculated by software: 12M crystal oscillator, timer mode 16 bit, 12T, 1 millisecond time void Timer0Init(void) //1 millisecond@12.000MHz{ AUXR &= 0x7F; //Timer clock 12T mode TMOD &= 0xF0; //Set timer mode TMOD |= 0x01; //Set timer mode TL0 = 0x18; //Set the initial timing value TH0 = 0xFC;
[Microcontroller]
X25045/X5045 standard function set based on C51
The C51 version that is widely circulated on the Internet is Pang Bo's "25045 Operation Standard Subroutine Set 41.c", but after I actually used it, I found some errors, such as the difference between & and && and some logical problems. In addition, people always ask about the circuit connection method. Since the X250
[Microcontroller]
Keywords in C51
Keyword Purpose Description auto Storage type description Used to describe local variables, the default value is this break Program statement Exit the innermost loop case Program statement Selection item in Switch statement char Data type description Single-byte integer or character data const Storage type descrip
[Microcontroller]
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号