Esempio n. 1
0
interrupt(TIMER0_A1_VECTOR) ta1_isr(void)
{
    // Limpa flag de interrupcao 
    TACCTL1 &= ~CCIFG;
    periodos+=1;
    dado = lerConversorAD(); 

    if ((subindo == 0) && (dado > 500) && (periodos > 80) ){
        subindo = 1; // subiu a tensão inicio do batimento
        P1OUT &= ~BIT0; // apaga led vermelho    
        gotoXy(0,1);
        prints("S2"); // imprime o coração
        integerToLcd(calcula_freq()); //imprime os batimetnos 
        periodos = 0;
    }else {
        if ((subindo == 1) && ( dado < 300) && (periodos>80)){
            subindo = 0; // desceu a tensão final do batimento
            gotoXy(0,1);
            prints("   "); // apaga o coracao
        }
    }
    
    if (periodos >1200){
        P1OUT &= ~BIT0; // apaga led vermelho    
        gotoXy(2,1); 
        integerToLcd(0);
    }    
}
Esempio n. 2
0
__interrupt void pushbutton_ISR (void)
{
	switch(__even_in_range( P2IV, 10 ))
	{
	case 0x00: break; 					// None
	case P2IV_P2IFG0: 					// Pin 2.0 => 0x02
		P8OUT ^= BIT1; 					// P8.1 = toggle
//		gotoXy(0,1);
//		if ((BIT1&P8IN)==BIT1)			// read P8.1 Output
//			prints("LED 8.1 is ON ");
//		else
//			prints("LED 8.1 is OFF");
		break;
	case 0x04: break; 					// Pin 2.1
	case P2IV_P2IFG2: 					// Pin 2.2 => 0x06
		P8OUT ^= BIT2; 					// P8.1 = toggle
		gotoXy(0,1);
		if ((BIT2&P8IN)==BIT2)			// read P8.2 Output
			prints("LED 8.2 is ON ");
		else
			prints("LED 8.2 is OFF");
		P2IFG &= ~BIT0 & ~BIT2; 		// P2.0 and P2.2 IFG cleared
		P2IES ^= BIT2;					// P2.2 lo/Hi edge
		break;
	case 0x08: break; 					// Pin 2.3
	case 0x0A: break; 					// Pin 2.4
	case 0x0C: break; 					// Pin 2.5
	case 0x0E: break; 					// Pin 2.6
	case 0x10: break; 					// Pin 2.7
	default: break;
	}

    //disable all interrupts
//    P2IE &= ~(BIT0 + BIT2);
//
//	if((P2IFG & BIT0)==BIT0)
//	{
//	    //button P2.0 has been pressed
//		P8OUT ^= BIT1; 					// P8.1 = toggle
//		gotoXy(0,1);
//		if ((BIT1&P8IN)==BIT1)			// read P8.1 Output
//			prints("LED 8.1 is ON ");
//		else
//			prints("LED 8.1 is OFF");
//	}
//	else if((P2IFG & BIT2)==BIT2)
//	{
//	    //button P2.2 has been pressed
//		P8OUT ^= BIT2; 					// P8.2 = toggle
//		gotoXy(0,1);
//		if ((BIT2&P8IN)==BIT2)			// read P8.2 Output
//			prints("LED 8.2 is ON ");
//		else
//			prints("LED 8.2 is OFF");
//	}
//	P2IFG &= ~BIT0 & ~BIT2; 	// P2.0 and P2.2 IFG cleared
}
Esempio n. 3
0
void printFrecu(unsigned int megas, unsigned int kilos)
{
    //IMPORTANTE!!! PENDIENTE ->Tener en cuenta de imprimir 0xx en ascii cuando FrecKHz sea 0, 025,050 y 075
  char sMegas[3];
  char sKilos[3];
  
  integerToAscii(megas,sMegas);
  integerToAscii(kilos,sKilos);
    
 /*Armado de Visualizacion en LCD
  Fr. 1xx,xxx MHz --> prints("Fr. 116.525 MHz ");
  */ 
  gotoXy(0,0);      
  prints("Fr. ");
  gotoXy(4,0);
  prints(sMegas);
  gotoXy(7,0);
  prints(".");
  gotoXy(0,1);
  prints(sKilos);
  gotoXy(3,1);
  prints(" MHz ");
}
Esempio n. 4
0
int main(void) 
{
    WDTCTL = WDTPW  + WDTHOLD; // Para o WDT(Wath dog Timer)

    // calibrando o clock para trabalhar em 16MHz
    BCSCTL1 = CALBC1_16MHZ;  
    DCOCTL = CALDCO_16MHZ;

    // configurando conversor AD para trabalhar com tensao no pino 4
    ADC10CTL0 &= ~ENC;
    ADC10CTL1 = 4 << 12;
    ADC10CTL0 = SREF_0 + ADC10ON + ENC + ADC10SHT_0;
 
    // configurando LED
    P1DIR |= BIT6;  // EN saida
    P1DIR |= BIT0;  // LED Vermelho
    P1DIR |= BIT7;  // RS saida 
    P2DIR = 0xFF; 
    P1OUT = 0x00;
    lcdinit();
    prints("Batimentos ");
    gotoXy(7,1);
    prints("BPM");
    
    // Configurando interrupcao
    TACCR0 = 32000;  //   16 MHz / 32000 = 500 Hz

    // Usar clock TASSEL_2, no modo UP (MC_1).
    TACTL = TASSEL_2 | MC_1;
  
    // Reseta o timer no fim de contagem(OUTMOD_7) e habilita interrupcao (CCIE)
    TACCTL1 = OUTMOD_7 | CCIE;
   
   // LPM0 (Lower power mode) bota a cpu para dormir com interrupcao habilitada.
    __bis_SR_register(CPUOFF | GIE);

    return 0;
}