I have Microchip's dsPICDEM 2 Development Board with two MCUs on it, a dsPIC30F4011 Motor Control MCU and a dsPIC30F4013 General Purpose MCU. I need to program both microcontrollers with the MPLAB ICD 2 In-Circuit Debugger.
When I build a test project (with a program that just toggles on and off LEDs D3 and D4), everything is built successfully (using the C30 Language Tools). The program looks like this:
#include <p30fxxxx.h>
#include "delay.h"
int main(void)
{
// setup
LATBbits.LATB0 = 0;
TRISBbits.TRISB0 = 0;
while (1)
{
LATBbits.LATB0 = ~LATBbits.LATB0;
Delay5ms(100);
}
return 0;
}
(the functions prtotyped in delay.h are functions defined in assembly code in delay.s and have been excerpted from Microchip's examples)
When I program any MCU by means of MPLAB 8.80 and the ICD, I get the message Programming succeeded. However, when I run the program on the board, nothing happends (no LED switches on and off).
I have tried including some files into the project:
libpic30-coff.a
under Library Filesp30F4011.gld
under Linker Scriptp30F4011.h
andp30Fxxxx.h
under Header Files
but that has not helped.
I have not been able to find any detailed, step-by-step information on how to program these PICs using the named tools, neither in Microchip's documentation nor on the internet.
What do I have to don in MPLAB IDE 8.80 in order to program both dsPIC30F4011 and dsPIC30F4013 with MPLAB ICD 2, assuming MPLAB IDE and ICD 2 are already set up?
Thank you in advance.
EDIT:
I was using the following directives to set the configuration bits:
_FOSC(CSW_FSCM_OFF & XT_PLL8); //Run this project using an external crystal
//routed via the PLL in 8x multiplier mode
//For the 7.3728 MHz crystal we will derive a
//throughput of 7.3728e+6*8/4 = 14.74 MIPS(Fcy)
//,~67nanoseconds instruction cycle time(Tcy).
_FWDT(WDT_OFF); //Turn off the Watch-Dog Timer.
_FBORPOR(MCLR_EN & PWRT_OFF); //Enable MCLR reset pin and turn off the
//power-up timers.
_FGS(CODE_PROT_OFF); //Disable Code Protection
I saw this code in Microchip's examples.
However, this was not working. Anyway, the solution is as Brett pointed out. I tried it, and it worked from the very first time.
I have tried again the first code, and now it does work. Weird. I still do not know what I was doing wrong.
In addition, I have tried removing the files I included, and I have realized that there is no need to include those libraries / header files / linker scripts into the project.