PIC16f690

Thread Starter

JBM

Joined Feb 4, 2016
15
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
 

John P

Joined Oct 14, 2008
2,026
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.
 

ErnieM

Joined Apr 24, 2011
8,377
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.

 

Thread Starter

JBM

Joined Feb 4, 2016
15
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.
I checked all these connections and it is okey
I am using ICD 3 programmer itself but stil it does not work.
 

Thread Starter

JBM

Joined Feb 4, 2016
15
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
 

ErnieM

Joined Apr 24, 2011
8,377
I checked all these connections and it is okey
I am using ICD 3 programmer itself but stil it does not work.
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.
 
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.
I only suggested getting rid of the excess circuitry to insure there was no interference with the programming (since he mentioned it was present).
 

Picbuster

Joined Dec 2, 2013
1,047
Sorry, Its just a test circuit so i have no design
Its a basic program of led blinking
I use a pic16f690 microcontroller
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)
 

Attachments

Thread Starter

JBM

Joined Feb 4, 2016
15
post of photo of your setup. With programmer and programmer board (or proto-board). Close-up and clear please.
This is the code and configuratins bits. please check if its okey
C:
#include <stdio.h>
#include <stdlib.h>

// PIC16F690 Configuration Bit Settings
// 'C' source line config statements

#include <xc.h>
#define _XTAL_FREQ=15000000
#define __delay_ms(x)
// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.

// CONFIG
#pragma config FOSC = HS  // Oscillator Selection bits (HS oscillator: High-speed crystal/resonator on RA4/OSC2/CLKOUT and RA5/OSC1/CLKIN)
#pragma config WDTE = OFF  // Watchdog Timer Enable bit (WDT disabled and can be enabled by SWDTEN bit of the WDTCON register)
#pragma config PWRTE = OFF  // Power-up Timer Enable bit (PWRT disabled)
#pragma config MCLRE = ON  // MCLR Pin Function Select bit (MCLR pin function is MCLR)
#pragma config CP = OFF  // Code Protection bit (Program memory code protection is disabled)
#pragma config CPD = OFF  // Data Code Protection bit (Data memory code protection is disabled)
#pragma config BOREN = ON  // Brown-out Reset Selection bits (BOR enabled)
#pragma config IESO = OFF  // Internal External Switchover bit (Internal External Switchover mode is disabled)
#pragma config FCMEN = OFF  // Fail-Safe Clock Monitor Enabled bit (Fail-Safe Clock Monitor is disabled)

void main()
{
  TRISC4 = 0;
  while(1)
  {
  RC4=1;
  __delay_ms(1000);
  RC4=0;
  __delay_ms(1000);
  }
}
Mod edit: added code tags
 
Last edited by a moderator:

Thread Starter

JBM

Joined Feb 4, 2016
15
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

Joined Apr 24, 2011
8,377
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.
 

JohnInTX

Joined Jun 26, 2012
4,787
but a small problem the led is lit up but is not blinking.
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:

John P

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

Code:
// CONFIG : $2007 : 0x0FF4

typedef unsigned char byte;

void main() {
  byte i, chexum;

  trisa = 0b00000000;  // 0-5 available
  trisb = 0b00100000;  // 4-7 available, bit 5 is RX, bit 7 is TX
  trisc = 0b00000000;  // 0-7 available
 
  ansel = 0b00000000;
  anselh = 0;  // No analogs

  portc = 0;
  portb = 0;
  porta = 0;

  option_reg = 0b00000111;  // Global enable for weak pullups, prescaler to T0, 256:1 (overflow at 30/sec)
  osccon = 0b01110001;  // Internal oscillator, 8MHz

etc
etc
 

Thread Starter

JBM

Joined Feb 4, 2016
15
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.
Yes i am using a resistor of 470ohms in series to the led and 15MHz crystal with 22pF capacitors.
 
Top