PIC microcontrollers are a very useful and versatile tool for use in many electronic projects. They are very inexpensive and easy to find. They are also very powerful and many are capable of speeds up to 64 MIPS using the internal oscillator block, about 16 times faster than most comparable AVR microcontrollers. PICs are also easy to program, however getting the project set up can some times be tricky.
PIC Projects Some of the various PICs from Microchip, 16F84, 16F627, 16F628, 16F876 and a 16F877. So far, I have only played around with the PIC16F84 PIC chip, with exception to using a PIC16F876 with the HamHUD. Programming PIC16F628A hi again. Thanks for your last feedback in helping me installing my pic programmer. Now I'm using a software chip burning system 'MicroPro' which writes.hex files into 16f628a.
These instructions will walk through the process of setting up the software, creating a new project, and programming some very simple functions to test the configuration and ensure everything is working. They are designed to be very open ended; after the project is created and the basics are finished the reader is encouraged to explore all the features and extras not covered in these instructions. Also you will find that these instructions will start out walking through step by step, but as the instructions near the end the reader is encouraged to explore other ways of accomplishing the tasks and make the project their own. What you will need To build a project with a PIC microcontroller only requires a few items. PIC microcontroller.
These instructions are for programming a PIC18F series MCU, although others are similar. Obtained from. Microchip allows students with valid.edu email addresses sample PIC's for free!. The PIC I am using to create these instructions is a PIC18F22K80. PICkit 3 In-Circuit Debugger. Available from.
Costs $45 for general public, and #34 with student discount if you have an.edu email address. There are also other programmers which will work just as well; however, this is the best one for starting out.
Breadboard and breadboard wires. LEDs, buttons, potentiometers, or anything else you would like to connect to the PIC.
Before doing any programming the first step is to build the hardware. Although the PIC18F portfolio is very large, many of the chips have several commonalities. For more detailed information see the 'Guidelines for Getting Started with PIC18Fxxxx Microcontrollers' section in your devices datasheet.
For detailed pin-outs of the PIC microcontroller see the 'Pin Diagram' section in your devices datasheet. Note: VDD = Positive Voltage and VSS = Ground. Connect the MCLR pin through a 1kΩ resistor to VDD. Connect a 0.1μF capacitor between every pair of adjoining VDD-VSS pairs or AVDD-AVSS pairs. Connect a 10μF capacitor between VCAP and Vss.
Connect MCLR pin to pin 1 of the PICkit 3. Connect VDD to pin 2 of the PICkit 3. Connect VSS to pin 3 of the PICkit 3. Connect PGD pin to pin 4 of the PICkit 3. Connect PGC pin to pin 5 of the PICkit 3.
Leave pin 6 of the PICkit 3 unconnected. Connect any analog inputs to pins with ANx functionality where x is a number.
Connect any digital inputs or outputs to pins with Rxy functionality where x is a letter identifying the port, and y is a number identifying the bit. For my example I have an LED connected between RA0 and ground, the wiper of a potentiometer connected to AN1, and a DPST switch connected to RA2.
You may find it easier to program the PIC if you have sketched down a schematic of your circuit. These instructions will use XC8 compiler and MPLAB X IDE by Microchip.
This step will explain how to get these tools and ensure they have been installed correctly. To get the latest version of the software visit Microchips website at. Select the software for your OS and follow the standard installation instructions.
Note: If you are using Windows 8 you may need to run the installers in compatibility mode for Windows 7. Once the software is installed, start MPLAB X. In the menu bar select Tools-Options.
In the Options dialog select the Embedded tab and ensure XC8 is listed in the Toolchain list. If it is listed select OK and move on the next step. If it is not listed ensure that instillation has completed, and click Scan for Build Tools button. If still not listed, look on for help with your specific problem. In this step we will create a new project based on a template from Microchip. On the menu bar select File-New Project. In the new file dialog box expand Samples and select Microchip Embedded.
In the project box select PIC18 C Template. Select Next. Give the project any name you like. Choose a location to save the project to in the Project Location box. Leave the Project Folder as default options. Check 'Set as Main Project' box. Select Finish The project will now show up in Project Explore on the left hand side of the screen.
Before we can get started programming we need to set the build parameters. Create Configuration. Right click on the project name in the projects tool bar. In the Project Properties dialog select Manage Configurations. In the Configurations dialog select New. In the New Configuration Name dialog enter Default and click OK.
In the Configurations dialog make sure Default is selected and click Set Active. Click OK in the Configurations dialog Set Configuration Properties. In the Project Properties dialog select 'Conf: Default' in the Categories list.
In the Device box type the name of the device you are using. In my case PIC18F26K80. In the Hardware Tools list select PICkit3. In the Compiler Toolchain select XC8 (v.) Where. Is the version you have installed.
Select Apply. Under Conf: Default select PICkit 3. For Option categories select Power. Check 'Power target circuit from PICkit3. Select Apply. Under Conf: Default select XC8 compiler.
For Option categories select Optimizations. Set 'Optimization Set' to 'none'.
Select Apply. Click OK to close the dialog box Test the Configuration To test the configuration click the clean and build button (the one with the hammer and broom). Text will start scrolling in the output window at the bottom of the page. If everything is successful the this text will say BUILD SUCCESSFUL (total time.). If you get an error, go back through this step making sure that you did not miss anything, and that everything was applied. The next step is setting the configuration bits. The configuration bits tell the MCU its initial conditions for when it turns on.
They are used to set the clock source and speed, watchdog time configuration, and other similar features. Configuration bits are device dependent, so check the data sheet for the chip you are using for more information. In the project explorer expand Source Files and open configurationbits.c. Remove all the text below the #endif line. Notice a new tab has opened at the bottom of the screen. Set the bits as needed for your project.
Since these are chip dependent, check the data sheet for more information about what each does. Some common settings follow:. Extended Instruction Set - Should be set to OFF when using template. Oscillator - Used to select the processor.
Unless you are using an external crystal, leave set as Internal RC oscillator. See data sheet for other oscillator configurations. Note: CLKOUT will allow for easier debugging, and should be turned on if available. PLL Enable - Will allow for future use of the PLL. Note: this will not turn on the PLL, it will only enable it. It is recommended to enable it.
Watchdog Timer - The watch dog timer is used to ensure the processor will not lock up. It however makes it much harder to debug.
It is recommended to disable it while initially programming, and only enable it after the project is nearly done. Code/Table Write/Read protects - Used to disable writing or reading to certain ranges of memory. Leave all of these disabled.
If unsure about a setting, it is usually safe to leave it default. After all configuration bits have been set, click the 'Generate Source Code to Output' button at the bottom of the panel. The panel will now switch to the Output tab. Select all the text in this tab and copy it to the clip board. Paste it at the bottom of the configurationbits.c file and pres save. Clean and build the project again by clicking the broom and hammer icon.
Ensure the build was successful. Also check to make sure there was no errors in the output If everything has worked move on to the next step. If there are errors or warnings fix them before moving on. Hi, I've been following along with a pic 18F45K20 and I am at the blink LED part.
Everything works fine except that the LED blinks every 2 seconds. I believe I am running at 16 MHz. I could not find the PLL so I just configured my OSCONbits.IRFC = 0b111 (16 MHz according to data sheet). I am using the INTIO67 clock, Which I also can't seem to find on the data sheet.
I'm new to this and not sure what I am missing here. Anything helps and here is the link to the data sheet I am looking at, starts at page 26. Thank you for any help. I'm using the 18F24k20 and the manual says:.
When SCS=00,the system clock source is determined by configuration of the FOSC bits in the CONFIG1H Configuration register. WhenSCS=01,the system clock source is the 32.768 kHz secondary oscillator shared with Timer1.
So, setting OSCCONbits.SCS = 0b00; determines the internal oscillator block will be used and at what frequency. In your case of the PIC16F687 (SCS is just bit Zero) the manual states: When SCS = 0, system clock source is determined by FOSC bits. When SCS = 1, system clock source is frequency determined by IRCF After a reset, SCS is always cleared (set to 0).
Heh always helpful eh. Theres loads of posts regarding the 'verify failed at address 0000h' with the JDM, try searching the forum. This error comes up if 'anything' is wrong.so its not exactly useful for debugging.all it means is IC-prog is attempting to send out data, but when it reads from the PIC, it doesn't get anything, as that is its only source of feedback to check if its connected or if it can communicate. IC-prog has the ability to test the control lines so I would check the following: 1) make sure the VDD to the PIC is at least 4.5V. Should be 5v but anywhere between 4.5 and 5.5 sohuld be fine. 2) Check the voltage on the MCLR pin (pin 4 on the 628A), form memory I think the minimum voltage to get it into 'programming mode' is 12.7V, sohuld be arround 13V. It could either be hardware, or software.
XP/vista don't like programs big banging the serial port and you may need some sort of utility. I believe this is all covered on the IC-prog website. When you checked the voltages did you check the boxes in the JDM hardware debugging dialogue? I could be wrong but I seem to remember IC-prog doesn't power the chip properly when it is not programming it.
Failing that, I believe your serial port can't provide enough power/voltage for the programmer. Laptops especially have this problem, as do new computers with serial ports, because the days when RS232 were +/- 12V are gone, most only output about +/- 7v ish (that goes for USB-RS232 adapters too).
Many programmers use an external power supply (15v) which can provide the 13v for MCLR, and then use a regulator for the 5v.in this case, the JDM style programmer simply switches these voltages, rather than actual;ly produce them from the power from the serial port, generally much more reliable. I hate to say it, but I would cut your loses and buy a PICkit2 or a copy off ebay The chinese copies/cloines are very cheap, work with USB, and support many chips, worth it if you are planning on promgramming PIC's for a while.
Could you provide a schematic of the programmer you built? There are many variations of the JDM, some more reliable than others.
Hi, I took a look at the schem on the site (the one in the zip file) and yep, its a stock JDM. As Nigel rightly pointed out these are woefully unreliable.
If you can, try this simpler version: I don't know why but when I started programming PIC's, the above version worked, when all others failed. Although, it does assume that your serial port can output +12.7V from the tx line to the MCLR pin, which as I said before, isn't usually the case these days.
This site has a good 'debugging' section for the JDM. Then of course theres the software problem. IC-prog cannot always access the serial port under win2000/XP (god knows about vista) so there are some utilities that help it along. (xport?) You must try to find out what is causing the problem, as the 'verify failed at blah blah blah' error isn't at all helpful. I usually start with hardware, as you have done, checking voltages etc.then software.
Quite a good USB powered version is this: You can replace the USB connector with a 5v supply, it generates (rather poorly I might add) the 13v via a voltage multiplier, regulated by a 13v zener and silicon diode, to make 13+0.6 = 13.6v. This is switched by an optocoupler (can be replaced by a transistor as I did). That should help.
Of course there is no point in building another JDM, but if you one really doesn't work after all that, consider buying one. They are a hell of a lot cheaper than you might think.
Comments are closed.
|
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |