Use MPLAB X to configure PIC microcontrollers

Publisher:科技创造者Latest update time:2020-01-22 Source: eefocusKeywords:MPLAB  configuration Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Recently, I have a project that requires me to use a PIC microcontroller for development (I have never used it before). I encountered many problems that I don't understand. Here I summarize the problems I encountered and the corresponding solutions. I hope there will be guidance from experts, and I also hope to help friends like me.


1. Introduction to PIC microcontrollers

I have played with 51 and STM32 microcontrollers before. I was confused when I first started. I didn’t know where to start when I got the data sheet. I searched for information online and saw “Guo Tianxiang teaches you to play with PIC microcontrollers in ten days”. Of course, the microcontroller used in the video is not the model of the microcontroller I use, but watching the video can provide a direction. It is not necessary to watch the entire video. You can read the data sheet and write the code if you have an idea. The following is a link to the relevant video (including relevant code, thanks to the enthusiastic netizens for sharing!). (PS: Thank you again, Mr. Guo Tianxiang, from 51, DXP, etc., I learned from watching your videos!)

(Video with code)

Link: https://pan.baidu.com/s/1tJRE3OJ8s9DC-90nlxmfLQ

Extraction code: a0ge


Link: https://pan.baidu.com/s/18SGLYs5Dcv5YSyY_MGjJuA

Extraction code: g0f0


2. The first configuration problem encountered

Since I am using MPLAB X V5.0 IDE and XC8 (V2.0) compiler, I encountered a problem during configuration. The video uses __CONFIG(X);--[pic16F series] to configure (PIC16F&PIC18F use different methods), and an error message appears during compilation: Unexpected tag

I can't find the reason at the moment (I hope someone who knows can give me some guidance), so I searched online for information and found that the software can be configured by itself. The operation is as follows:


If you have multiple projects open, be sure to set the project you want to operate as the main project, as follows:

Open the configuration interface as follows

The configuration interface is as follows:

After configuring according to the data sheet and actual conditions, the motor "outputs and generates source code" will generate the corresponding source code based on your configuration:

Just copy the code into your source file.


------------------------------------------------------------------------------------------------------------------------------------------------------


------------------------------------------------------------------------------------------------------------------------------------------------------


The above configuration can be realized. If I want to configure other projects, I must set this project as the main project, because the MCU model of each project may be different, and the configuration may also be different

This is the configuration of another test project of mine.


------------------------------------------------------------------------------------------------------------------------------------------------------

3. Regarding the writing of interrupt functions.


It is also different from the video. The video uses the form of void interrupt tim0(), but when I use the compiler XC8 (V2.0), it cannot be compiled.

hint:


main.c:81:6: error: variable has incomplete type 'void'


void interrupt isr_deal(void)


main.c:81:15: error: expected ';' after top level declarator


I don't know the reason, but it can be compiled when using XC8 (V1.45). (Please give me some advice!)


Refer to the XC8 (V2.0) compilation manual, and write it in other forms to compile. The manual is opened as follows:


1. Click "Compiler Help" as shown in the picture.

2. Go to the corresponding local help website

Click to open the corresponding document to view the relevant instructions.


If you cannot open the website, you can find it in the compiler installation directory, such as mine:

Find the corresponding document in.


---------The above, there will be updates later.

Keywords:MPLAB  configuration Reference address:Use MPLAB X to configure PIC microcontrollers

Previous article:PIC microcontroller serial port transmission and key press
Next article:PIC Microcontroller Getting Started Tutorial (IV) - The First Project

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

NXP Launches New i.MX 8XLite Applications Processor for Secure V2X Applications
According to foreign media reports, NXP Semiconductors announced the launch of its new i.MX 8XLite application processor, focusing on secure V2X and industrial IoT applications. The SoC features NXP's integrated EdgeLock® security and is designed to meet FIPS 140-3 while performing highly complex encryption and proces
[Automotive Electronics]
NXP Launches New i.MX 8XLite Applications Processor for Secure V2X Applications
Huawei Sound X 2021 real machine exposed: supported by Hongmeng distributed sound system
     Tonight at 19:30, Huawei will hold a flagship new product launch conference with the theme of "A New Life of All Things", at which time the long-awaited Huawei P50 series will be officially released.   Of course, in addition to the protagonist P50 series, Huawei's new generation Sound X, smart screen and other ne
[Mobile phone portable]
MCU+MPU= Sitara™ AM2x
Texas Instruments (TI) recently announced the launch of a new high-performance microcontroller (MCU) product series Sitara™ AM2x for real-time control, networking and edge analysis applications in industrial applications. The new Sitara AM2x MCU has 10 times the computing power of traditional flash-based MCUs, thus
[Embedded]
MCU+MPU= Sitara™ AM2x
Micron Crucial X6 Portable SSD Coming Soon
Crucial®, Micron's global consumer brand for computer memory and storage, today introduced an expansion of its highly recognized mobile solid-state drive (SSD) portfolio, providing consumers with more external storage performance, capacity and value options at a wide range of price points. New products to be launched
[Embedded]
Micron Crucial X6 Portable SSD Coming Soon
vivo V1 official announcement: Blue Factory's self-developed imaging chip will be used in X70
      On the morning of August 27, Hu Baishan, executive vice president of vivo, communicated with the media today and explained the recent rumors about the self-developed chip. He confirmed the existence of "vivo V1", which is a self-developed imaging chip of vivo, which will be used in the X70 series of mobile phone
[Mobile phone portable]
Using C50x to control brushless DC motor
Using C50x to control brushless DC motor Brushless DC motors are becoming more and more widely used due to their easy control, no commutator, simple structure, high speed and high efficiency. The continuous introduction of various special chips has further promoted its application and development. C50x is a sin
[Analog Electronics]
Using C50x to control brushless DC motor
Simulation of 16x16 dot matrix horizontal scrolling with 4 74HC595 cascade control (Part 1)
Preface: I bought a 51 development board from Taobao for learning. Its 16*16 dot matrix screen is controlled by 4 74HC595 cascades. This method is convenient for changing the row and column refresh mode, but each time a row or column is displayed, 32-bit data is serially input and then output in parallel. The s
[Microcontroller]
Simulation of 16x16 dot matrix horizontal scrolling with 4 74HC595 cascade control (Part 1)
Infineon TLE983x Intelligent Automotive Relay Driver Solution
The TLE983x from Infineon is a single chip solution that integrates a high performance 8-bit microcontroller derived from the established XC800 family with application specific power drivers, control and communication modules in an automotive qualified new Smart-Power Technology. The TLE983x family concept offers scala
[Power Management]
Infineon TLE983x Intelligent Automotive Relay Driver Solution
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号