Career change to engage in hardware. ACM is to go to the end, after all, electronics is their own professional characteristics.
The first single-chip microcomputer, buy the board is stc89c52 (a treasure 58 of the ocean Amoy. Guo Tianxiang The new concept of the book (seems a bit not matching but live to get it also. )
Let's talk about the mistakes that are easy to make.
1. The serial drive has been engaged for 1 hours. Have not been installed, then followed the tutorial to do
2. The book on the control led port is P1, but actually bought this allegro is P2, the first to engage in a half-day always dot not light, and then a think will be wrong port, and 0 try? Changed no, and changed 2. Bright (This is a problem, later to look for seniors to ask, how to see the Development Board according to the port of each module?) I haven't found it for a while. )
3. Engineering code is a bit less used to knocking up. and spit a bit Keil 4, not indentation can not be happy to play.
Content:
One: LED operating principle
Post schematic diagram.
The first reading on the principle is very abstract. This is a good picture, very clear.
Two: Code realization running Lights
Basic idea: The initial state is 1111 1110 that is, only the leftmost light is lit, and then the interval to the right to move 0, (with the displacement function _crol_ (A, A, b) to the left of a bit, the loop left is not like the << operation of the lowest bit 0, the right to move their own brain compensation for the delay function. In fact, the loop is jammed, about O (24700000) ==10ms
#include <reg52.h> #include <intrins.h> #define gpio_led p2#define uint unsigned int#define uchar unsigned Charvoid delay10ms (uchar n); void Main () {Uchar I; Gpio_led=0xfe;//1111_1110while (1) {for (i=0;i<7;i++) {Gpio_led=_crol_ (gpio_led,1);D elay10ms (1);} for (i=0;i<7;i++) {gpio_led=_cror_ (gpio_led,1);D elay10ms (1);}} void delay10ms (Uchar N) {uchar I,j,k;while (n--) { i=50;while (i--) {j=38;while (j--) { k=130;while (k--);}}}}
51 single-chip computer first---running lights