Start writing embedded

xiaoxiao2021-04-10  338

1. Choose a Keil environment compile

Need to use the frequency and actual system of the universal 8052 driver oscillator, the 12MHz write program is selected, then DEBUG, then run, then select the port, select Port 1. In this way we can see the effect of the simulation, we are the 5th pin of the control port 1 (pin 1.5)

2. The control port is passed through a special function register (SFR). This SFR is actually an 8-bit latch, that is, the value written to the port will remain unchanged, know that there is a new value written or reset; these 4 Each of the ports is represented by an SFR: their names are P0, P1, P2, P3, respectively; from physical view, their addresses are 0x80,0x90,0xa0,0xb0, respectively.

3. If you need to write data to the port, you can follow: unsigned char port_data; port_data = 0x0f; p1 = port_data;

As for the 5th pin of the write port 1, you can use the sbit led_pin = p1 ^ 5; then copy directly to LED_PIN (Note that this sbit is not standard C, but KEIL, so you need include At the same time, it is necessary to explain that this type is also Keil, it can only be 0 or 1, which declares that variables are placed in the BDATA space on the 8051 chip.

The method of producing a delay can be used to cycle with a fork, which can be nested.

转载请注明原文地址:https://www.9cbs.com/read-133249.html

New Post(0)