Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PIC 10F programming question

Status
Not open for further replies.

Broz

New Member
Hello. It's been a long time since I posted last. I was teaching myself how to program PIC's a while back and had to take a break. I'm now back into it and making good progress. I've been working with the 16F690, programming it using a PICKit2 and the LPC demo board. I've written a program on it that works just the way I planned, and now I would like to switch to programming a 10F type of PIC. The little 6 pin SMT chip is exactly what I need. I think the program I've written for the 16F690 will be the same or very similar for the 10F. The problem is, I don't think the PICKit2 can program the 10F and I don't know how to go about programming anything that's surface mount. It will be my first experience with surface mounted components. I'm not even sure if I have to program it in circuit or not.

So, what's a good programmer that's at a reasonable cost and I can get started quickly? Also, if I have to program in circuit, how do I do that? Thanks.
 
The problem is, I don't think the PICKit2 can program the 10F
The 10F200 is in the **broken link removed** for both the PICkit 2 software and MPLAB.

and I don't know how to go about programming anything that's surface mount.
Simply put 5 pins (1x5) or 10 pins (2x5, depends on your cable(s)) on the board to plug your programmer into. With so few microcontroller pins, you'll be sharing programming pins and probably the MCLR pin with your circuit, so you have to find some way of isolating your circuit from the pins while programming. I use SPDT switches, but pins and jumpers will work fine too.

Also, if I have to program in circuit, how do I do that?
Have a look at how I isolated the pins in **broken link removed** or **broken link removed**.
 
Last edited:
Get a sot 23 to dip adapter board. Solder some sip sockets to receive the dip adapter board on the LPC board proto area. Hook up the icsp to the sip connections, and isolate the outputs on the icsp connections per the Pickit 2 manual. Remove the 16f690, and you should be able to program away. For sure the Pickit 2 will program the 10F's as a stand alone programmer, can't open up MPLAB right now to see how it is supported there.
 
You can also get the 10F series in an 8 pin dip. You could then prototype and debug the circuit on a breadboard. Once the code is finished, you could mount a 10F SMD version on the target PCB and program it before mounting the rest of the parts. Or design the circuit so it doesn't interfere with ICSP process or use "solder jumpers" to isolate the required pins.
You could also use a SOT socket for programming it:
https://www.electro-tech-online.com/custompdfs/2008/09/20076633186382756250000PDF.pdf
Or buy the adapter from MicroChip:
**broken link removed**
 
Last edited:
There are several other ways to program surface mount PICs.

  1. Use an IC clip. They have them for SOICs and others (iirc). For SOICs, Pomona makes a clip that hooks onto the chip and makes contact with the pins. You can program the bare chip as long as you provide Vcc and Gnd from the programmer. Pickit2 does that. By the way, this is great for programming in-circuit as well. No need to add an ICSP header. They make them for DILs, too.**broken link removed**
  2. Get a breakout board for package you are using and hook up the BOB up for ICSP. Then, using a lightweight clamp (even a clothes pin would work if there is clearance) to hold the chip against the board with the pins aligned with the correct pads. You might have to bend the chip's pins down a bit to ensure good contact.
 
Last edited:
Ok, I thought the easiest thing to do would be just to get the programming adapter from Microchip. I have the adapter now. I'm confused about something now. The PICKit2 programming software supports the 10F, but MPLAB doesn't support the 10F with the PICKit2.

So I'm guessing I write the code in MPLAB and then compile it into a hexcode and then use the programming software for the PICKit2 to program it. Is that right?
 
Hey thanks nickelflippr, that did the trick. It looks like I can program the 10F206 I have with my pickit2 from within MPLAB now. This place is great. I don't know how I would be able to learn this stuff without the help of this forum.

I have another question/request now. I started out writing a program for the 16f690 that flashes one LED and looks for an input and then flashes a couple other LED's when the input is received. I got it to work on the 16f690 with no problems. I now want to make a very similar program for the 10F. As the 10F is only the second type of PIC I've worked with, I haven't mastered how to read the datasheets and spot the differences required to program the 10F. I'm not even sure how to set a pin as an input or output. Is there a 10F tutorial somewhere, or does someone have an example code I could use? Something as simple as a "hello world" would work, just so I can figure out the differences.

Thanks.
 
