Wednesday, December 15, 2010

Weak current College】 【MCU c language tutorial-lesson two: a preliminary understanding 51 chip】.

<br> The previous lesson, our first project was completed, you may have read C language friends would say, "this PC of the C language does not have much of a difference?". Indeed there is no significant difference between the C language .is a programming language for the generic term for a different processor related C language will have some details of the change. Write PC C program, such as the hardware programming you have on the hardware you want to have a sense of 51 microcontroller programming is even .more so, because of its application is out of touch with the hardware, so we have to come to a preliminary understanding about 51 bi film structure and PIN feature. MSC51 schema are many kinds of chips, specific features and capabilities vary (later wrote the .Appendix will join some of the commonly used 51 chip information list), for the next tutorial in the Atmel AT89C2051 AT89C51 and company as a Center for learning object, which is the typical representative AT89 series, in use considerable fans, application information, price, .is the preferred chip 51 beginner. Hei Hei, saliva is a bit more suspected of selling advertising.: P figure 2-1 AT89C51 and AT89C2051 pin function diagram <br> <h1 align="center"> AT89C51 <h1 align = "center ."> AT89C20514KB programmable Flash memory (erasable 1000 times) <? xml: namespace prefix =" O "?> <o:p> </ o: p> 2KB programmable Flash memory (erasable 1000 times) <o:p> </ .o: p> three levels of confidentiality <o:p> </ o: p> program memory, both at the level of confidentiality <o:p> </ o: p> program memory static work <o:p> </ .o: p> 0Hz-24MHz frequency: static work <o:p> </ o: p> 0Hz-24MHz frequency: 128 bytes <o:p> </ o: p> internal RAM 128 bytes <o:p> < ./ o: p> internal RAM, two 16-bit <o:p> </ o: p> timer / counter 2 a 16-bit <o:p> </ o: p> timer / counter with a <o: .p> </ o: p> serial communication port of an <o:p> </ o: p> serial communication port 6 <o:p> </ o: p> each interrupt source 6 <o:p> </ .o: p> each interrupt source 32 <o:p> </ o: p> I / O leader 15 <o:p> </ o: p> I / O leader on-chip oscillator <o:p> </ .o: p> when a 1-chip <o:p> </ o: p> analog comparator in table 2-1 AT89C51 and main properties table AT89C2051 <br> <o:p> Figure 2-1 is AT89C51 and PIN function .figure AT89C2051. And table 2-1 is their main performance table. Above you can see they are largely the same, because the AT89C2051 IO lines rarely, cause it was unable to process additional RAM and ROM, on-chip Flash memory or less, .but its volume ratio AT89C51 small lot, then you can choose according to actual needs. Each has its characteristics but its core is the same, here's a look at the specific features of pin-AT89C51. <br> 1. the power supply pin < .br> Vcc power-40 <br> GND ground terminal 20 <br> * Operating voltage is 5V, AT89LV51 operating voltage is 2.7-6V, pin function. </ o: p> 2. external crystal pin figure 2-2 external crystal .pin <br> XTAL1 19 <br> XTAL2 18 <br> On-chip oscillator XTAL1 is reversed phase amplifier input, XTAL2 is the output, use an external oscillator, external oscillator signal should be directly added to XTAL1, XTAL2 vacant. Internally, .the clock generator on the oscillation frequency pulse II, such as crystal oscillator for 12MHz, clock frequency for 6MHz. Crystal oscillator frequency can be selected within the 1MHz-24MHz. Capacitor takes about 30PF. <br> * Type the same as AT89C51 chips, .in their number followed by a frequency, 12, 16, 20, 24MHz optional. We buy and pay attention to when choosing. If AT89C51 24PC is maximum oscillation frequency to 24MHz, 40P6 package ordinary commercial chips. 3. reset RST 9 <br> .The oscillator runs, two machine cycles (24 oscillation cycle) or more high level appear in the cited leg, will enable MCU reset, as long as the foot of maintaining a high level, 51 chip will reset cycle. Reset P0-P3 mouth are .reset 1 pin performance-high level, the program counter and the special function register SFR all zero. When you reset the foot becomes by high level low level, a ROM chip 00H began to run the program. Common reset circuit shown in Figure 2 - .3. <br> * Reset operation does not have an impact on the internal RAM. <br> Figure 2-3 common reset circuit <br> 4. input and output pins <br> (1) P0 port [P0.0- .P0.7] P0 is an 8-bit-drain-bi-directional i / o ports, port 1 (on port write 1) for high-impedance input. As output is capable of driving 8 TTL. <br> On the internal .Flash program memory programming, receive instruction bytes; validation program output directive bytes, requirements connected to La resistance. <br> To access the external programs and external data memory, P0 port is the address of the time-of-conversion (low 8 - .bit) / data bus, visit internal pull-up resistor. <br> (2) P1 port [P1.0-P1.7] P1 is the one with internal pull-up resistors 8-bit bi-directional ports I / 0 .. Output can drive 4 TTL. Port </ h1> </ h1> 1, the internal pull-up resistor will port to high level, as input. <br> On the internal Flash program memory programming, receive low 8-bit address .information. <br> (3) P2 port [P2.0-P2.7] P2 is the one with internal pull-up resistors 8-bit bi-directional ports I / 0. Output can drive 4 TTL. Port 1, internal .pull-up resistor will port to high level, as input. <br> On the internal Flash program memory programming, receive high 8-bit address and control information. <br> To access the external programs and 16-bit external data memory, .the P2 mouth out of high 8-bit address. And in access to 8-bit address of the external data memory, the content on their PIN during this period will not change. <br> (4) P3 port [P3.0- .P3.7] P2 is the one with internal pull-up resistors 8-bit bi-directional ports I / 0. Output can drive 4 TTL. Port 1, internal pull-up resistor will port to high level, as input. <br .> On the internal Flash program memory programming, control information. In addition to the P3 port is also used for some specific features, please see table 2-2. <br> * P1-3 ports in input use, because of internal resistance, .have been received on the external la low pin outputs a certain amount of current. <br> P3 PIN use either feature P3.0 serial communication input (RXD) P3.1 serial communication output (TXD) P3.2 external interrupt 0 (INT0 .) P3.3 external interrupt 1 (INT1) P3.4 timer 0 input (T0) P3.5 timer 1 input (T1) P3.6 external data memory write gated WRP3.7 external data memory write gated RD table 2-2 P3 .port PIN use either feature table <br> Call! breath say, stop. Well, what? what is a pull-up resistor? pull-up resistor in brief is to pull the high level, usually 4.7-10 k resistor received Vcc power .supply and pull-low resistor for you is to lower the resistance level, GND ground received. Specific instructions are not here to discuss, or then look the other pin function. <br> 5. other control or reuse pin <br> (1 .) ALE / PROG 30 access external storage, ALE (address latches allow) output for latch address the low byte. Even if you do not access the external storage, ALE-still in constant frequency output pulse signal (this frequency is the frequency of the .oscillator 1 / 6). To access the external data memory, a ALE pulse. On the Flash memory programming, this PIN is used to enter programming pulse PROG <br> (2) the cited is PSEN 29 external program memory of the selected signals .output. When the program memory by external AT89C51 for instruction or constant, per machine cycle output 2 pulse that is both valid. But to access the external data memory, you will not have a pulse output. <br> (3) EA / Vpp .31 external access allows client. When the PIN access external program memory, you should enter a low level. To enable external access only AT89C51 program memory (address as 0000H-FFFFH), then the PIN must be kept low level. On the Flash memory .programming, to impose Vpp programming voltage. There are two Vpp voltage, similar chip maximum frequency values according to the additional numbers or chip features words. Specific as table 2-3. <br> <o:p> </ o: p> .<o:p> </ o: p> Vpp = 12V 5V <o:p> </ o: p> Vpp = <o:p> </ o: p> printing in chip surface <o:p> </ .o: p> on model AT89C51 <o:p> </ o: p> xxxx <o:p> </ o: p> YYWW <o:p> </ o: p> AT89LV51 <o:p> </ .o: p> xxxx <o:p> </ o: p> YYWW <o:p> </ o: p> AT89C51 <o:p> </ o: p> xxxx-5 <o:p> </ .o: p> YYWW <o:p> </ o: p> AT89LV51 <o:p> </ o: p> xxxx-5 <o:p> </ o: p> YYWW <o:p> </ .o: p> <o:p> </ o: p> tablets <o:p> </ o: p> within features Word 030H = <o:p> </ o: p> 030H 1EH = <o: p .> </ o: p> 030H 1EH = <o:p> </ o: p> 030H 1EH = <o:p> </ o: p> 031H 1EH = <o:p> </ o: p> 51H .031H = <o:p> </ o: p> 61H 031H = <o:p> </ o: p> 51H 031H = <o:p> </ o: p> 61H FFH <o:p> </ .o: p> 032H = 032H = <o:p> </ o: p> FFH 032H = <o:p> </ o: p> 05H 05H <o:p> </ o: p> 032H = 2 - .3 Vpp and chip models and on-chip features Word relations <br> See you on the PIN function AT89C51 should have a certain understanding, PIN in programming and validate the timing we here don't do more of that in general we do not need .to all it, unless you want your own development programmer. Off course we'll start with some simple examples to describe the syntax of C programs and writing skills, intermediate interspersed method related hardware knowledge such as serial port interrupt usage etc..

No comments:

Post a Comment