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.

Starting out

Status
Not open for further replies.

aaronchay

New Member
Hi all, I've just started out on micro controllers and would like to seek some advice o the hardware part.

If I were to create my own circuit, what are the components needed to write the program? My current knowledge tells me that I need to connect my own circuit with the PIC on it to the MPLAB ICD 2 Debugger and then to the computer which I will write a program using the MPLAB IDE. Is that right?

Host computer ----- MPLAB ICD 2 ----- Target board

Are there any 3rd party hardware which I can use to replace the MPLAB ICD2 to save cost?

Thanks!
 
Last edited:
Hi guys, thanks for your prompt reply. I have purchased the PICKIT2 Starter Kit. Currently they're having a promotion which comes with 9 PICs free with the price slightly lower.

One question I have is, if I do my external circuit on a breadboard, do i need any external power supply?
 
Hi, understood, Anyway, I've also built up a voltage regulator with a LM7805.

Anyway, for the programming part, is there any tutorials because I can't seem to build all my softwares. how do I get the HEX files?
 
You don't need the hex files. You make a project in MPLAB and select PicKit2 as the debugger/programmer and hit F10. I believe that the PicKit2 demo boards come with sample code, do you have these files.

Mike.
 
You don't need the hex files. You make a project in MPLAB and select PicKit2 as the debugger/programmer and hit F10. I believe that the PicKit2 demo boards come with sample code, do you have these files.

Mike.
I do have the sample codes, I'm only able to run it when I use the PICkit2 programmer to write the files but not in MPLAB.

**broken link removed**[/url][/IMG]

This is the screenshot when I chose PICkit2 under Programmer and when I click on write to device.
 
Sorry, even when I cut and paste your URL I still get nothing.

Click the advanced button and add it as an attachment.

Mike.
 
Sorry, I've add an image as well as attachment.

<a target="_blank" href="http://b.imagehost.org/view/0437/untitled_8.jpg"><img src="http://b.imagehost.org/t/0437/untitled_8.jpg" border="0" width="150" height="106" alt="untitled_8.jpg (140 KB)" /></a>
 

Attachments

  • untitled.JPG
    untitled.JPG
    140 KB · Views: 143
I can see it now. It looks like you have it set up as a programmer rather than a debugger. It also looks like you have no code to download. Can you post the asm file. Put
Code:
 before it and
after it so it keeps it's formatting.

Mike.
P.S. please don't delete posts. It makes me look like I'm answering myself.
 
Hi Mike,

This is the tutorial 3 of the PICKIT2

Code:
;******************************************************************************
;Software License Agreement                                         
;                                                                    
;The software supplied herewith by Microchip Technology             
;Incorporated (the "Company") is intended and supplied to you, the  
;Company’s customer, for use solely and exclusively on Microchip    
;products. The software is owned by the Company and/or its supplier,
;and is protected under applicable copyright laws. All rights are   
;reserved. Any use in violation of the foregoing restrictions may   
;subject the user to criminal sanctions under applicable laws, as   
;well as to civil liability for the breach of the terms and         
;conditions of this license.                                        
;                                                                    
;THIS SOFTWARE IS PROVIDED IN AN "AS IS" CONDITION. NO WARRANTIES,  
;WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED  
;TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A       
;PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,  
;IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR         
;CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.       
; *******************************************************************
; PICkit 2 Lesson 3 - "Rotate"
;
; Extends Lesson 2 to sequence through the display LEDs.
;
; *******************************************************************
; * See Low Pin Count Demo Board User's Guide for Lesson Information*
; *******************************************************************
; * NOTE: The PIC16F690 requires the AC162061 header for debugging  *
; *******************************************************************

#include <p16F690.inc>
     __config (_INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _BOR_OFF & _IESO_OFF & _FCMEN_OFF)

     cblock 0x20
Delay1              ; Assign an address to label Delay1
Delay2
Display             ; define a variable to hold the diplay
     endc
     
     org 0
Start:
     bsf       STATUS,RP0          ; select Register Page 1
     clrf      TRISC               ; make IO PortC all output
     bcf       STATUS,RP0          ; back to Register Page 0
     movlw     0x08
     movwf     Display
MainLoop:
     movf      Display,w           ; Copy the display to the LEDs
     movwf     PORTC
OndelayLoop:
     decfsz    Delay1,f            ; Waste time.  
     goto      OndelayLoop         ; The Inner loop takes 3 instructions per loop * 256 loopss = 768 instructions
     decfsz    Delay2,f            ; The outer loop takes and additional 3 instructions per lap * 256 loops
     goto      OndelayLoop         ; (768+3) * 256 = 197376 instructions / 1M instructions per second = 0.197 sec.
                                   ; call it a two-tenths of a second.
     
     bcf       STATUS,C            ; ensure the carry bit is clear
     rrf       Display,f
     btfsc     STATUS,C            ; Did the bit rotate into the carry?
     bsf       Display,3           ; yes, put it into bit 3.
     goto      MainLoop
     end
 
Your pickit2 is a debugger. If you select pickit2 under the debugger->select tool menu then it should find your development board and should download the code.

Mike.
 
Your pickit2 is a debugger. If you select pickit2 under the debugger->select tool menu then it should find your development board and should download the code.

Mike.
I did exactly as stated and was shown this message:

Initializing PICkit 2 version 0.0.3.30
Found PICkit 2 - Operating System Version 2.32.0
Target power not detected - Powering from PICkit 2 ( 5.00V)
PIC16F690 found (Rev 0x6)
PICkit 2 Ready

and when I click on "Program the target device" this is what is shown:
Programming Target (9/7/2008 9:35:13 PM)
Erasing Target
Programming Program Memory (0x0 - 0x3)
Verifying Program Memory (0x0 - 0x3)
Programming Debug Executive (0x-F00 - 0xFFF)
Verifying Debug Executive (0xF00 - 0xFFF)
Programming Debug Vector
Verifying Debug Vector
Programming Configuration Memory
Verifying Configuration Memory
PK2Error0028: Unable to enter debug mode
NOTE: This device requires an ICD Header for debug. See "Header Specification" DS51292.
PICkit 2 Ready

Is there any steps which I left out?
 
Last edited:
Looks like I was wrong, the PicKit2 can't debug the 16F690. Strange that Microchip supply it with the PicKit2.:confused:

Oh well, you can only program it. Have you tried doing "release from reset" (on programmer menu) after you program it?

Mike.
 
Looks like I was wrong, the PicKit2 can't debug the 16F690. Strange that Microchip supply it with the PicKit2.:confused:

Oh well, you can only program it. Have you tried doing "release from reset" (on programmer menu) after you program it?

Mike.
Thanks Pommie! Figured it out,

After writing the code, got to click on Project -> QuickBuild
After that, click on Program the target device

Thanks alot!
 
Good to hear it's working. One thing to try, on the programmer->settings dialog there is options to program after build and run after program, you should try playing with them. With the right combination you can just hit F10 and it will program and run.

Mike.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top