Hola Amigos
Estoy Tratando de Pasar Un Codigo que Encontre en la WEB, Este Esta Hecho en Mikro C y Me Gustaria poder Pasarlo a CCS.
El Codigo en Cuestion es Este:
sbit Output_LED at GP5_bit;
unsigned short i, TIME_UP;
void interrupt(void){
if(PIR1.TMR1IF) {
i ++;
if(i == 3) TIME_UP = 1; // Time Up in 1.5 sec
PIR1.TMR1IF = 0;
}
}
void main() {
TRISIO = 0b00000011 ;
ANSEL = 0x00;
INTCON = 0b11000000 ; // Enable GIE and PEIE for Timer1 overflow interrpt
PIE1 = 0b00000001 ; // Enable TMR1IE
// Configure Comparator module
// CIN- pin is configured as analog,
// CIN+ pin is configured as I/O,
// COUT pin is configured as I/O,
// Comparator output available internally,
// CVREF is non-inverting input
// CINV is set to 1
CMCON0 = 0b00010100;
VRCON = 0b10100011; // Vref is set to VDD/8
Output_LED = 0;
do{
TMR1H = 0x00;
TMR1L = 0x00;
TIME_UP = 0;
i = 0;
T1CON = 0b00110000; // Configure Timer 1
if(CMCON0.COUT){ // First clap detected
Delay_ms(100);
T1CON.TMR1ON = 1; // Start Timer1
while(!CMCON0.COUT && !TIME_UP); // Wait until second clap is
T1CON.TMR1ON = 0; // detected or Timer1 overflows
if(CMCON0.COUT && !TIME_UP) Output_LED = ~Output_LED;
Delay_ms(100);
}
} while(1);
}
Esto es lo que Tengo:
#include <12F675.h>
#device ADC=10
#FUSES NOWDT //No Watch Dog Timer
#FUSES PUT //Power Up Timer
#FUSES NOMCLR //Master Clear pin used for I/O
#FUSES PROTECT //Code protected from reads
#FUSES CPD //Data EEPROM Code Protected
#use delay(internal=4MHz)
#use fast_io(A)
#define ACT_RELE PIN_A5 //Aqui Conectamos la Etapa del RELE
unsigned int Contador;
unsigned short TiempoTerminado;
#INT_TIMER1
void TIMER1_isr(void)
{
Contador++;
if ( Contador == 3 )
{
TiempoTerminado = 1;
}
}
void main()
{
set_tris_a(0x02);
setup_comparator(A1_VR | COMP_INVERT); //Configuramos el Comparador A1 vs Vref e Invertimos la Salida
setup_vref(VREF_HIGH | 12); //Configuramos el Vref a 3.13v
setup_timer_1(T1_INTERNAL|T1_DIV_BY_8); //524 ms overflow
enable_interrupts(INT_TIMER1);
enable_interrupts(GLOBAL);
output_a(0x00);
while(TRUE)
{
set_timer1(0);
Contador = 0;
TiempoTerminado = 0;
if ( C1OUT == 1 ) //Detectamos el Primer Aplauso
{
delay_ms(100);
}
}
}
OJO He Cambiado El Valor de Vref que traia Originalmente para adecuarlo a mis Necesidades, Donde Me Quedo Atorado es en las Instrucciones :
- TMR1ON
- !CMCON0.COUT && !TIME_UP
- CMCON0.COUT && !TIME_UP
De Antemano Agradesco Su Ayuda

.