Beginner- blinking led's on pickit 2 starter kit


Closed Thread
Results 1 to 24 of 24

Hybrid View

  1. #1
    Join Date
    Oct 2009
    Location
    Utah, USA
    Posts
    427


    Did you find this post helpful? Yes | No

    Default Re: Beginner- blinking led's on pickit 2 starter kit

    I have never used MPlab... BUT I do know that the free version of MicroCodeStudio does support the 16F690.

    You are correct that the pickit software imports HEX code. So you write your software in the MCS environment. Compile using PBP and then import the hex into the pickit software and program your pic.

    I (and others) can help you get MCS (free version) up and running, not much to it really. Other than pointing it to PBP for the compiler.

    I then just goto the pickit window and manually import the hex file and program.

    That is about all I know to help you with. No experience with MPlab here.

    ---------------------------

    Below is a snippit of code showing how to set the configuration fuses from within your program. look toward the top for the line that begins with @.

    Also lower down you will see several configuration registers and some typical settings with comments to explain.

    Code:
    ' 16F690 '**************************************************************** '* Name : UNTITLED.BAS * '* Author : [select VIEW...EDITOR OPTIONS] * '* Notice : Copyright (c) 2007 [select VIEW...EDITOR OPTIONS] * '* : All Rights Reserved * '* Date : 11/25/2007 * '* Version : 1.0 * '* Notes : * '* : * '**************************************************************** @ device pic16F690, intrc_osc_noclkout, BOD_OFF, PWRT_OFF, wdt_off, mclr_off,protect_off
    INCLUDE
    "Temp_Convert_CtoFonly.pbp"
    ' -----[ I/O Definitions ]------------------------------------------
    ' DEFINE DEBUG_REGG PORTA 'set debug port to porta ' DEFINE DEBUG_BIT 0 'use pin a0 of porta for debug
    ' DEFINE DEBUG_BAUD 2400 'set baud rate to 2400 ' DEFINE DEBUG_MODE 0 'communicate in true mode ' DEFINE DEBUGIN_BIT 1 'use pin a0 of porta for debug ' -----[ Variables ]------------------------------------------------
    x88 VAR BYTE[9] 'array to hold the 8 column bytes
    msg VAR BYTE[30] 'array to hold current message col VAR BYTE 'byte to hold fetched coulmn row VAR BYTE 'byte to hold current row being scanned via walking "1" r VAR BYTE 'row counter i VAR BYTE 'col counter char VAR BYTE 'current character to fetch view VAR BYTE 'delay to allow eye to see ltr VAR BYTE 'number of letters in current message pos VAR BYTE 'scrolling column counter len VAR BYTE 'length of current char or msg being scrolled now VAR BYTE 'holds current position for storing data to matrix pix VAR BYTE done VAR BYTE car VAR BYTE ' holds position of car, "0" is the car crash VAR BYTE speed VAR BYTE ' scrolling speed, lower is faster BtnTmr VAR BYTE 'counter for decreminging LOn VAR WORD 'time for leds to be on LOff VAR WORD 'time for leds to be off wface VAR BYTE mode VAR BYTE C VAR WORD ; Celsius also used as Car race Lap counter F VAR WORD ; Fahrenheit '-------------[variables and constants for temperature routine]-------------- DS18B20_9bit CON %00011111 ' set resolution on DS18B20 93.75ms, 0.5°C Comm_Pin VAR PortA.4 ' One-wire Data-Pin "DQ" on PortA.4 Busy VAR BIT ' Busy Status-Bit Raw VAR WORD ' RAW Temperature readings TempF VAR WORD ' Temp in deg F Cold_Bit VAR Raw.BIT11' Sign-Bit for +/- Temp. 1 = Below 0 deg C Real_Cold CON 1 ' Define Real_Cold = 1 Sign VAR BYTE ' +/- sign for temp display
    ' -----[ Initialization ]--------------------------------------------
    Reset:
    TrisA = %00011000
    'Port A3,A4 inupts rest outputs (A3 cannot output) TrisB = %00000000 'Port B all outputs TrisC = %00000000 'Port C all outputs ansel = 0 'and turn off analog AnselH = 0 'turn of rest of analogs CM1CON0 = 0 'turn off comparators CM2CON0 = 0 'turn off comparators SSPCON.BIT5 = 0 ' disable serial port, pins are I/O OPTION_REG = %10000000 '1 turn off weak pull ups INTCON = %00000000
    ' -----[starting Constants ]------------------------------------------------

    Last edited by Heckler; - 21st June 2011 at 20:38. Reason: formatting corrections
    Dwight
    These PIC's are like intricate puzzles just waiting for one to discover their secrets and MASTER their capabilities.

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Re: Beginner- blinking led's on pickit 2 starter kit

    Everything can be done within MPLAB (Code, Programmin etc). You just need to start a new project, select the right toolsuite, and start from there. not sure where you stuck with it.

    If PIbasic toolsuite is properly installed you should be able to do everything in a snap


    About the configuration fuses, check the one used in the assembler code, and check the FAQ. There's a whole thread explaining how to set them. Within MPLAB, the @ Device line shouldn't work, use MPASM @ _CONFIG, still explained in the FAQ.

    Bellow, a compilation of few handy things
    http://www.picbasic.co.uk/forum/showthread.php?t=11116

    HTH
    Last edited by mister_e; - 22nd June 2011 at 02:59.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Jun 2011
    Posts
    19


    Did you find this post helpful? Yes | No

    Default Re: Beginner- blinking led's on pickit 2 starter kit

    how do you compile to hex with microstudio and would you recommend i just use another power supply instead of the pickit 2? thanks again

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Re: Beginner- blinking led's on pickit 2 starter kit

    I ALWAYS recommend to use external power supply, just for safety sake.

    Since I don't remember of any, I think I should do some step-by-step guide for beginners. 1 for Microcode studio, and one for MPLAB using PBPDemo.

    Hows that sound?
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  5. #5
    Join Date
    Oct 2009
    Location
    Utah, USA
    Posts
    427


    Did you find this post helpful? Yes | No

    Angry Re: Beginner- blinking led's on pickit 2 starter kit

    Hey Jason,

    Firstly, I can't say wether MPLab is more or less capable than MCS. It's just the only one I know and use.

    In order to compile in MCS I believe you only need to go to VIEW, COMPILE AND PROGRAM OPTIONS and tell MCS where to find PBP.
    (Mine is just C:\pbp)

    For Me I just use the compile button on the upper left of the mcs window (below NEW) I have not bothered to get "Compile Progarm" to work.

    Below is a post I made in another thread that might help...

    I use MicroCode Studio...
    I just compile the program in MCS, then move over to the pickit2 window and do a "File", "Import Hex" and go to the directory where MCS put the .hex file and load it and "Write" to the PIC. Mine are under C:\Program Files\Mecanique\MCS.

    Just open up MCS and Pickit2 and leave them open for the duration of your programming / editing session.

    Once you locat the directory that MCS stores the .hex file, Pickit2 will find it the next time you compile. If you are testing the same program repeatedly you will find the .hex file you are working on, listed as a recent file, under the "File" drop down in the Pickit2 window. You can just double click on the existing link under the "File" menu and you are ready to "Write" to your PIC.

    I have not bothered to figure out how to get MCS to automatically compile and burn.

    Sometimes I will manually modify the PIC "fuses" in the Pickit2 window just before burning. I'm not that good at setting the "fuses" correctly in my program yet. (look below the "Help" drop down menu, in the Pickit2 window, and you will see a "Configuration" link which will allow you to change the "fuse" bits.

    Hope this addresses your question
    good luck
    Dwight


    Personally I think the PICkit2 is ideal to supply power for your test circut as long as you arent pulling too much current.

    I can, literally, make a change to a program, compile, import to pickit and program a PIC to test the code in less than 15 seconds. I just leave the pickit window open along side of the MCS window.

    NOTE: here is a GOTCHA to watch out for with the LPC demo board...
    If you are trying to read the onboard POT into RA0 and send the results to a DEBUG window... there is a confilict as RA0 is also used for DEBUG... so what I did is to cut the trace from the POT to RA0 and put a loose wire instead. That way I can take the output from the POT to any of the PINS that I want to, not just RA0. (See the LPC schematic in its documentation. (this one drove me nuts for a while)

    Hope you are making progress


    Dwight
    These PIC's are like intricate puzzles just waiting for one to discover their secrets and MASTER their capabilities.

  6. #6
    Join Date
    Jun 2011
    Posts
    19


    Did you find this post helpful? Yes | No

    Default Re: Beginner- blinking led's on pickit 2 starter kit

    I get an illegal opcode error when I run that configuration command and the 16f690 device in microstudio dissapeared

  7. #7
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Re: Beginner- blinking led's on pickit 2 starter kit

    Quote Originally Posted by Jasonstew View Post
    I get an illegal opcode error when I run that configuration command and the 16f690 device in microstudio dissapeared
    Which configuration command do you refer to? Which opcode ?
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  8. #8
    Join Date
    Jun 2011
    Posts
    19


    Did you find this post helpful? Yes | No

    Default Re: Beginner- blinking led's on pickit 2 starter kit

    the @ device pic16F690, intrc_osc_noclkout, BOD_OFF, PWRT_OFF, wdt_off, mclr_off,protect_off
    command and the pic16F690 opcode error

  9. #9
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default Re: Beginner- blinking led's on pickit 2 starter kit

    Here is some info on how to set your configuration fuses. http://www.picbasic.co.uk/forum/cont...o-your-Program They are case sensitive, so changing them all to capitals will help. Here is one way to do it, if you wanted it in your code space.

    Code:
    @ __CONFIG _INTRC_OSC_NOCLKOUT & _BOD_OFF & _PWRTE_OFF & _WDT_OFF & _MCLRE_OFF & _CP_OFF
    You may notice that there is no mclr_off or protect_off options in the P16F690.INC in the MPLAB directory. That is causing some of the errors.

  10. #10
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Re: Beginner- blinking led's on pickit 2 starter kit

    Quote Originally Posted by Jasonstew View Post
    how do you compile to hex with microstudio and would you recommend i just use another power supply instead of the pickit 2? thanks again
    PICKit2 works great with MCS, you would start the pickit software and start MCS, set the PICKit2 to auto import the hex file named for your project, then each time you recompile in MCS it will automatically reload the hex and reprogram the PIC. I use those Demo boards sometimes and they work well within their limitations. I doubt the Demo version of PBP will allow you to do very much in the way of programming a pic unless you are very clever to optimize your code. BTW for the demo board use the PICKit2 power is adequate, it is short tolerant in that it will crash and protect your USB, at least it does mine. It allows you to select the PIC's operating voltage too.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts