打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
PIC Microcontroller Primer – Tutorial #2

As promised, this part starts with a simple programming tutorial on the PIC12F675 microcontroller which shows you how to program and use it as a simple LED flasher. It’s assumed that you have successfully constructed your own PIC mini development board, and you have a PIC usb programmer (PIC Kit 2) in your hand. Well, then get ready to prepare your little hardware for this minor experiment, as instructed below.

Hardware Wiring

As you can see the hardware is very simple and only requires a 5mm Red LED and a 1K resistor, in addition to the PIC mini development board. The LED is connected between GPIO 2 (pin 5) of the PIC 12F675 microcontroller and the ground (0V) rail through the 1K current limiting resistor.

Software Code

For the sake of simplicity, a 'ready-to-use’ hex code is used here. Just download the hex file (Hello_LED.Hex) from the indicated link, and burn it into the PIC12F675 microcontroller with the help of your PIC Kit 2 programmer. Note that, this is only a simple approach to test the PIC12F675 microcontroller of your mini development board. From the next part, you can learn how to program PIC microcontrollers using your own codes!

PIC Kit 2 Microcontroller Programmer Guide

Inorder to get the best from your PIC Kit 2 Microcontroller Programmer, it is recommended to download the PIC Kit 2 user guide from http://www.pic16.com/soft/PICkit2_USER_GUIDE.pdf This user’s guide describes how to use PIC Kit 2 Microcontroller Programmer. Other useful notes are also included in this detailed official documentation.
The PIC KIt 2 Microcontroller Programmer can program PIC microcontrollers that are installed in an application circuit using In-Circuit Serial Programming (ICSP). In-Circuit Serial Programming (ICSP) requires five signals:

  • VPP/MCLR – Programming Voltage (when applied, the device goes into programming mode)
  • PGC or ICSPCLK – Programming Clock (a unidirectional synchronous serial clock line from the programmer to the target)
  • PGD or ICSPDAT – Programming Data (a bidirectional synchronous serial data line)
  • VDD – Power Supply (positive voltage)
  • VSS – Power Supply (ground reference)

When you are familiar with your PIC Kit 2 microcontroller programmer, interconnect the mini development board (MDB) with PIC Kit 2 as shown below. Since, you can safely power the mini development board (at this time) by the PICkit? 2 Microcontroller Programmer itself, remember to switch off the mini development board’s power supply during ICSP programming!

After this ICSP wiring, connect the PIC Kit 2 programmer to your PC and open the PICKit2 Software. After Opening the PICKit2 Programmer Tool, click Erase, and after Erasing Import the downloaded Hex file from the stored location (File → Import).

After Importing the Hex File, write the program to PIC by clicking the Write button. After programming, you may verify the program in the PIC Microcontroller with the Hex file using the Verify button. This can used to check whether the program in the microcontroller is corrupted or not. Now remove the ICSP wiring, and power the mini development board from its own power supply. If everything is okay, you can see that the LED is flashing continuously with about 4Hz frequency at 50% duty cycle.

Yes, now you are sure that your PIC12F675 (in your MDB) is functioning well, and your PIC Kit 2 microcontroller programmer can successfully burn hex files from your computer to the microcontroller chip. Certainly, not a bad evening!

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
Programming The ATtiny85(译)
编程之道(英汉对照)
Writing device drivers in Linux: A brief tuto...
How To Program Your Very Own Operating Systems (OS)
如何在ATE中集成对PIC单片机的编程烧写功能
Top 10 C Language resources that will turn you into a better programmer - C and C Programming Resources
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服