Some Problems in Online Programming and Debugging of PIC Microcontroller

Publisher:boczsy2018Latest update time:2011-12-30 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1 In-circuit serial programming

1.1 In-circuit serial programming interface

PIC microcontrollers with Flash memory generally have an online serial programming function, which only requires 5 wires to download the program to the Flash program memory of the microcontroller. The arrangement order of these 5 wires is MCLR/Vpp, Vdd, Vss, PD (or PGD) and PC (or PGC). Figure 1 is a diagram of the online serial programming interface of the PIC microcontroller.


Figure 1 PIC microcontroller online serial programming interface

1.2 Pin meaning

The specific meanings of the above five pins are: MCLR/Vpp - programming voltage (generally around 13 V for PIC microcontrollers); Vdd - programming power supply (5 V); Vss - ground; PD - programming data signal; PC - programming clock signal.

With this programming connection circuit, only appropriate programming hardware circuit and programming software are needed to realize online serial programming and debugging of the microcontroller.

2 Online Debugger

2.1 Connection between the online debugger and the target board

The first generation of online debugger launched by Microchip is named MPLAB ICD, which supports online debugging and burning of PIC16F87X series microcontrollers, and has reliable performance, simple and convenient use. Based on MPLAB ICD, Microchip launched the second generation of online debugger named MPLAB ICD2 (hereinafter referred to as ICD2), which supports online debugging and burning of the full series of PIC Flash memory microcontrollers, and even supports online debugging and burning of Microchip's 16-bit microcontroller dsPIC. The connection between ICD2 online debugger and target board is shown in Figure 2. String 5

Figure 2 only shows the connection between the three important signals of ICD2, MCLR/Vpp, PGD and PGC, and the target board. ICD2's Vdd and Vss are connected to the target board in the normal way. If there are AVdd (analog power) and AVss (analog ground) on the target board, AVdd and AVss must also be connected to their corresponding power and ground on the target board. No power and ground pins can be left hanging to ensure that ICD2 can work normally during debugging.

2.2Problems that may occur with PGC and PGD signals

① As can be seen from Figure 2, the PGC and PGD pins of ICD2 are already connected to 4.7 kΩ pull-down resistors. Therefore, when users design circuit boards, these two pins on the circuit board should not be connected to pull-down resistors to avoid causing incorrect electrical levels.

② PGC and PGD are signal pins. For these two pins, there must not be any capacitors or other capacitive devices connected between ICD2 and the target board, otherwise it will affect the transmission of serial data and clock signals. PGC and PGD signals are bidirectional transmission signals. There must not be any diodes or other components blocking signal transmission between ICD2 and the target board.

2.3 Reset

MCLR/Vpp is the ICD2 programming voltage pin. The voltage should be around 13 V during programming. Another function of this pin is reset. We know that any microcontroller can cause a reset when powered on or in some other special circumstances. The reset of the microcontroller, power supply and crystal oscillation are the three necessary conditions for the microcontroller to enter normal operation. Therefore, the following issues should be noted.

① Do not connect a large capacitor, otherwise Vdd (power supply voltage) cannot be established quickly, affecting the reset. String 5

② A reset resistor of less than 10 kΩ should be connected in series between the Vdd (power supply voltage) and MCLR/Vpp of the target board, so that the MCLR/Vpp pin of the target board can be pulled down normally during reset, and the programming voltage can be maintained at around 13 V during programming.



Figure 2 Connection between the in-circuit debugger and the target board

③ The reset resistor cannot be too large and must be less than 10 kΩ. According to the author's experience, for PIC16F87X series microcontrollers, normal reset can be achieved when the reset resistor is 10 kΩ or less; for PIC18FXX2 series microcontrollers, normal reset cannot be achieved when the reset resistor is 10 kΩ, and normal reset can be achieved by replacing it with a resistor of about 4.7 kΩ.

2.4 Application Practice

Due to the practicality and low price of ICD2, more and more users are using ICD2 online debugger. In the process of connecting ICD2 with the target board, it is very easy to have problems of one kind or another. For beginners and users who make their own target board, it is especially important to make a reliable connection between ICD2 and the target board. The so-called reliable connection means good contact. When making a target board, users should follow the descriptions in Sections 2.2 and 2.3 of this article. The target board produced can generally achieve normal connection with ICD2.

When the target board made by the user is connected to ICD2, if the connection fails, beginners, due to lack of practical experience, often cannot determine where the problem is, and even suspect that there is a problem with ICD2. At this time, you should first determine whether there is a problem with the target board. If there is no problem with the target board, you can only suspect that there is a problem with ICD2 itself or the connection between ICD2 and the computer.

String 1


Conclusion

This article focuses on the connection between the in-circuit debugger and the target board, reset, and solutions to problems that may arise. It has very strong practical and reference value and is hoped to attract the attention of readers who use in-circuit debuggers and save debugging time.

References

1 Wu Feng, Chen Xinjian. Introduction to PIC Microcontroller C Language Development. Beijing: Beijing University of Aeronautics and Astronautics Press, 2005
2 Zhang Mingfeng. Introduction and Practice of PIC Microcontroller. Beijing: Beijing University of Aeronautics and Astronautics Press, 2004

Chen Xinjian: Engineer, his main research direction is single chip microcomputer, hydraulic measurement automation and gate and dam safety monitoring automation.
Wu Feng: Senior Engineer, his main research direction is single chip microcomputer, hydraulic measurement automation and gate and pump station computer monitoring.

Reference address:Some Problems in Online Programming and Debugging of PIC Microcontroller

Previous article:Using BootLoader to Upgrade Online in PIC18 Microcontroller
Next article:Hot water controller based on PIC microcontroller

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号