PIC16f690

Discussion in 'Embedded Systems and Microcontrollers' started by JBM, Feb 4, 2016.

  1. JBM

    Thread Starter New Member

    Feb 4, 2016
    15
    1
    hello ppl,
    I am new to pic microcontroller programming in mplab
    I am coding a normal led blinking program and it does not work and shows like this

    Connecting to MPLAB ICD 3...
    Firmware Suite Version.....01.32.10
    Firmware type..............Midrange

    Target detected
    Target Device ID (0x0) does not match expected Device ID (0x1400).

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

    Programming...
    program memory
    Address: 0 Expected Value: 118a Received Value: 0
    Failed to program device
    I am using a external power supply of 12v and regulated by voltage regulator to 5v
    Please help me with this
     
  2. John P

    AAC Fanatic!

    Oct 14, 2008
    1,632
    224
    It sounds as if you're using a programmer which isn't responding to the computer, or the processor isn't connected to it. When it says "Target Device ID (0x0) does not match expected Device ID (0x1400)" it means it can't find your chip.
     
  3. Picbuster

    Member

    Dec 2, 2013
    373
    50
    Please provide:
    schematic
    programmer type and make.
     
  4. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
    Target detected
    Target Device ID (0x0) does not match expected Device ID (0x1400).

    Programming...
    program memory
    Address: 0 Expected Value: 118a Received Value: 0

    What both of these have in common is the value of zero. That means your programmer is not properly connected to the target (the PIC).

    There are 5 wires that need go between the programmer and the target: Vcc, GND, Vpp, data and clock. Check these connections are correct.

    The note also says you are using the ICD 3 as the programmer. This is a rather large device oft referred to as the "hockey puck" due to it's similar size and shape. Is this what you have as a programmer? If you talk to the wrong programmer you get bad results.

     
  5. JBM

    Thread Starter New Member

    Feb 4, 2016
    15
    1
    Sorry, Its just a test circuit so i have no design
    Its a basic program of led blinking
    I use a pic16f690 microcontroller
     
  6. JBM

    Thread Starter New Member

    Feb 4, 2016
    15
    1
    I checked all these connections and it is okey
    I am using ICD 3 programmer itself but stil it does not work.
     
  7. JBM

    Thread Starter New Member

    Feb 4, 2016
    15
    1
    I am using an crystal oscillator of 15Mhz, 22pF capacitors on either sides. 10k resistor between MCLR and VDD and i use a 7805 voltage regulator.
    This is what i see now

    Connecting to MPLAB ICD 3...
    Firmware Suite Version.....01.32.10
    Firmware type..............Midrange

    Target detected
    Target Device ID (0x0) does not match expected Device ID (0x1400).

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

    Programming...
    program memory
    Address: 0 Expected Value: 118a Received Value: 0
    Failed to program device
     
  8. Sonoran Desert Tortoise

    Member

    Oct 30, 2014
    53
    34
    Get rid of the crystal oscillator and use the internal oscillator.
    Remove everything from your board and connect only the five wires that Ernie mentioned.
     
    spinnaker likes this.
  9. JBM

    Thread Starter New Member

    Feb 4, 2016
    15
    1
    I tried with the internal oscillator of 4Mhz and still shows the same
     
  10. Sonoran Desert Tortoise

    Member

    Oct 30, 2014
    53
    34
    post of photo of your setup. With programmer and programmer board (or proto-board). Close-up and clear please.
     
  11. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
    Is the device powered? Either from the external circuit (best to deliver power to everything) or off the ICD (which is limited in the power it can provide, and usually it is powering your entire circuit).

    The oscillator does not matter one little bit as programming just needs the programming voltages and the data and clock, as the processor itself is not running. There is separate hardware used just for programming.

    Do you have anything else connected to data, clock, or MCLR? Any of these if loaded can corrupt the signals.
     
  12. Sonoran Desert Tortoise

    Member

    Oct 30, 2014
    53
    34
    I only suggested getting rid of the excess circuitry to insure there was no interference with the programming (since he mentioned it was present).
     
  13. Picbuster

    Member

    Dec 2, 2013
    373
    50
    But you need hardware to run it and pickit to program ( advice; do not use a third party progger always a problem save money but pay double to get it to work)

    connections to pickit
    see attached schematic (pinout for dill and soic20 NOT for QFN_20)
     
  14. JBM

    Thread Starter New Member

    Feb 4, 2016
    15
    1
    This is the code and configuratins bits. please check if its okey
    Code (C):
    1.  
    2. #include <stdio.h>
    3. #include <stdlib.h>
    4.  
    5. // PIC16F690 Configuration Bit Settings
    6. // 'C' source line config statements
    7.  
    8. #include <xc.h>
    9. #define _XTAL_FREQ=15000000
    10. #define __delay_ms(x)
    11. // #pragma config statements should precede project file includes.
    12. // Use project enums instead of #define for ON and OFF.
    13.  
    14. // CONFIG
    15. #pragma config FOSC = HS  // Oscillator Selection bits (HS oscillator: High-speed crystal/resonator on RA4/OSC2/CLKOUT and RA5/OSC1/CLKIN)
    16. #pragma config WDTE = OFF  // Watchdog Timer Enable bit (WDT disabled and can be enabled by SWDTEN bit of the WDTCON register)
    17. #pragma config PWRTE = OFF  // Power-up Timer Enable bit (PWRT disabled)
    18. #pragma config MCLRE = ON  // MCLR Pin Function Select bit (MCLR pin function is MCLR)
    19. #pragma config CP = OFF  // Code Protection bit (Program memory code protection is disabled)
    20. #pragma config CPD = OFF  // Data Code Protection bit (Data memory code protection is disabled)
    21. #pragma config BOREN = ON  // Brown-out Reset Selection bits (BOR enabled)
    22. #pragma config IESO = OFF  // Internal External Switchover bit (Internal External Switchover mode is disabled)
    23. #pragma config FCMEN = OFF  // Fail-Safe Clock Monitor Enabled bit (Fail-Safe Clock Monitor is disabled)
    24.  
    25. void main()
    26. {
    27.   TRISC4 = 0;
    28.   while(1)
    29.   {
    30.   RC4=1;
    31.   __delay_ms(1000);
    32.   RC4=0;
    33.   __delay_ms(1000);
    34.   }
    35. }
    Mod edit: added code tags
     
    Last edited by a moderator: Feb 12, 2016
  15. David Fowler

    New Member

    Feb 11, 2016
    25
    0
    The code looks ok but isn't your problem writing out to the PIC? What programmer are you using?
     
  16. JBM

    Thread Starter New Member

    Feb 4, 2016
    15
    1
    People its working. Thanks for the help
    MCLR pin was not connected
    so now its working
    but a small problem the led is lit up but is not blinking.
     
    ErnieM likes this.
  17. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
    Thanks for letting us know what it finally was.

    Btw, I've been working with PICs for 2 decades now and my odds of connecting the programmer up correctly are about 50-50 the first time. I am forever swapping data and clock.

    Even on a PCB once. Just once.
     
  18. JohnInTX

    Moderator

    Jun 26, 2012
    2,338
    1,019
    Try adding:
    TRISC = 0b11101111 // always write TRIS as a byte instead of individual bits. This sets RC4 to output
    ANSEL = 0; // ports digital even though RC4 is not an analog input
    ANSELH = 0;
    CCP1CON = 0; // make sure PWM is off
    CM2CON0 = 0; // make sure comparator output is disabled

    If that doesn't make it work try:
    PORTC = 0xff;
    and
    PORTC = 0x00;
    for your LED flasher and let us know if that works.

    How do you have your LED hooked up? Are you using a resistor in series with it?
    Presumably you have an external 15MHz crystal hooked up to OSC1/2 with suitable loading caps, based on your config bits.
     
    Last edited: Feb 12, 2016
  19. John P

    AAC Fanatic!

    Oct 14, 2008
    1,632
    224
    Here is the start of a PIC16F690 program that works(!!) but written for MikroC, so with another compiler YMMV.

    Code (Text):
    1.  
    2. // CONFIG : $2007 : 0x0FF4
    3.  
    4. typedef unsigned char byte;
    5.  
    6. void main() {
    7.   byte i, chexum;
    8.  
    9.   trisa = 0b00000000;  // 0-5 available
    10.   trisb = 0b00100000;  // 4-7 available, bit 5 is RX, bit 7 is TX
    11.   trisc = 0b00000000;  // 0-7 available
    12.  
    13.   ansel = 0b00000000;
    14.   anselh = 0;  // No analogs
    15.  
    16.   portc = 0;
    17.   portb = 0;
    18.   porta = 0;
    19.  
    20.   option_reg = 0b00000111;  // Global enable for weak pullups, prescaler to T0, 256:1 (overflow at 30/sec)
    21.   osccon = 0b01110001;  // Internal oscillator, 8MHz
    22.  
    23. etc
    24. etc
    25.  
     
  20. JBM

    Thread Starter New Member

    Feb 4, 2016
    15
    1
    Yes i am using a resistor of 470ohms in series to the led and 15MHz crystal with 22pF capacitors.
     
Loading...