Introduction to the _crol_ function
Cx51 User’s Guide
Summary
#include unsigned char _crol_ ( unsigned char c, /* character to rotate left */ unsigned char b); /* bit positions to rotate */ Description The _crol_ routine rotates the bit pattern for the character c left b bits. This routine is implemented as an intrinsic function (starting from bit 1 in the c variable and moving left b bits at a time, for example, when b = 1, the string of numbers will move like this: 1111110–>11111101) Return Value The crol routine returns the rotated value of c. Example #include void test_crol (void) { char a; char b; a = 0xA5; b = _crol_(a,3); /* b now is 0x2D */ } Flowing light code Using AT89C52 chip, crystal oscillator is 11.0592MHz #include #include #define uint unsigned int #define uchar unsigned char void delay(uint time); void main() { uint led = 0xfe; //11111110 while(1){ P1 = led; //11111110 Turn on the first light of P1 port first delay(500); //delay 0.5s led = _crol_(led,1); //Call the _crol_ function to shift the led variable left from the first one 11111110-->11111101 //Return to led, now led = 11111101 } } void delay(uint time) //delay = 1 ms 0.001s { uint x; uint the; uint z; for(z = time; z > 0; z--){ for(x = 1; x > 0; x--){ for(y = 115; y > 0; y--){} } } } Proteus simulation diagram
Previous article:51 MCU Getting Started Tutorial (2) - Implementing a Flowing Light
Next article:51 MCU Tutorial The first 51 program: Light up a light-emitting diode
Recommended ReadingLatest update time:2024-11-15 07:51
- Popular Resources
- Popular amplifiers
- MCU C language programming and Proteus simulation technology (Xu Aijun)
- 100 Examples of Microcontroller C Language Applications (with CD-ROM, 3rd Edition) (Wang Huiliang, Wang Dongfeng, Dong Guanqiang)
- Fundamentals and Applications of Single Chip Microcomputers (Edited by Zhang Liguang and Chen Zhongxiao)
- Single chip microcomputer control technology (Li Shuping, Wang Yan, Zhu Yu, Zhang Xiaoyun)
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- CGD and Qorvo to jointly revolutionize motor control solutions
- CGD and Qorvo to jointly revolutionize motor control solutions
- Keysight Technologies FieldFox handheld analyzer with VDI spread spectrum module to achieve millimeter wave analysis function
- Infineon's PASCO2V15 XENSIV PAS CO2 5V Sensor Now Available at Mouser for Accurate CO2 Level Measurement
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- A new chapter in Great Wall Motors R&D: solid-state battery technology leads the future
- Naxin Micro provides full-scenario GaN driver IC solutions
- Interpreting Huawei’s new solid-state battery patent, will it challenge CATL in 2030?
- Are pure electric/plug-in hybrid vehicles going crazy? A Chinese company has launched the world's first -40℃ dischargeable hybrid battery that is not afraid of cold
- Research on Several Issues of Portable Image Acquisition System Based on ARM and FPGA
- Please give me some advice!
- Analysis of the switch input circuit composed of four diodes
- Analysis of common problems in TMS320C2000 projects?
- Clock chip problem
- 18 Ways to Draw PCB Routes
- Hardware circuit design based on STC microcontroller
- [Sipeed LicheeRV 86 Panel Review] 12-Waft Routine Analysis and Button Function Test
- Be careful with the FPGA's JTAG port (power-on and power-off sequence)
- Process review is becoming increasingly difficult. How can we cut the Gordian knot?