navegante 420
la nave nodriza
Bueno el pick no esta jodio, acabos de probar con uno virgen y tampoco anda.
Segun el libro de CCS+proteus pag 239 !!! advierte que "hay un error de asignacion en el fichero de cabezera del 18F4520.h (solo en este?) al usar la funcion setup_comparator(), sugieren asignar directamente el valor que corresponda al byte de config CMCON, Lo apunto para verificar....
#include <18F4550.h>
#FUSES NOWDT //No Watch Dog Timer
#FUSES WDT128 //Watch Dog Timer uses 1:128 Postscale
#FUSES INTRC_IO //Internal RC Osc, no CLKOUT
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOBROWNOUT //No brownout reset
#FUSES BORV20 //Brownout reset at 2.0V
#FUSES NOPUT //No Power Up Timer
#FUSES NOCPD //No EE protection
#FUSES STVREN //Stack full/underflow will cause reset
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC1 used for I/O
#FUSES NOWRT //Program memory not write protected
#FUSES NOWRTD //Data EEPROM not write protected
#FUSES IESO //Internal External Switch Over mode enabled
#FUSES FCMEN //Fail-safe clock monitor enabled
#FUSES PBADEN //PORTB pins are configured as analog input channels on RESET
#FUSES NOWRTC //configuration not registers write protected
#FUSES NOWRTB //Boot block not write protected
#FUSES NOEBTR //Memory not protected from table reads
#FUSES NOEBTRB //Boot block not protected from table reads
#FUSES NOCPB //No Boot Block code protection
#FUSES MCLR //Master Clear pin enabled
#FUSES LPT1OSC //Timer1 configured for low-power operation
#FUSES NOXINST //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#FUSES PLL12 //Divide By 12(48MHz oscillator input)
#FUSES CPUDIV4 //System Clock by 4
#FUSES USBDIV //USB clock source comes from PLL divide by 2
#FUSES VREGEN //USB voltage regulator enabled
#FUSES ICPRT //ICPRT enabled
#use delay(clock=8000000)
#use i2c(Master,Fast,sda=PIN_B0,scl=PIN_B2)
#use fast_io (A)
#use fast_io (B)
#use fast_io (C)
#use fast_io (D)
#byte CMCON=0xFB4
#int_COMP
void COMP_isr(void)
{
if(C1OUT==1)output_high (pin_D4);
else output_low (pin_D4);
if(C2OUT==1)output_high (pin_D5);
else output_low (pin_D5);
clear_interrupt(INT_COMP);
}
void main()
{
set_tris_D (0b11000000);
set_tris_A (0b11111111);
set_tris_B (0b11111100);
setup_timer_0(RTCC_INTERNAL);
setup_timer_1(T1_INTERNAL|T1_DIV_BY_1);
enable_interrupts(GLOBAL);
//enable_interrupts(INT_RB);
enable_interrupts(INT_COMP);
setup_vref(VREF_LOW|5|VREF_F5);
CMCON=0b00000110;
setup_oscillator(OSC_8MHZ|OSC_TIMER1|OSC_31250|OSC_PLL_OFF);
output_D(0);