Using pickit 3 with DSPIC30F2010

I'm just learning to use the PIC microcontrollers and am totally confused having no knowledge prior. I am using a pickit 3 and the DSPIC30F2010. I have used to connect them via the circuit as shown below(i made it myself after lot of digging, couldn't find something that works in the internet). The thing is I am not even sure if the circuit is correct, primarily because i to had power the chip externally via 5V since the pickit seems to unable to power the chip by its own(returing errors like unable to detect VDD),but that kind of feels not normal, i mean the pickit should naturally be able to power the device right?

Despite my assumptions, the processor was detected and i was able to write programs into it, although when i click the verify option in the mplab IPE, it sometimes says 'verify failed' and other times, it is fine. Is this normal? The program i wrote was generated using MICRO C FOR DSPIC and the generated hex file was written via the MPLAB IPE. The program i used was obtained online. Its a program for simply blinking an LED.

//i have used crystal of 16 MHz

void main()
{
TRISE.F0=0;
while (1)
{
PORTE.F0=1;
Delay_ms(1000);
PORTE.F0=0;
Delay_ms(1000);

}
}


But as i understand you can only write programs via the pickit, however you would require another circuit(using an external clock and so) to actually test the program. please help me with this. What would be the circuit required to essentially test the program i written.

• If you get the “Programming/Verify complete” message after programming then it's OK. The separate 'verify' action by default includes verifying other settings in addition to the program memory, and can produce spurious verify fails. Go to settings (advanced) - memory and deselect the automatic memory selection and select just 'program memory' and it should pass, though the PICkit is not the most reliable programmer, it doesn't always verify correctly. – Phil G Mar 25 at 13:53
• thank you for taking to time share that knowledge. But sir, i assume by what you are saying,you are simply implying that the pickit is unreliable with verifying the program, but pretty much reliable for writing programs into it. I just want to know the fidelity of the pickit. – Jagan Mar 27 at 12:57
• So long as it connects correctly to begin with - "Target device dsPICxxxx found. Device Revision ID = xxxx", and you get “Programming/Verify complete” then it has worked. There's some unreliability with each of the steps, but you'll know if it fails. – Phil G Mar 27 at 13:24

No, you don't need an external clock or crystal to test your circuit.

The micro has many clocking options, you can of course use an external clock, or an external oscillator circuit if you need an accurate clock accuracy is like 0.005%. Or, you can use an internal oscillator if you can work with low accuracy timing (internal RC oscillator accuracy is ±2% nominal).

If you want to use the internal oscillator, you should select the option from the configuration bits (choose the internal FRC oscillator). You may also need to specify for microC that you are running at 7.37 MHz (which is the frequency of the internal oscillator). This is necessary for the compiler so that he knows how to translate a 1000ms delay into assembly instructions.

to sum this up, just hook an LED to E0 (don't forget the series resistor), change config bits to select internal oscillator rather than external clock/oscillator, set frequency to 7.37 and you should have your LED blinking.

• thank you so much! Finally the led is blinking. So happy that i could take my first step!!! – Jagan Mar 27 at 13:23
• I tried it with an external clock of frequency 16MHz and two capacitors(20pF) as per the circuit given in the data sheet. Made change to the config bits choosing the clock as primary oscillator with HS mode, i believe that's the mode without any Multiplication or division for the clock frequency as i understand. But this time the LED didn't blink. I looked the output on a DSO, which was a square pulse of frequency 50Hz(if i'm not wrong). The output pulse was correct but it was switching fast, which is contrary to the program(The required delay of 1s). What is wrong, where am i missing. – Jagan Mar 27 at 16:46
• the problem is probably on the software side. I'm not familiar with mikroC but for a compiler to generate a specific delay, you should tell him what frequency are you running on. Then he would replace the "delay_ms(1000) with an equivalent number of instructions, usually NOP or "no operation instruction".You should make sure that you are telling the compiler that you are running at 16Mhz or else he would generate the wrong number of instructions and thus the timing wouldn't be correct. – fhlb Mar 30 at 10:41
• i did change the config bits to external oscillator of 16MHz with HS mode, but the led didn't blink. Is there something else i might be doing wrong? Also if it helps at all i checked the output waveform on a DSO as i mentioned. For the settings with internal oscillator the square pulse was moving, while for the external oscillator the pulse was still. If i'm taking stupid please ignore. Also if its fine, could you provide a code to run in MPLAB X IDE, so that i can verify whether the problem is on the software side or not. – Jagan Apr 3 at 18:19
• if you want to make sure if your oscillator circuit is working (hardware wise) you can put your scope's probe to 10x mode (for lower capacitance) and put the oscilloscope on OSC1 or OSC2 pins, you should see a periodic waveform (square wave or maybe sinusoidal) of frequency 16Mhz. If not then either the oscillator is failing to startup or maybe the oscillator driver is turned off or configured correctly or even damaged. – fhlb Apr 4 at 11:28