Newbie help. PIC18F45k20 pickit debug express


Results 1 to 20 of 20

Threaded View

  1. #1
    Join Date
    Aug 2011
    Posts
    12

    Default Newbie help. PIC18F45k20 pickit debug express

    Hi all,

    Im a serious newbie at microcontrollers. Trying to get into this as a hobby but I think I am in over my head right now. I need some help.

    Im trying to use my PICkit3 programmer with stand along software to program the programs I make in pbp. So far none of my programs work, however if I copy paste a sample program from my pickit3 debug express development kit from microchip. It works fine. The problem is, its in c language and I have no idea what any of it means.
    Example: Blink LED

    //************************************************** ****************************
    //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.
    // ************************************************** *****************
    // PIC18F45K20 Starter Kit Lesson 2 - Blink LED
    //
    // This lesson blinks LED 7 on the demo board by using a delay and
    // loop.
    //
    // ************************************************** *****************
    // * See included documentation for Lesson instructions *
    // ************************************************** *****************

    /** C O N F I G U R A T I O N B I T S ******************************/

    #pragma config FOSC = INTIO67, FCMEN = OFF, IESO = OFF // CONFIG1H
    #pragma config PWRT = OFF, BOREN = SBORDIS, BORV = 30 // CONFIG2L
    #pragma config WDTEN = OFF, WDTPS = 32768 // CONFIG2H
    #pragma config MCLRE = OFF, LPT1OSC = OFF, PBADEN = ON, CCP2MX = PORTC // CONFIG3H
    #pragma config STVREN = ON, LVP = OFF, XINST = OFF // CONFIG4L
    #pragma config CP0 = OFF, CP1 = OFF, CP2 = OFF, CP3 = OFF // CONFIG5L
    #pragma config CPB = OFF, CPD = OFF // CONFIG5H
    #pragma config WRT0 = OFF, WRT1 = OFF, WRT2 = OFF, WRT3 = OFF // CONFIG6L
    #pragma config WRTB = OFF, WRTC = OFF, WRTD = OFF // CONFIG6H
    #pragma config EBTR0 = OFF, EBTR1 = OFF, EBTR2 = OFF, EBTR3 = OFF // CONFIG7L
    #pragma config EBTRB = OFF // CONFIG7H


    /** I N C L U D E S **************************************************/
    #include "p18f45k20.h"
    #include "delays.h"

    /** D E C L A R A T I O N S *******************************************/


    void main (void)
    {

    TRISD = 0b01111111; // PORTD bit 7 to output (0) ; bits 6:0 are inputs (1)

    while (1)
    {
    LATDbits.LATD7 = ~LATDbits.LATD7; // toggle LATD

    Delay1KTCYx(50); // Delay 50 x 1000 = 50,000 cycles; 200ms @ 1MHz
    }

    }

    but if I program a similar blink sample code from pbp, it doesn't work. Why? Im guessing is has something to do with not defining configurations but I don't know.
    Example: Blink LED

    ' PicBasic program to blink an LED connected to PORTD.0 about once a second

    Symbol PORTD = 8 ' Set PORTD address
    Symbol TRISD = $88 ' Set TRISD address

    Poke TRISD, 0 ' Set PORTD to all output

    loop: Poke PORTD, 1 ' Turn on LED connected to PORTD.0
    Pause 500 ' Delay for .5 seconds

    Poke PORTD, 0 ' Turn off LED connected to PORTD.0
    Pause 500 ' Delay for .5 seconds

    Goto loop ' Go back to loop and blink LED forever
    End

    I should also note that I am only using the trial version if PBP right now. I would like to purchase it if I could ever get one of my programs to work. Also, I am using the MicroCode Studio IDE. Please Help. Thanks
    Last edited by redmobiusv; - 8th August 2011 at 16:31.
    I am microcontroller stupid!!

Members who have read this thread : 1

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