Thread: What't wrong with my program code on PIC18F4520?

  1. #1
    Registered User
    Join Date
    May 2017
    Posts
    2

    What't wrong with my program code on PIC18F4520?

    I am trying to run a program on PIC18F4520(http://www.kynix.com/uploadfiles/pdf...F4520-I2fP.pdf) using PicKit3 & MPLAB IDE. But I got an error: PK3Err0040: The target device is not ready for debugging. Please check your configuration bit settings and program the device before proceeding.

    Whereas when I try to run one of the old program, it's running. My new program code which is not running is:


    Code:
    #pragma config OSC = HS,FCMEN = OFF,IESO = OFF // CONFIG1H
    #pragma config PWRT = OFF, BOREN = SBORDIS, BORV = 0 // CONFIG2L
    #pragma config WDT= 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 = ON // CONFIG7H
    
    #include "p18f4520.h"#include "delays.h"
    
    void main(void) { 
    TRISA=0b11111111;
    TRISB=0b11111111;
    TRISC=0b11111111;
    TRISD=0b00000000;
    TRISE=0x11111111;
    while(1)
    {
    Delay10KTCYx(200);
    LATDbits.LATD3=1 ;
    LATDbits.LATD2=1 ;
    LATDbits.LATD1=1 ;
    }
    
    }

    Please let me know where the issue is? Is it something to do with bootloader?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,666
    PK3Err0040: The target device is not ready for debugging | Microchip
    This question is really about the idiosyncrasies of your particular hardware setup and IDE.

    You should typically start by copy/pasting your error message into google, and seeing where it leads to.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. what is wrong with my code, my program stops
    By aqoonyahan in forum C Programming
    Replies: 2
    Last Post: 02-23-2016, 01:06 AM
  2. ATM Program, what's wrong with my code?
    By kimimaro619 in forum C Programming
    Replies: 3
    Last Post: 03-19-2015, 12:12 PM
  3. What's wrong with the code(Calculator program)
    By rizwan in forum C Programming
    Replies: 10
    Last Post: 10-19-2011, 05:59 PM
  4. what's wrong with this selection sort program code
    By suryak in forum C Programming
    Replies: 14
    Last Post: 05-20-2011, 10:23 AM
  5. What is wrong with my code? My first program......
    By coreyt1111 in forum C++ Programming
    Replies: 11
    Last Post: 11-14-2006, 02:03 PM

Tags for this Thread