#define DATA_PIN PIN_A0 // DATA, Dato serial del tono
#define CLOCK_PIN PIN_A1 // CLOCK, Reloj DTMF
#define CE_PIN PIN_A2 // CE, Habilita Chip DMTF, en bajo
int16 numero;
void Init_HT9200(void);
void envia_dtmf(numero);
void main(){
set_tris_a(0b11100000);
output_a(0x00);
output_c(0);
Init_HT9200(); // init the chip
while(1)
{
output_toggle(PIN_C1);
envia_dtmf(1);envia_dtmf(0x1F); ///fprintf(debug,"1 = 697, 1209\r\n");//digito 2 //off dtmf
envia_dtmf
(2);envia_dtmf
(0x1F);fprintf(debug
,"2 = 697, 1209\r\n");//digito 2 //off dtmf// envia_dtmf(3);envia_dtmf(0x1F);fprintf(debug,"3 = 697, 1209\r\n");//digito 2 //off dtmf
//! envia_dtmf(4);envia_dtmf(31);fprintf(debug,"4 = 697, 1209\r\n");//digito 2 //off dtmf
//! envia_dtmf(5);envia_dtmf(31);fprintf(debug,"5 = 697, 1209\r\n");//digito 2 //off dtmf
//! envia_dtmf(6);envia_dtmf(31);fprintf(debug,"6 = 697, 1209\r\n");//digito 2 //off dtmf
//! envia_dtmf(7);envia_dtmf(31);fprintf(debug,"7 = 697, 1209\r\n");//digito 2 //off dtmf
//! envia_dtmf(8);envia_dtmf(31);fprintf(debug,"8 = 697, 1209\r\n");//digito 2 //off dtmf
//! envia_dtmf(9);envia_dtmf(31);fprintf(debug,"9 = 697, 1209\r\n");//digito 2 //off dtmf
}
}
void Init_HT9200(){
output_high(CE_PIN); // start with chip disabled (else you go nuts)
output_high(CLOCK_PIN); // start with clock pin high
output_low(CE_PIN); // now enable the chip
delay_ms(10); // delay 10ms to ramp up the ocillator
//envia_dtmf(0x1F);
//DTMF_Out (DTMF_OFF); // turn off any tone from previous run
}
void envia_dtmf(numero){
int i;
if (numero == 0) numero = 10; // take care of 0 here
for(i=0;i<=5;++i) {
output_high(CLOCK_PIN); // clock high while setting data
// if(bit_test(numero,i)){ output_high(DATA_PIN); }
// else { output_low(DATA_PIN);}
output_bit(DATA_PIN,shift_left(&numero,1,0)); // set data LSB->MSB
delay_us(5); // 1/2 of 100K Clock speed
output_low(CLOCK_PIN); // clock low to latch data
delay_us(5); // 1/2 of 100K Clock speed
}
delay_ms(200); // duración
}