PIC microcontroller debugging experience

Publisher:信息巫师Latest update time:2019-11-16 Source: 51hei Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

I am a beginner, a PIC beginner, but I have been in the microcontroller business for many years. To be honest, the C development environment is similar, except that burning and online simulation are similar. After two days of research, I received a lot of responses and inspiration.

At the request of soso, I will share my recent debugging experience with you .

1. Let me first talk

about what I want to do. To be ashamed, this is a temporary small task, to do a collection and display part, use two ADs to collect analog quantities, and switch through switches. Simply put, when the switch is turned on, one analog quantity is displayed; when the switch is closed, another analog quantity is displayed. The main circuit is very simple, I will just say it directly without attaching pictures. The power supply returns to the negative pole of the power supply through a load (a sliding rheostat will do), and a current sensor is connected in the loop to collect the current signal in real time (if conditions do not allow, a constantan wire or a large wattage and small value sampling resistor can also be used to collect the current signal. Then it is amplified and isolated and sent to the AN0 port of the microcontroller. Another AN1 can be used to collect another analog quantity, the specific one is to be determined, it can be temperature or voltage (time is short, I made 1 channel, and the other channel is waiting for the senior people to develop it, haha)
114618osrs2s8rd3pjsojp.jpg.thumb.jpg 

2. The problem I encountered
For me, pic is a new thing. I have to start from the beginning, which is not long, 72 hours. To me, this kind of microcontroller is cheap, small, simple in structure, and programmed in C, which is more to my taste. The disadvantage (that is, what tormented me) is simulation and burning.
Like other microcontrollers, each manufacturer has launched its own C compilation environment and development environment. Our pic uses ide and picc (not an insurance company), as shown in the figure.
114618o4ycwxmpkxkkexdw.jpg.thumb.jpg 
Picc is the entry interface of the embedded ide
, which feels very familiar and is similar to keil, so I followed the prescription.

114618jrb0bcfedctgz67u.jpg.thumb.jpg 
Think about it through the project and create a project. Select the chip you use and the compiler, as shown in the picture, the path of picc.exe can also be seen!

114619cjd7lmjdslzsjwjl.jpg.thumb.jpg 
Create a new project, but do not import the c file.
Click the project under the VIEW menu bar, right-click on the source, add the c file, if there is no c file, create a new c file, and then add it to the source. After importing, it will be as shown in the picture.

114619rfujugtm0fgeku18.jpg.thumb.jpg   

The following is the exciting compilation program. If the program is correct, this should appear:

114619jupujshhsdxjjas8.jpg.thumb.jpg   
Next, you can burn and simulate .

114620jzjgxdpdsfp8j6zf.jpg.thumb.jpg   
Before that, you need to make some necessary settings, just click the picture above, in Configue.
Then, select the device through the Programmer and Debugger. I use ICD2 and select ICD2. The next
step is to connect. If you want to simulate, change Release to Deb ug, then click connect in the debugger. If you want to burn the program, click connect in the programmer. Success looks like this.

114620x8v9vc32fh343fd8.jpg.thumb.jpg   
I am burning, so I click program. The result is as follows.

114620ro1wtw0wwc22qpcb.jpg.thumb.jpg 
Online simulation. I am also studying it. It would be better if there are experts who can give me some advice. I will share it with you here.

Finally, let me talk about what I have learned. When I come into contact with new objects, my first reaction is confusion and I don’t know where to start. Of course, this is impossible to accomplish anything. To think of a way to solve all this, the first thing is to find someone who understands. If there is really no such person around you, then go to the Internet. There are many talents in our forum. Then I thought of the Internet, looking for the necessary resources, datasheets, reference header files, datasheets and our circuit diagrams to do rough program design. I mean things like block diagrams and processes. After writing the program, you must repeatedly ponder it. It is possible that a careless mistake may cause the program to fail. I have encountered this before. I searched for a while but couldn’t find the problem. It turned out that a small bit of a register was written incorrectly.

The purpose of writing this post is to give some inspiration to beginners like me who have been searching hard. If I can help learners in trouble, I will feel extremely honored.

Reference address:PIC microcontroller debugging experience

Previous article:Identification of PIC16F877 Matrix Keyboard
Next article:The relationship between PC, PCL and PCLATCH

Latest Microcontroller Articles
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号