PIC Kit Noob - Page 1
Forum section: electronics / general

author: GadgetUK
author_rank: Contributor
timestamp: October 07, 2013, 04:42:33 pm
content: Hi,I recently got a PIC Kit 2 along with some basic PIC chips - 16F84A etc. I am trying to understand how the thing works, I know I can program the chips using the PIC Kit, but should I be able to run code straight from it, or do I need to program the chip and then plug into a breadboard with xtal and power etc? ie. does the PIC Kit provide a clock etc in order to run in debug?

author: mariush
author_rank: Super Contributor
timestamp: October 07, 2013, 05:09:47 pm
content: Some PIC chips have an internal oscillator, some don't. Open the datasheet for that particular PIC chip and see. Just search for "PIC16F84 datasheet" in Google and you'll find it.If I readthe datasheetcorrectly, PIC16F84A has no oscillator built in (see page 22-23),If the chip has no oscillator built in, most pic chips can also be configured to use a resistor and capacitor to give it a clock, instead of an oscillator. Again, read datasheet.You can write the program and select the proper bits (use internal osc, frequency etc) and after programming the chip will just run.I would say most pic chips today can be programmed just by connecting the pickit to them - i don't have experience with old pic chips though (think 3-5 years old).I prefer to put the chip on a breadboard with the 5v and ground wires and connect the icsp wires to the breadboard and the pickit just programs, but it's possible to run the chip from the pickit (at least it's possible with pickit3, i didn't use pickit2 so far)

author: GadgetUK
author_rank: Contributor
timestamp: October 07, 2013, 05:15:43 pm
content: Thanks very much, that makes perfect sense now!! I already had my 4Mhz crystal ready for the PCB once I've programmed it, but after trying to run the code whilst in the PIC Kit board and seeing no activity on any of the output pins I was starting to think there was a problem with the programmer or software etc. I will get the bread board wired up and see what happens.

author: jakehiltz
author_rank: Contributor
timestamp: October 07, 2013, 05:16:30 pm
content: I would recommend using MickoC for your programming environment (IDE). Its free for the trial (limit is 2kb of code) . You should look at some examples and libraries that come with the IDE as I found them to be very helpful for my first projects with Pic . Make sure you download the PicKit drivers and that you export all code to HEX.

author: dannyf
author_rank: Super Contributor
timestamp: October 07, 2013, 06:44:10 pm
content: PICKIT2 works best as a programmer.It can work as a debugger with other headers.

author: AndyC_772
author_rank: Super Contributor
timestamp: October 07, 2013, 06:59:29 pm
content: I wouldn't even bother messing about with chips that don't include an oscillator. Put them to one side for now and use them in a future project if you to.Order yourself a few PIC18F26K22 and have a good read of the data sheet - it's a really versatile device that I keep ending up with whenever I search for a part to use in a project. I think it's a good device to learn, and if you need more I/O in future, there are PIC18F4x, 6x and 8x devices that are very similar.It has an internal high speed oscillator which runs at 16 MHz, and a 4x PLL that you can switch on to give a system clock (Fosc) = 64 MHz.Tip: to configure the clock source, brown-out voltage, code protection and other features, open the Window > PIC Memory Views > Configuration Bits, then select the options you want in the memory view and click 'Generate source code to output'. I normally copy this into a new file called "config.h" and then #include it in my main.c file.

author: Metalcrowe
author_rank: Contributor
timestamp: October 07, 2013, 07:12:36 pm
content: Quote from: AndyC_772 on October 07, 2013, 06:59:29 pmI like this Pic also, but unfortunately it is not compatible with the Pickit 2.Here is a list of all Pickit 2 compatible Pic's.http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en027813

author: dannyf
author_rank: Super Contributor
timestamp: October 07, 2013, 07:18:28 pm
content: QuoteNo more /4?

author: AndyC_772
author_rank: Super Contributor
timestamp: October 07, 2013, 07:22:26 pm
content: Shame. Maybe it's worth upgrading to the PICKIT 3 anyway? I wouldn't personally want to invest a lot of time and effort in learning a device which I wasn't likely to use in a real project. PICs certainly have some features in common, but registers do change significantly from one device to another, so code for one isn't necessarily that portable.

author: AndyC_772
author_rank: Super Contributor
timestamp: October 07, 2013, 07:24:51 pm
content: Quote from: dannyf on October 07, 2013, 07:18:28 pmYou can run the high frequency internal oscillator at any number of speeds, 16 MHz being the maximum. The 4x PLL can be used at 8 MHz and at 16 MHz to give operating speeds of 32 and 64.It's worth clarifying that the core takes 4 cycles per instruction, so the instruction rate is always Fosc/4, giving a maximum operating speed of 16 MIPs with the 4x PLL enabled.

