Al poner en funcionamiento un sencillo programa (prender led) en el dspic33ep128gm604 noto con desagrado, que no funciona. vuelvo a intentarlo, y después de muchas cortar y alimentar el dspic, FUNCIONA, Sin embargo vuelvo a cortar la alimentación, y este deja de funcionar, y asi sucesivamente.
. Por favor me podrían explicar porque sucede esto, y cual seria la solución.
obviamente necesito el dspic para una aplicación mas compleja que prender un led. Me he dado cuenta también, que cuando el dspic funciona el Vcap es de 1.8v (hasta 2.4 v según el datasheet), cuando deja de hacerlo el Vcap es de 3.3, tal vez por ahí este el error, pero no tengo idea de como resolverlo. otra cosa al quemar el mplab este graba normal, sin lanzar algún error. estoy usando el oscilador interno a 40MIPS.
Les dejo lo que programe en MPLAB
#include "xc.h"
#include <libpic30.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
/* Configuration Bit Settings */
//_FOSCSEL(IESO_OFF & FNOSC_PRIPLL);
//_FOSC(FCKSM_CSDCMD & IOL1WAY_ON & OSCIOFNC_OFF & POSCMD_HS);
//_FWDT(FWDTEN_OFF & WINDIS_OFF & WDTPRE_PR128 & WDTPOST_PS32768);
_FOSCSEL(FNOSC_FRC & IESO_OFF); //PWMLOCK_OFF necesario para q funcione el pwm correctamente
// Enable Clock Switching and Configure POSC in HS mode
_FOSC(FCKSM_CSECMD & OSCIOFNC_OFF & POSCMD_NONE);
_FWDT(FWDTEN_OFF & WINDIS_OFF & WDTPRE_PR128 & WDTPOST_PS32768); // Watchdog des-habilitado.
_FICD(JTAGEN_OFF & ICS_PGD2)
////_FPOR(PWMPIN_ON & HPOL_ON & LPOL_ON & ALTI2C_OFF & FPWRT_PWR128)
//
//_FICD(JTAGEN_ON & ICS_PGD2);
//_FBS(BSS_NO_FLASH & BWRP_WRPROTECT_OFF)
//_FGS(GCP_OFF & GWRP_OFF);
void Configuracion_40MIPS(void);
void config_io_digital(void);
int main(void) {
config_io_digital();
Configuracion_40MIPS();
// AD1PCFGL = 0xFFFF;
_TRISB7 = 0;
_LATB7 = 0;
while (1) {
_LATB7 = ~_LATB7;
__delay32(4000000);
}
return 0;
}
void Configuracion_40MIPS(void) {
// Configure PLL prescaler, PLL postscaler, PLL divisor
PLLFBD = 41; // M = 43
_PLLPOST = 0; // N2 = 2
_PLLPRE = 0; // N1 = 2
// Initiate Clock Switch to Internal FRC with PLL (NOSC = 0b001)
__builtin_write_OSCCONH(0x01);
__builtin_write_OSCCONL(0x01);
// Wait for Clock switch to occur
while (_COSC != 0b001);
// delay_ms(500);
// Wait for PLL to lock
while (_LOCK != 1) {
};
}
////void Configuracion_40MIPS(void) {
// CLKDIVbits.PLLPRE = 2; ///* N1 = 4 //CLKDIV = 0x0000; //N1=2 (factor de preescaler), N2=2(factor post-escaler)
// PLLFBD = 30; // M=32. multiplica la entrada a PLL
// CLKDIVbits.PLLPOST = 0; // /* N2 = 2 */
// while (_LOCK == 0);
//}
void config_io_digital(void) { //COFIGURAR PINES DSPIC33EP
ANSELA = 0x00;
ANSELB = 0x00;
ANSELC = 0x00;
}