Look for the file 10F206TEMP.ASM on your hard disk here:
C:\Program Files\Microchip\MPASM Suite\Template\Code
assuming you installed MPLAB in the default folder.
It is not quite a "Hello World" program, but is a good starting point for building code.
 
Hey thanks kchriste, that's some very useful information. I used that to write my program. I'm still having a heck of a time. I was able to write a pretty complex program for the 16f690 but I can't get these 10f206's to do anything. I'm just trying to light an LED right now before I go on to my projects. Look at this code and tell me where I'm making my mistake. I'm thinking it should light an LED on GP1, but it does nothing. I must be missing something easy and will feel like an idiot. Here is the code:

Code:
list      p=10F206            ; list directive to define processor
	#include <p10F206.inc>        ; processor specific variable definitions

	__CONFIG   _MCLRE_ON & _CP_OFF & _WDT_OFF & _IntRC_OSC

; '__CONFIG' directive is used to embed configuration word within .asm file.
; The lables following the directive are located in the respective .inc file. 
; See respective data sheet for additional information on configuration word.



;**********************************************************************
	ORG     0x1FF             ; processor reset vector

; Internal RC calibration value is placed at location 0x1FF by Microchip
; as a movlw k, where the k is a literal value.

	ORG     0x000             ; coding begins here
	movwf   OSCCAL            ; update register with factory cal value 




start	
	movlw	   b'1101'  ; make gp1 output
	TRIS	   GPIO 	 ;
	movlw	   b'0010'  ; set gp1
	movwf	   GPIO		;
	goto	   $		; loop forever

; remaining code goes here






	END                       ; directive 'end of program'
 
Code looks OK to me and runs fine in Mplab SIM. Some hardware questions:
Do you have a pull up resistor on MCLR? (pin 6 on SOT-23 or Pin 8 on PDIP)
Is the PICKIT disconnected? The In-Circuit Serial Programming clock pin is shared with GP1 and may be conflicting so disconnect the PICKIT and see what happens.
Do you have a 0.1uF cap across the power pins of the PIC?
 
The Pickit is disconnected. It's on a breadboard. I have the cap across the power pins but no pull up resistor on MCLR. I'm using the 8 pin DIP. I guess I should try that.
 
I believe you are right Nickel, even though the SIM shows no difference between CMCON0:CMPON being set or reset. Must be a bug in the SIM because the datasheet shows that CMPON is set on power up and enables the comparator.
 
Bugs everywhere, although a recent snow and freezing temps is killing them off around here. Saw someone complain about the simulator and a 16f77X. Wouldn't recognize the internal osc in config, although you might expect something like that in a new device series.
 
Turn the comparator off.

I hope that works. Being fairly new to all this, I don't know how to turn the comparator off. Is this something that goes in the _config? I'm reading the datasheet now trying to figure it out on my own, but haven't yet.
 
Aha! I'm getting better at reading these datasheets. I figured it out how to turn off the comparator and it's working. Let me know if this is the "proper" way, this is how I did it and it works.

bcf CMCON0, CMPON

Now I can light up the LED. Onto my more complex programs. This place is great. Thanks for all the help. I hope someday I will be able to help someone here as well.

Edit: Just to give an update, once I got the LED to light, I loaded my more complex program. It works. I have 3 outputs and one input and it all works as planned. Woot!
 
Last edited:
I'm back. I thought I had a handle on this but apparently there is a bunch of stuff on GP2 that needs to be turned off before it will act like a regular output. I'm trying to read the datasheet and figure out how to do this, but I'm having troubles. The order of precedence for GP2 is FOSC4, COUT, T0CKI, and finally TRIS GPIO. Exactly what is all this stuff and how can I turn it all off easily so that I can use GP2 as just a simple output? Thanks again.
 
Well, that is all dependent on the hardware support modules and the way the registers latch.

Those are not precedences, their available options;)

You can control what you want that pin/port to be with the proper register latches.

-BaC
EDIT: I am however a bit confused, are we speaking about 16Fs here or 10Fs. There is no comparators on a 10F200, so I am guessing 16F?

I'm back. I thought I had a handle on this but apparently there is a bunch of stuff on GP2 that needs to be turned off before it will act like a regular output. I'm trying to read the datasheet and figure out how to do this, but I'm having troubles. The order of precedence for GP2 is FOSC4, COUT, T0CKI, and finally TRIS GPIO. Exactly what is all this stuff and how can I turn it all off easily so that I can use GP2 as just a simple output? Thanks again.
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top