The base bit (CY) and data move left and right

Publisher:EtherealEssenceLatest update time:2015-05-19 Source: 51hei Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
1. Picture

2. Code
3. Summary

 


  Code
 
#include
sbit led=P2^0;
sbit led2=P2^1;
void DelayUs2x(unsigned char t)
{   
 while(--t);
}
void DelayMs(unsigned char t)
{
     
 while(t--)
 {
     //roughly delay 1mS
     DelayUs2x(245);
DelayUs2x(245);
 }
}
/*The following function is the essence of reverse scanning*/
unsigned char jpsm() //Matrix keyboard reverse scanning
{
unsigned char i=0; //Used to receive key value 
P0 = 0x0f; //Detect the lower 4 bits
if(0x0f != P0) //Detect whether the key is pressed
{
DelayMs(10); //Debounce
if(0x0f != P0) //Judge whether the key is really pressed instead of other interference
{
i = P0; //Assign the lower 4 bits to i
P0 = 0xf0; //Check the upper 4 bits
DelayUs2x(5); //Slight delay. This statement can be removed
i = i | P0; //Combine the lower 4 bits and the upper 4 bits into a complete key value
while( 0xf0 != P0 ) //Check if the key is released
{
;
}
return i; //Return the key value
}
}
return 0; //Return 0 if the key is not pressed
}

void main()
{
unsigned char i=0xaa;
while(1)
{
if(126 ==jpsm()) //Judge whether button 1 is pressed
{
/*i <<= 1; //Note: In the Keil compiler, no matter whether it is left shift or right shift, the shifted data is placed in CY
led = CY;*/
i >>=1;
led = CY;
        }
}  
}


Summary
1. What is a carry digit?
    Answer: It is used to store the carry digit.

Reference address:The base bit (CY) and data move left and right

Previous article:Communication method between single chip microcomputer and human-machine interface
Next article:How many bytes does a pointer occupy?

Recommended ReadingLatest update time:2024-11-17 00:25

LED Manufacturer Achieves Full Traceability with DataMan Barcode Readers
Overview challenge Verify that all finished components have completed each production process stage without omission and have passed the necessary tests to ensure full traceability. solution Lumileds has deployed a traceability system that uses DataMan barcode readers to read the laser-marked 2D codes on all L
[Power Management]
LED Manufacturer Achieves Full Traceability with DataMan Barcode Readers
A problem about data and xdata encountered in C51 has been solved
environment: I defined a structure variable in a C file, and then the variable was only used by a function in this file. Then I called the function in an interrupt to change the output state of an IO port. As a result, I could not achieve the desired effect when executing it. struct BE   {       unsigned int Coun
[Microcontroller]
aiMotive Launches aiData, Integrated, Cost-Effective, Data-Driven Autonomous Driving Pipeline
According to foreign media reports, aiMotive, an independent technology team in the field of autonomous driving technology, announced the launch of aiData, the latest member of its product portfolio. This tool is an integrated, cost-effective, data-driven autonomous driving pipeline that has been used for internal dev
[Automotive Electronics]
aiMotive Launches aiData, Integrated, Cost-Effective, Data-Driven Autonomous Driving Pipeline
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号