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.
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
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Let me show you how to calculate a current transformer!
- Theory and Implementation of Narrow-Band IF Sampling Based on DSP_C54X
- [RT-Thread reading notes] (1) Thread initialization and linked list
- Share the correct use and maintenance guide of NiMH batteries
- EEWORLD University Hall----Live Replay: The Latest Isolation Devices Compliant with USB 2.0 Standards
- EEWORLD University - Understanding PID Control (English subtitles)
- IAR Compilation Optimization Level Introduction
- Problem with peripheral clock enable statement
- Choosing the right ARM-based MCU
- EEprom write speed is slow