Electronic – Programming PIC18F4680 using PicKit4

ledpicpickit

I received my PicKit4 and some uCs. Since my only PDIP package is a PIC18F4680 I want to test the programmer and MPLAB IDE with it. I set the board following this tutorial. I loaded an template project (pic18_c_template) and configured the properties for my uC.

Since I was not able to find the grid view to set the datapin (like in the video), I wanted to configure a digital pin as a blinking LED. I found some example code for the right registers.

******************************************************************************/
/* Files to Include */
/******************************************************************************/

#if defined(__XC)
    #include <xc.h> /* XC8 General Include File */
#elif defined(HI_TECH_C)
    #include <htc.h> /* HiTech General Include File */
#elif defined(__18CXX)
    #include <p18cxxx.h> /* C18 General Include File */
#endif

#if defined(__XC) || defined(HI_TECH_C)

#include <stdint.h> /* For uint8_t definition */
#include <stdbool.h> /* For true/false definition */

#endif

#include "system.h" /* System funct/params, like osc/peripheral config */
#include "user.h" /* User funct/params, such as InitApp */

/******************************************************************************/
/* User Global Variable Declaration */
/******************************************************************************/

/* i.e. uint8_t <variable_name>; */

/******************************************************************************/
/* Main Program */
/******************************************************************************/



void main(void)
{
    /* Configure the oscillator for the device */
    ConfigureOscillator();

    /* Initialize I/O and Peripherals for application */
    InitApp();

    /* TODO <INSERT USER APPLICATION CODE HERE> */

    TRISB0 = 0;

    while(1) {
        RB0 = 1;
        _delay(1000); // 1 Second Delay
        RB0 = 0; // LED OFF
        _delay(1000); // 1 Second Delay
    }

}

Uploading the program was apparently no problem

[\[code\]Connecting to MPLAB PICkit 4...

Currently loaded versions:
Application version............00.05.41
Boot version...................01.00.00
Script version.................00.03.33
Script build number............0540a22e50
PICkit 4 is supplying power to the target (3.30 volts).
Target device PIC18F4680 found.
Device Revision Id = 0x7

Calculating memory ranges for operation...

Erasing...

The following memory area(s) will be programmed:
program memory: start address = 0x0, end address = 0x7f

Programming/Verify complete\[/code\]]

but the load on RB0 (pin 33) is not blinking. My guess is that I need to connect an oscillator to time the delay, but shouldnt the LED blink regardless? (At least in some intervals).

Also the programmers led strip is yellow, which means 'programming'. But shoudnt the program process be completed?

Best Answer

Have a look at your configuration bits. (could be done in MPLABX)
You had to activate the internal oszillator (FOSC-Bits)

#pragma config OSC = IRCIO6

You also had to select the Pins as digital (default state is analog)

ADCON1 = 0x3F;