void main(void){ ADCON1 = 0x0f; LED_dir = 0; LED = 0; TMR0H = 0x3C; TMR0L = 0xB0; TIMER_CON = 0b10000011; TIMER0_CON = 0b10000001; INTCONbits.GIE = 1; INTCONbits.TMR0IF = 0; INTCONbits.TMR0IE = 1; VENTILADOR_dir = 0; VENTILADOR = 1; configLCD(); while(1){ } }
int main (void) { // Inicializamos la placa initBoard(); // Inicializamos el LCD configLCD(&databusLCD, &enPinLCD, &rwPinLCD, &rsPinLCD); // Escribimos texto en el LCD printLCD("Wake up Neo"); // Bucle infinito while(1) { // Parpadeamos el led togglePin(&LED[0]); delay_ms(500); } return 0; }
int main(int argc, char** argv) { char tempStr[14]; LCDcursor cursor; /* ----- Device Initial Config ----- */ pic16f1825_init(); /* ------ LCD Initial Config ------- */ initLCD(); configLCD(); /* ---------- RAM Testing ---------- */ uint16_t RAMtest = memtest_MARCH_Cmin(); LATC1 = 1; clearLCD(&cursor); sprintf(tempStr, "Memory Tests:"); printlnLCD(tempStr, strlen(tempStr), 2, &cursor); /* Returns 0x3000 if no Errors, otherwise returns the address of the first error */ gotoXY(0, cursor.yPos+1); cursor.yPos += 1; if(0x3000 == RAMtest){ sprintf(tempStr, "RAM Test OK!"); printlnLCD(tempStr, strlen(tempStr), 2, &cursor); }else { sprintf(tempStr, "!RAM @ 0x%04X", RAMtest); printlnLCD(tempStr, strlen(tempStr), 2, &cursor); } /* ---------- ROM Testing ---------- */ uint8_t ROMtest = memtest_program_mem(); if(ROMtest){ sprintf(tempStr, "ROM Test OK!"); printlnLCD(tempStr, strlen(tempStr), 2, &cursor); }else { sprintf(tempStr, "ROM Error!"); printlnLCD(tempStr, strlen(tempStr), 2, &cursor); } /* -------- EEPROM Testing -------- */ if(memtest_eeprom(NULL)){ sprintf(tempStr, "EEPROM Test OK!"); printlnLCD(tempStr, strlen(tempStr), 2, &cursor); }else { sprintf(tempStr, "EEPROM Error!"); printlnLCD(tempStr, strlen(tempStr), 2, &cursor); } uint8_t turn_on_times = read_eeprom(0); if(0xFF == turn_on_times) /* By default the EEPROM data in a given address is 0xFF */ turn_on_times = 1; /* This is the first time the circuit is powered up */ else turn_on_times++; write_eeprom(0,turn_on_times); write_eeprom(255,turn_on_times ); /* update the checksum (last address of EEPROM) */ sprintf(tempStr, "The circuit was powered %d times",turn_on_times); printlnLCD(tempStr, strlen(tempStr), 2, &cursor); __delay_ms(3000); printImageLCD(IMG); __delay_ms(3000); set_precision_ds18b20(PRECISION_12); while(1){ start_temp_measure_ds18b20(); __delay_ms(1000); /* Wait for temperature measurement */ sprintf(tempStr, "Temp: %.2f", read_temp_ds18b20()); gotoXY(0,2); cursor.yPos = 2; printlnLCD(tempStr, strlen(tempStr), 2, &cursor); } return (EXIT_SUCCESS); }