コード例 #1
0
ファイル: main.c プロジェクト: andreydung/AVRClock
int main(void)
{
	PORTB = 1 << 2;		//pull up activated at PB2
	PORTD = 0b00001100;
	GICR = (1<<INT0)|(1<<INT1)|(1<<INT2);	//external interrupt 0, 1 and 2
	MCUCR |= (1 << ISC11)|(1 << ISC01);
	
	setupTimer1();
	setupTimer0();

	sei();
	
	minute = 15;
	hour = 2;
	alarmhour = 0;
	alarmmin = 0;
	increaseHour();
	increaseMinute();
    
	DDRC = 0xFF;
	DDRA = 0xFF;		// Port A for the multiplex
	
	mode = 0;
	index = 0;
	blink = 255;
	while(1) {};
	return 0;
}
コード例 #2
0
void main() {

  TRISA = 0b00000000; // set PORTA -> salidas
  TRISB = 0b01000000; // set PORTB -> salida menos el pin 6.
  ANSEL  = 0;              // Configure AN2 pin as analog
  ANSELH = 0;
  C1ON_bit = 0;                      // Disable comparators
  C2ON_bit = 0;
  INTCON = 0b10100000; // INTERRUPCION POR TIMER0 Y GIE ACTIVADOS.
  /* INTCON.T0IE = 1;                 /\* Activado interrupcion por timer0 *\/ */
  OPTION_REG = 0b10000111; //  TMR0 temporizado:  RBPU, TOCS= INTERNAL INSTRUCTION CLOCK= 0 PSA =0   1:256
  TRISC = 0b10000000;                          // PUERTOC COMO SALIDA exepto pin 7
  PORTC = 0;                          // LIMPIAR PUERTOC
  setupTimer1();
  Delay_us(10);                 /* wait for acquisition time*/
  Lcd_Init();                        // Initialize LCD

  /* Programa principal */
  Lcd_Out(2,0,txtDefault);                 // Write text in second row
  UART1_Init(9600);                         // initialize UART1 module
  Delay_ms(100);                  // Wait for UART module to stabilize
  moverEnAutomatico();
  while (1) {
    waitSignal();
    if (UART1_Data_Ready()) {     // If data is received,
      uart_rd = UART1_Read();     // leer el dato recibido del celular
      waitSignal();
      switch (uart_rd) {
      case 'A': {               /* Modo automático */
        Lcd_Out(2,6,txtAutomatic);
        moverEnAutomatico();
        break;
      }
      case 'M': {
        moverManual();
        break;
      }
      default:
        break;
      }
    }
  }
}