Homemade MCU Part 12… Making and debugging the AT89C2051 programmer

Publisher:mu22Latest update time:2016-12-15 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

  Now everyone uses S52, why use C2051! The price is similar. But C2051 is much smaller than S51 and S52, and it has only 20 pins. In some simple control, these pins are enough, and the small size is more advantageous. But it seems that there is no S2051 that supports online programming (ISP) at present. So I tried to make a programmer for C2051, and more importantly, I want to share with you the debugging skills of hardware and software in the process of circuit manufacturing, and try to achieve the experience and methods of success at one time. I
  searched on the Internet and found many pictures, which are similar. The most common picture is:

The above picture shows a circuit that can burn many devices. Its PCB board is also easy to find on the Internet. But because it is an experimental production, no PCB is used, so a multi-purpose board is used. Since wide-body devices all support ISP, I removed the 40-pin wide-body IC socket and only left a 20-pin narrow-body IC socket for burning C2051. After modifying the circuit, the circuit diagram is as follows:

The components list is as follows:

1/8w 4.7k 6 (6 in total) 
560r 3 (3 in total) 
2k2 1 
4.7 ohm 1 connected in series with the power supply circuit for protection10k 
resistor 1 used for CPU p0 port pull- 
up1n4148 2 used for vpp high voltage supply (note that one end of 4148 is black) 
12v 1 used for vpp high voltage supply (note that one end of 12V is white, don't get confused) 
4.7uf/50v 8 Use the same model for all electrolytics, pay attention to the direction104
2 used for power supply filtering22p 
2 used for crystal circuit11.0592 
1 crystal2n5401 
1 pay attention to the model and the direction of insertion, don't make a mistake! 
2n5551 2    
LEDs 2 3mm white to red (for power indication and communication indication) (pay attention to the direction) 
db9 1 serial port 
20pin card holder 1 40pin ic holder for burning 2051, etc. 
1 89s51 16pin ic holder for inserting monitoring  1
max232 chip 
usb holder 1 serial cable for 
power supply 1  usb cable for communication 1 At89s51 for
power supply  1 for monitoring max232cpe 1 integrated circuit for communication  pcb 1 circuit board


The actual board has been completed today, let's show it first. Then I will talk about the detailed debugging methods and steps:

 


(Click to see the full picture)

  This circuit may be a little complicated for beginners. It is divided into several parts. If you plan the circuit board first, then solder all the components at once, and then debug, the probability of success is very small. So what should you do? First plan the position layout of the components, then divide it into several units, debug after a unit is completed, and then proceed to the production and debugging of the next unit after it is normal. My plan is as follows, first the power supply part including the power indicator LED:

First solder the USB socket, and then plug in the USB power supply after confirming that there is no short circuit. Use a multimeter to find out which of the two points A and B is the positive pole of 5V and which is the ground. Then remove the power supply and solder the remaining capacitors, resistors and LEDs. After confirming that there is no short circuit, connect the power supply and the LED should light up. I changed the current limiting resistor of the LED to 2K because I think it is bright enough. The current is 1.5 mA. The actual object is as shown in the red circle on the right.

The second part is MAX232, including the +12v voltage regulator circuit. MAX232 is a special IC for TTL to RS232 conversion. It provides a positive 10v and negative 10v boost circuit inside. We use its boost circuit to get a +12v power supply.

We first solder the 9-pin serial port, but do not connect the MAX232. In the MAX232 area you planned, solder the MAX232 socket and four capacitors according to the circuit on the left side of the above figure. After checking that there is no short circuit, plug in the MAX232 and connect the power supply. The voltage of +9v-+10v should be measured at point A. There should be a voltage of -9v--10v at point B. Connect pin 10 to the ground, and pin 7 should be +10V. If pin 10 is connected to +5v, then pin 7 becomes -10v. In this way, the MAX232 is normal. Connect pin 2 of the serial port to pin 7 of the MAX232. Connect pin 3 of the serial port to pin 8 of the MAX232. Connect the power and connect pin 10 of the MAX232 to ground and +5v respectively to see if pin 2 of the serial port changes as before. After the above debugging is correct, solder the 12V voltage regulator circuit on the right side of the above figure. As shown below:

Use a multimeter to measure a stable +12V voltage at both ends of the voltage regulator tube. In this way, your serial port conversion and 12V power supply circuit are debugged normally.

  The third part is the 12V burning control part: the circuit and physical diagram are as follows:

After this part of the circuit is soldered, connect the normal +12v and power supply +5V of the second part. First measure whether the +12v access point and the power supply voltage +5v on the circuit are normal. Then measure point A in the above figure, which should also be +5v. Then you connect VO13 to +5V with a wire, so point A is +9v-+11v. Good! Disconnect VO13, and then connect V014 to +5v with a wire, and point A should be close to 0. In this way, the 12V burning control circuit is also debugged correctly.

  The following is the circuit of S51 part, as shown below:

This part of the circuit includes the pull-up resistor of the P0 port and the receiving indicator LED connected to the 10th pin of S51. Don't forget to connect the 31st pin (EA/VP) of S51 to the power supply +5v. First make sure that the connection between the 9th pin of MAX232 and the 10th pin of S51 is disconnected (because the 9th pin of MAX232 will output +5v high level after debugging normally, which will light up the receiving indicator LED and hinder the inspection of the working performance of S51). After checking that the circuit is correct, plug in the S51 chip and connect the power supply. The static current should be around 9-12mA. Good! Open KEIL and write a test program:
#include
#define uchar unsigned char
main(void)
{
uchar i,j,k;
while(1)
   {
     for(i=0;i<1;i++)
       {
         for(j=0;j<255;j++)
    for(k=0;k<255;k++);
       }
     P3_0=~P3_0;

   }
}

This program is to make the LED connected to the 10th pin (P3.0) of S51 flash. If it flashes, it means that the crystal oscillator is oscillating and the S51 circuit is working properly. Compile it, then use ISP to write this program into the S51 chip, and then insert it into the 2051 burner we made. After connecting the power supply, my circuit immediately works normally and the LED is flashing. If the LED does not respond, you have to check whether your S51 circuit is connected normally, whether the crystal oscillator is soldered correctly, etc.
  After the S51 circuit is normal, we have to solder the 9th pin of the MAX232 that was just disconnected to the 10th pin of the S51. At this time, we will write another test program:
#include
#include

void main(void)
{
SCON=0x50;
TMOD=0x20;
PCON=0x80;
TCON=0x40;
TH1=0xfd;//比特率19200
TL1=0xfd;
TI=1;
TR1=1;
while(1)
{
    printf("hello World!\n");
}
}

This program opens the serial port of the S51 microcontroller and continuously sends out the string "hello World". Compile it into a HEX file, and then use ISP to write the program into the S51 chip. Then plug it into the 2051 programming board. Connect the serial port cable to the PC. Turn on the PC and run the serial port debugger:

Set the baud rate of the red circle to 19200. Confirm it is COM1 port. Then power on the 2051 programmer, and "hello world" will appear on my PC serial debugger immediately.

In this way, the serial communication with the PC is debugged successfully. If you do not get the correct result, and the debugging in the above steps is normal, then there is an error in the wiring from the PC serial port to your S51. Check your wiring carefully and you will find the error.

  After the above steps are normal, it is time to integrate the circuits that have been debugged normally in these steps. Connect the 12v burning control terminal VPP to the 1st pin of 2051, and connect VO13 and VO14 to the 13th and 14th pins of S51 respectively. Connect the 15th pin VST of S51 to the 9th pin of 2051. Connect the 1st pin (P1.0) of S51 to the 11th pin of 2051. Connect the 5th, 6th, 7th and 8th pins of S51 to the 5th, 6th, 7th and 8th pins of 2051 respectively. Connect the P0 port (pins 32-39) of S51 to the 12th-19th pins of 2051 respectively. Don't forget to connect the power supply and ground of 2051.

 

OK! After checking everything, connect the power supply and try again to see if the serial communication is normal (to prevent the S51 from not working due to incorrect soldering after soldering). Unplug the S51, use ISP to write the E51Pro.HEX driver firmware into the S51, and then plug it into the 40-pin S51 socket, plug the AT89C2051 into the 20-pin IC socket, connect the PC serial port, run the Easy 51Pro V2.0 on the PC, and then power on the 2051 burner. Select AT89C2051 on the PC software, click on the device detection, mine is 1e 21 FF. Then try to open a HEX file, click on auto-complete, it will complete the device detection, erasing, writing, verification and other tasks, as shown below:

If your device is not found, but the previous serial communication and other debugging are normal, then the wiring in the last step may be wrong. Carefully check your wiring and whether the power supply and grounding of the C2051 socket are normal.

  OK, dust it off, it's done. I can finally go to the side and have a cup of tea and cool down! Give me some applause! Is it easy? I...!

 Summary: Developing a habit of debugging step by step is very beneficial to the success of the circuit. If there is a problem, the scope of debugging can be minimized.


Reference address:Homemade MCU Part 12… Making and debugging the AT89C2051 programmer

Previous article:Homemade MCU Thirteen…Clock IC_DS1302
Next article:Homemade MCU XI…Analog-to-digital conversion IC ADC0809

Recommended ReadingLatest update time:2024-11-16 14:26

Schematic diagram of 6-bit electronic clock based on AT89C2051
The principle of the 6-bit electronic clock using AT89C2051 is shown in the figure below. As long as the hardware connection is correct, success is guaranteed. In addition, the SET button in the picture is used to calibrate the time. Press and hold for more than 2 seconds to enter the calibration time state, shift gea
[Microcontroller]
Schematic diagram of 6-bit electronic clock based on AT89C2051
Design and implementation of thyristor trigger circuit based on AT89C2051 single chip microcomputer
Since thyristors were used as switching elements, their trigger circuits have gone through the thyristor separation component stage and the integrated circuit stage and then entered the single-chip microcomputer embedded stage. Although the use of a trigger circuit with a single-chip microcomputer as the core avoids th
[Microcontroller]
Design and implementation of thyristor trigger circuit based on AT89C2051 single chip microcomputer
Design of intelligent fast charging system based on AT89C2051 single chip microcomputer
    1. Introduction   It has been 140 years since the French physicist Plante invented the lead-acid battery in 1859. Lead-acid batteries have the advantages of low cost, wide applicability, good reversibility, good high current discharge performance, high voltage of single cells, and can be made into sealed maintena
[Microcontroller]
Design of intelligent fast charging system based on AT89C2051 single chip microcomputer
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号