Author Topic: PIC Kit Noob  (Read 7484 times)

0 Members and 1 Guest are viewing this topic.

Offline GadgetUKTopic starter

  • Contributor
  • Posts: 10
PIC Kit Noob
« on: October 07, 2013, 04:42:33 pm »
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?
 

Offline mariush

  • Super Contributor
  • ***
  • Posts: 5012
  • Country: ro
  • .
Re: PIC Kit Noob
« Reply #1 on: October 07, 2013, 05:09:47 pm »

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 read the datasheet correctly, 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)
 

Offline GadgetUKTopic starter

  • Contributor
  • Posts: 10
Re: PIC Kit Noob
« Reply #2 on: October 07, 2013, 05:15:43 pm »
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.
 

Offline jakehiltz

  • Contributor
  • Posts: 10
Re: PIC Kit Noob
« Reply #3 on: October 07, 2013, 05:16:30 pm »
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.
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: PIC Kit Noob
« Reply #4 on: October 07, 2013, 06:44:10 pm »
PICKIT2 works best as a programmer.

It can work as a debugger with other headers.
================================
https://dannyelectronics.wordpress.com/
 

Online AndyC_772

  • Super Contributor
  • ***
  • Posts: 4221
  • Country: gb
  • Professional design engineer
    • Cawte Engineering | Reliable Electronics
Re: PIC Kit Noob
« Reply #5 on: October 07, 2013, 06:59:29 pm »
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.


Offline Metalcrowe

  • Contributor
  • Posts: 12
Re: PIC Kit Noob
« Reply #6 on: October 07, 2013, 07:12:36 pm »

Order yourself a few PIC18F26K22


I 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
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: PIC Kit Noob
« Reply #7 on: October 07, 2013, 07:18:28 pm »
Quote
a 4x PLL that you can switch on to give a system clock (Fosc) = 64 MHz.

No more /4?
================================
https://dannyelectronics.wordpress.com/
 

Online AndyC_772

  • Super Contributor
  • ***
  • Posts: 4221
  • Country: gb
  • Professional design engineer
    • Cawte Engineering | Reliable Electronics
Re: PIC Kit Noob
« Reply #8 on: October 07, 2013, 07:22:26 pm »
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.

Online AndyC_772

  • Super Contributor
  • ***
  • Posts: 4221
  • Country: gb
  • Professional design engineer
    • Cawte Engineering | Reliable Electronics
Re: PIC Kit Noob
« Reply #9 on: October 07, 2013, 07:24:51 pm »
Quote
a 4x PLL that you can switch on to give a system clock (Fosc) = 64 MHz.

No more /4?

You 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.
« Last Edit: October 07, 2013, 07:26:51 pm by AndyC_772 »
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: PIC Kit Noob
« Reply #10 on: October 07, 2013, 07:25:35 pm »
You can always pick a PIC24 device. Those are really nice chips.
================================
https://dannyelectronics.wordpress.com/
 

Offline Metalcrowe

  • Contributor
  • Posts: 12
Re: PIC Kit Noob
« Reply #11 on: October 07, 2013, 07:26:49 pm »
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)
 

Offline Skimask

  • Super Contributor
  • ***
  • Posts: 1433
  • Country: us
Re: PIC Kit Noob
« Reply #12 on: October 08, 2013, 04:19:54 am »

Order yourself a few PIC18F26K22


I 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

The 18FxxK22 PICs work fine with my PK2, Device file 1.62.09
There'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.
« Last Edit: October 08, 2013, 04:23:27 am by Skimask »
I didn't take it apart.
I turned it on.

The only stupid question is, well, most of them...

Save a fuse...Blow an electrician.
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: PIC Kit Noob
« Reply #13 on: October 08, 2013, 11:33:59 am »
Quote
unfortunately it is not compatible with the Pickit 2.

26K22 shows up as a supported device somewhere towards the bottom of the page you linked to.
================================
https://dannyelectronics.wordpress.com/
 

Offline Metalcrowe

  • Contributor
  • Posts: 12
Re: PIC Kit Noob
« Reply #14 on: October 08, 2013, 05:12:30 pm »
Ye but only for programming.  I think as a beginner, it is good to be able of debugging.
 

Offline RjSa

  • Contributor
  • Posts: 21
  • Country: ve
Re: PIC Kit Noob
« Reply #15 on: October 08, 2013, 05:15:56 pm »
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.
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: PIC Kit Noob
« Reply #16 on: October 08, 2013, 05:19:59 pm »
Quote
My advice is continue with the PIC16F84

I 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.
================================
https://dannyelectronics.wordpress.com/
 

Offline tsmith35

  • Frequent Contributor
  • **
  • Posts: 265
  • Country: us
Re: PIC Kit Noob
« Reply #17 on: October 08, 2013, 09:40:54 pm »
Quote
My advice is continue with the PIC16F84

I 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.

For 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.
 

Offline Mr Smiley

  • Frequent Contributor
  • **
  • Posts: 324
  • Country: gb
Re: PIC Kit Noob
« Reply #18 on: October 08, 2013, 11:00:33 pm »
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  :-+

 :)
There is enough on this planet to sustain mans needs. There will never be enough on this planet to sustain mans greed.
 

Offline tsmith35

  • Frequent Contributor
  • **
  • Posts: 265
  • Country: us
Re: PIC Kit Noob
« Reply #19 on: October 08, 2013, 11:13:54 pm »
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
Should be able to modify a .dat file like this:
http://www.microchip.com/forums/fb.ashx?m=385526
 

Offline Mr Smiley

  • Frequent Contributor
  • **
  • Posts: 324
  • Country: gb
Re: PIC Kit Noob
« Reply #20 on: October 08, 2013, 11:24:42 pm »
Yes, i read all that, BUT

It 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 working  :-\

I just use an old K149 programmer on a mates lappy  :-+

 :)
There is enough on this planet to sustain mans needs. There will never be enough on this planet to sustain mans greed.
 

Offline mtechmatt

  • Regular Contributor
  • *
  • Posts: 61
Re: PIC Kit Noob
« Reply #21 on: October 09, 2013, 07:54:22 am »
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.

Jake,

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
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf