Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PIC16F870 with my ICD2 wont work?

Status
Not open for further replies.

tobiasrj

New Member
Hi
I have bought a ICD2 and made a target board for it, with a PIC16F870 microcontroller in it. I have had a few problems with connecting with mplab, but i think it works now.
If i connect to ICD2 and programming the target board i get this message:

Connecting to MPLAB ICD 2
...Connected
Setting Vdd source to target
Target Device PIC16F870 found, revision = a1,a2
...Reading ICD Product ID
Running ICD Self Test
...Passed
MPLAB ICD 2 ready for next operation
Programming Target...
...Validating configuration fields
...Erasing Part
...Programming Program Memory (0x0 - 0x1A)
Verifying...
...Program Memory
...Verify Succeeded
Programming Configuration Bits
.. Config Memory
Verifying configuration memory...
...Verify Succeeded
...Programming succeeded
11-Feb-2009, 17:23:00

MPLAB ICD 2 ready for next operation

But when i pull my cable out off the target board, and tryes to run my microcontroller. the pins RC4 and RC6 is constant ON! And my program should only toggle the RC4 pin ON and OFF every 2 sec. Somebody who can help me?

My program in C-CSS:

#include <16F870.h>
#device adc=8
#use delay(clock=4000000)
#fuses NOWDT,XT, NOPUT, NOPROTECT, NODEBUG, BROWNOUT, LVP, NOCPD, NOWRT
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=9)
#use fast_io(B)

void main()
{
set_tris_c(0b00000000);

while(true)
{


output_high(PIN_C4);
delay_ms(2000);
output_low(PIN_C4);
delay_ms(2000);



}

}
 
Like Mia says, use NOLVP rather than LVP

and get rid of this:
#use fast_io(B)

If you use that, you need to set the tris bits yourself.
 
Thanks for your help it workt, but it was also my crystal who didnt run well.. But now the program is working. But i still can´t use debug mode i just get these messages:

Connecting to MPLAB ICD 2
...Connected
Setting Vdd source to target
Target Device PIC16F870 found, revision = a1,a2
...Reading ICD Product ID
Running ICD Self Test
...Passed
MPLAB ICD 2 ready for next operation
ICDWarn0015: Program memory has changed since last program operation? Continue with Debug operation?
Running Target
ICD0083: Debug: Unable to enter debug mode. Please double click this message for more information.
ICD0069: Debug: Unable to run target
MPLAB ICD 2 ready for next operation

What can be wrong? And do you now how to meassure a crystal? i have tried with a multimeter and meassured Hertz but dosent work.. is it impossible to messaure it in the circuit?
 
I have now turned off "NODEBUG" and i already have a 10 kohm resistor between MCLR and VDD.. But it still give the same errors? :S
 
The crystal is 4 Mhz and the caps is about 100nF i think, i have just changed the caps with some others to get the program running.. but dont now the value of them.. i can meassure them tommorow on work.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top