PIC Microcontroller Primer – Tutorial #2

Post here to discuss the PIC microcontroller tutorials.

Moderators: Chuckt, Garth, bitfogav

Post Reply [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
lulala
newbie
newbie
Posts: 4
Joined: Sat Aug 20, 2016 3:47 pm
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

PIC Microcontroller Primer – Tutorial #2

Post by lulala » Wed Nov 02, 2016 7:16 pm

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.
Image
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!
Image
Image
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).
Image
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.

Vallance
newbie
newbie
Posts: 1
Joined: Fri Mar 15, 2019 7:13 pm
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: PIC Microcontroller Primer – Tutorial #2

Post by Vallance » Sat Mar 16, 2019 8:32 pm

Is this tutorial still valid or has something changed? I must be doing something wrong if it is.

User avatar
bitfogav
Moderator
Moderator
Posts: 915
Joined: Sun Mar 28, 2010 9:03 pm
Location: United Kingdom
Contact:

Re: PIC Microcontroller Primer – Tutorial #2

Post by bitfogav » Sat Mar 16, 2019 10:03 pm

Vallance wrote:
Sat Mar 16, 2019 8:32 pm
Is this tutorial still valid or has something changed? I must be doing something wrong if it is.
Hi Vallance, Has this tutorial was posted by a forum member, and the links/code seem to be missing I would gather this
tutorial is no longer valid.

Is there something we can help you with specifically? You can find some valid Assembly tutorials here by Brad. Start at the bottom of the page.
https://bradsprojects.com/category/tutorials/
If you don't know what Voltage your country is using, you shouldn't be doing electronics ;-)

User avatar
brad
Site Admin
Site Admin
Posts: 2578
Joined: Fri Mar 26, 2010 10:30 pm
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: PIC Microcontroller Primer – Tutorial #2

Post by brad » Thu Apr 11, 2019 12:22 pm

Thanks for posting the link Gav, you can also go to the very first tutorial here:
https://bradsprojects.com/pic-assembly- ... ogramming/

Post Reply
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Who is online

Users browsing this forum: No registered users and 2 guests