Arme el siguiente circuito con hard real:
(http://www.todopic.com.ar/foros/index.php?action=dlattach;topic=27876.0;attach=10286)
El código fue el siguiente:
#include <16F877A.h>
#FUSES NOWDT //No Watch Dog Timer
#FUSES HS //High speed Osc (> 4mhz)
#FUSES PUT //Power Up Timer
#FUSES NOPROTECT //Code not protected from reading
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD //No EE protection
#FUSES NOWRT //Program memory not write protected
#use delay(clock=20000000)
#use fast_io(a)
#use fast_io(d)
#int_COMP
COMP_isr()
{
delay_ms(30);
if(C1OUT==1){
output_toggle(PIN_A2);
output_toggle(PIN_D0);
}
if(C2OUT==1){
output_toggle(PIN_A3);
output_toggle(PIN_D1);
}
}
void main()
{
//set_tris_a(0b00000011);
set_tris_d(0b1111100);
setup_adc_ports(NO_ANALOGS);
setup_psp(PSP_DISABLED);
setup_spi(FALSE);
//Comparadores con Vref interna = 2.5V.-
setup_comparator(A0_VR_A1_VR);
setup_vref(VREF_LOW|8);
set_tris_a(0b00000011);
clear_interrupt(INT_COMP);
enable_interrupts(INT_COMP);
enable_interrupts(GLOBAL);
while(1){
}
}
Los leds del puerto D actuaron correctamente, pero los leds del puerto A se alternaban. Acciono el pulsador de A0, enciende el led de A2 y D0. Vuelvo accionar se apaga D0 pero A2 no se ve afectado. Pero si acciono la tecla del pin A1, se apaga el led en A2 y se enciende el led de A3 :shock:
Cambie el orden de las configuraciones y el resultado fue el mismo :?
Todo lo tratado es en CCS :mrgreen:
Saludos!