author: dannyf
author_rank: Super Contributor
timestamp: October 07, 2013, 07:25:35 pm
content: You can always pick a PIC24 device. Those are really nice chips.

author: Metalcrowe
author_rank: Contributor
timestamp: October 07, 2013, 07:26:49 pm
content: The System Clock (FOSC) is not divided by 4. But the the machine cycle is divided by 4.A good example is found in the Timer0. (Picture)

author: Skimask
author_rank: Super Contributor
timestamp: October 08, 2013, 04:19:54 am
content: Quote from: Metalcrowe on October 07, 2013, 07:12:36 pmThe 18FxxK22 PICs work fine with my PK2, Device file 1.62.09There's a lot of PICs that Microchip doesn't "directly" support with their files, but the PK2 will do them. I've modified my device file driver to do a decent handful of even the PIC32's.But with that being said, I've also got a PK3. They've both got their places, even if MPLAB is a bit of PITA to use sometimes with both of them at the same time. I get around that by not using them both at the same time. One cheap laptop running with the PK2, one cheap laptop running with the PK3. Problem solved.

author: dannyf
author_rank: Super Contributor
timestamp: October 08, 2013, 11:33:59 am
content: Quote26K22 shows up as a supported device somewhere towards the bottom of the page you linked to.

author: Metalcrowe
author_rank: Contributor
timestamp: October 08, 2013, 05:12:30 pm
content: Ye but only for programming. I think as a beginner, it is good to be able of debugging.

author: RjSa
author_rank: Contributor
timestamp: October 08, 2013, 05:15:56 pm
content: In my opinion if you are learning and starting with microcontrollers it doesnt matter which PIC you select as long as it is a simple PIC with simple features so you dont get confused with pin configurations, fuses, etc.Maybe the simplest PIC you can get is the 16F84 and the internet is flooded with entry level information, code examples, projects, etc using this particular PIC.If after a while you get bored of it and you want a microcontroller with more features it wont be hard to migrate to an upper series like 18F, 24F etc.My advice is continue with the PIC16F84 because you wont find another PIC as simple as this one and with the same amount of information available on the internet.

author: dannyf
author_rank: Super Contributor
timestamp: October 08, 2013, 05:19:59 pm
content: QuoteI would say that as long as you code in a high level language like C, which chip in a family or which family to learn on doesn't matter: coding a PIC16F84 or a AVR or a ARM is all the same.

author: tsmith35
author_rank: Frequent Contributor
timestamp: October 08, 2013, 09:40:54 pm
content: Quote from: dannyf on October 08, 2013, 05:19:59 pmFor the most part, though some compilers (like CCS) don't follow standards very well. Overall, though, the code should be pretty close. Then again, part of the fun is seeing how you need to tweak your code to work properly with whichever compiler you're using at the time.

author: Mr Smiley
author_rank: Frequent Contributor
timestamp: October 08, 2013, 11:00:33 pm
content: Be careful it is the 84A cos the pickit2 won't do the original 84, there are people who have modded some inf file to do the original 84 but i can't get it to work on Linux, and I’ve got loads of them. Their great for making HD44780 lcd displays into one wire serials

author: tsmith35
author_rank: Frequent Contributor
timestamp: October 08, 2013, 11:13:54 pm
content: Quote from: Mr Smiley on October 08, 2013, 11:00:33 pmShould be able to modify a .dat file like this:http://www.microchip.com/forums/fb.ashx?m=385526

author: Mr Smiley
author_rank: Frequent Contributor
timestamp: October 08, 2013, 11:24:42 pm
content: Yes, i read all that, BUTIt specifies a specific .dat file, which i tried to use on Linux, but that version of the .dat file can't be found with command line pk2cmd, it is also edited with a hex editor and the Linux version of the .dat file is different from the version they use.I did give it a go, but just couldn’t get it workingI just use an old K149 programmer on a mates lappy

author: mtechmatt
author_rank: Regular Contributor
timestamp: October 09, 2013, 07:54:22 am
content: Quote from: jakehiltz on October 07, 2013, 05:16:30 pmJake,Only issue there is MikroC doesent let you In circuit debug with Pickit. I was a die-hard MikroC programmer, but as project complexity grew I had to switch over to MPLAB to really tackle harder stuff where I needed to know what was going on internally....MPLABX is really nice to use, the libraries suck, but thats another story!Matt