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)
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.
Picc is the entry interface of the embedded ide
, which feels very familiar and is similar to keil, so I followed the prescription.
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!
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.
The following is the exciting compilation program. If the program is correct, this should appear:
Next, you can burn and simulate .
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.
I am burning, so I click program. The result is as follows.
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.
Previous article:Identification of PIC16F877 Matrix Keyboard
Next article:The relationship between PC, PCL and PCLATCH
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Detailed explanation of intelligent car body perception system
- How to solve the problem that the servo drive is not enabled
- Why does the servo drive not power on?
- What point should I connect to when the servo is turned on?
- How to turn on the internal enable of Panasonic servo drive?
- What is the rigidity setting of Panasonic servo drive?
- How to change the inertia ratio of Panasonic servo drive
- What is the inertia ratio of the servo motor?
- Is it better for the motor to have a large or small moment of inertia?
- What is the difference between low inertia and high inertia of servo motors?
- RF Energy Harvesting Technology
- 【Perf-V Review】Lighting Experiment
- [Raspberry Pi 4B Review] + DLNA Server Setup
- ATtiny85 Mini Violin
- MicroPython Hands-on (12) - Hello World on the Control Board
- What are the advantages and disadvantages of 2.4G Wi-Fi and 5G Wi-Fi?
- CPLD dual integral AD analog-to-digital conversion help
- USB Type-C Docking Design
- Miscellaneous talks on rectification (VIII)
- Things to note when selecting and using a POE switch