I am working on my first project using a PIC microncontroller, a PIC12F675.
How do I load a program onto the microcontroller?
I bought this programmer to start, but don't really know how to use it.
I'm working with Windows 7.
I installed WinPic800 but it doesnt seem to be detecting the programmer when I plug it in via USB.
When I click "Read All" (or any other function for that matter), I get the error "Failed to open Ind.#0".
Can anyone tell me what I could be doing wrong?
Thanks
-
\$\begingroup\$ Multiple questions; pick one or expect this to be closed. \$\endgroup\$Brian Carlton– Brian Carlton2011年08月15日 01:34:43 +00:00Commented Aug 15, 2011 at 1:34
-
1\$\begingroup\$ Ok. I want to know why WinPic isn't detecting the programmer and microcontroller, but we'll let a moderator decide if this is too many questions. Oh and be nicer or expect no one to ever love you. \$\endgroup\$Shubham– Shubham2011年08月15日 01:51:12 +00:00Commented Aug 15, 2011 at 1:51
-
\$\begingroup\$ @Shubham I don't thin Brain was rude at all. I do agree that this question is overly broad with several unrelated questions. As for your comment on letting a moderator decide, this is a community moderated site with mods only around to help out the community. Brian and any other users have full right to say that a question should be closed, if 5 users agree, it will be closed. \$\endgroup\$Kellenjb– Kellenjb2011年08月15日 02:13:22 +00:00Commented Aug 15, 2011 at 2:13
-
\$\begingroup\$ Ok I edited the question to be less broad. \$\endgroup\$Shubham– Shubham2011年08月15日 03:36:41 +00:00Commented Aug 15, 2011 at 3:36
1 Answer 1
Get a better programmer, such as the Microchip PICkit 2 or PICkit 3. They work "out of the box" with the MPLAB IDE, and you get in-circuit debugging as well as programming (you need a special header if you want to debug the 12F675 as it doesn't have on-chip debug hardware). You will also get plenty of help from other users on the Microchip support forums, and you can use it with Microchip's low-cost development boards.
Here is a little test program for the 12F675:
;flasher.asm
;simple program for PIC12F675 to flash LED on pin 5
;uses Timer0 for delay
list p=12f675 ;list directive to define processor
#include "p12f675.inc" ;processor specific variable definitions
errorlevel -302 ;suppress "not in bank 0" message
__CONFIG _INTRC_OSC_CLKOUT
;-----------------------------------------------------------------
;defines
;-----------------------------------------------------------------
#define LED 2 ;GP2 (pin 5)
#define INIT_COUNT 10 ;
;-----------------------------------------------------------------
;variables
;-----------------------------------------------------------------
cblock 0x20
tick_counter
endc
;------------------------------------------------------------------
;initialisation
;------------------------------------------------------------------
;reset vector
org 0
nop
goto Main
;interrupt vector
org 4
banksel INTCON
bcf INTCON,T0IF ;clear Timer0 interrupt flag
movlw INIT_COUNT ;re-initialise count
movwf TMR0
decf tick_counter,f
retfie
Main:
banksel OSCCAL ;calibrate oscillator
call 0x3FF ;Get the cal value
movwf OSCCAL ;Calibrate
banksel ANSEL
movlw 11h ;AN0 as analog input,conversion clock Fosc/8
movwf ANSEL
bankseL CMCON
movlw 07h ;comparators off
movwf CMCON
banksel TRISIO
bcf TRISIO,LED ;LED output GPIO5 (pin 2)
banksel OPTION_REG
movlw b'00000011' ;prescaler 1/128
movwf OPTION_REG ;
banksel TMR0
movlw INIT_COUNT ;initialise timer count value
clrf tick_counter
movwf TMR0
bsf INTCON,GIE ;enable global interrupt
bsf INTCON,T0IE ;enable Timer0 interrupt
banksel GPIO
;-----------------------------------------------------------------------
;main program loop
;-----------------------------------------------------------------------
loop:
bsf GPIO,LED
call dly
bcf GPIO,LED
call dly
goto loop
dly:
movlw 0x10
movwf tick_counter
dly1:
movf tick_counter,f
skpz
goto dly1
return
end
-
\$\begingroup\$ Why is this a bad programmer? The reason I got this one was because it was cheap...the PICKit programmers can be quite expensive compared to cheap ones like this. \$\endgroup\$Shubham– Shubham2011年08月15日 22:31:48 +00:00Commented Aug 15, 2011 at 22:31
-
1\$\begingroup\$ If you don't know how to use it it is very expensive for what it can do for you! Either get the manual and read it fron to back, and get the programmer to work, or ditch it. Your ebay link suggests that it might be second hand, so it could be defective. \$\endgroup\$Wouter van Ooijen– Wouter van Ooijen2011年08月25日 19:59:49 +00:00Commented Aug 25, 2011 at 19:59