Hola, estoy teniendo muchos problemas tratando de poner el pic en modo sleep, pareceria que entra al sleep mode pero mido la corriente y me consume 4 ma, segun la hoja de datos tendria que consumir 105 nA!, el pic esta alimentado usando el cicuito que adjunto, dos diodos conectados a la vdd del pic, cuando se corta la tension se alimenta desde la bateria(3v), estoy midiendo la corriente que sale de la bateria. Tambien probe ponerlo en deep sleep y la corriente baja a 2.3 ma, o sea que pareceria que entra en los modos pero no se porque consume tanto, ya descarte que sea otra cosa que me consume corriente porque desde la bateria va derecho al diodo y al vdd del pic.Alguna idea, algun problema similar? - aca posteo el codigo para los dos casos(en el segundo escribi una parte en assembler para asegurarme que no haya delay entre dos instrucciones(como pide la hoja de datos)
CODIGO PONGO EN SLEEP MODE
#include <18F46J50.h>
#fuses NOWDT,NOPROTECT,NODEBUG,HS
#use delay(clock=20mhz)
#DEFINE LED PIN_A0
void main() {
byte i;
for(i=0;i<=4;i=i+1) { ///PRENDE Y APAGA LED 5 VECES Y ENTRA EN SLEEP MODE
output_HIGH(led);
DELAY_MS(500);
output_LOW(led);
DELAY_MS(500);
}
delay_ms(1000);
set_tris_c (255); //pongo todas las patas como entradas
set_tris_d (255);
set_tris_a(255);
set_tris_b(255);
set_tris_e(255);
SLEEP();
while(1); //ESPERO QUE ENTRE EN SLEEP MODE, AHI APAGO LA FUENTE Y MIDO LA CORRIENTE QUE SALE DE LA BATERIA
}
CODIGO PONGO EN DEEP SLEEP MODE
#include <18F46J50.h>
#fuses NOWDT,NOPROTECT,NODEBUG,HS
#use delay(clock=20mhz)
#DEFINE LED PIN_A0
#byte WDTCON = 4032
#BYTE OSCCON = 4051
#BYTE DSCONH=3917
void main() {
byte i;
for(i=0;i<=4;i=i+1) { ///PRENDE Y APAGA LED 5 VECES Y ENTRA EN DEEP SLEEP MODE
output_HIGH(led);
DELAY_MS(500);
output_LOW(led);
DELAY_MS(500);
}
delay_ms(1000);
set_tris_c (255); //pongo todas las patas como entradas
set_tris_d (255);
set_tris_a(255);
set_tris_b(255);
set_tris_e(255);
#ASM
BSF WDTCON, 7 // Setting the REGSLP
BCF OSCCON, 7 //Clearing the IDLEN bit
BCF INTCON,7 //Clearing the GIE bit
BSF DSCONH, 7 //Setting the DSEN bit
sleep
#endasm //ESPERO QUE ENTRE EN SLEEP MODE, AHI APAGO LA FUENTE Y MIDO LA CORRIENTE QUE SALE DE LA BATERIA
}
INSTRUCCIONES EN HOJA DE DATOS PARA ENTRAR EN DEEP SLEEP MODE
Setting the REGSLP (WDTCON<7>) bit
• Clearing the IDLEN bit
• Clearing the GIE bit
• Setting the DSEN bit (DSCONH<7>)
• Executing the SLEEP instruction immediately after
setting DSEN (no delay or interrupts in between