/*! SPI Master Mode initialization for interrupt based transactions * * @param scale * @param spifreq */ void spi_init_master_intr(pclk_scale scale, spi_freq spifreq, spi_ctl* ctl ) { Freq cclk; uint32_t spi_pclk = 0; uint32_t ccount; FIO_ENABLE; mam_enable(); //FIO_SCK_0; SCK_HIGH; PINSEL_SPI_SCK ; PINMODE_SPI_SCK_PULLUP; PINSEL_SPI_MISO ; PINMODE_SPI_MISO_PULLUP ; PINSEL_SPI_MOSI ; PINMODE_SPI_MOSI_NOPULL ; // SSEL for master mode. PINSEL_SPI_MASTERM_SSEL_0 ; PINMODE_SPI_SSEL_PULLUP ; FIO_SPI_SSEL; SSEL_HIGH; SCK_HIGH; MOSI_HIGH; POWER_ON(PCSPI); init_binsem( &spi_binsem_g ); spi_init_xact_status( &spi_status_g ); SET_PCLK(PCLK_SPI, CCLK_DIV1); // cclk value cclk = pllquery_cclk_mhz(); switch(scale) { case CCLK_DIV1: spi_pclk = cclk; break; case CCLK_DIV2: spi_pclk = cclk/2; break; case CCLK_DIV4: spi_pclk = cclk/4; break; case CCLK_DIV8: spi_pclk = cclk/8; break; default: #ifdef DEBUG_SPI printf_lpc(UART0,"Bad choice for scale value.\n"); #endif break; } // SPI control register setup // no second device pin initialized. // PINSEL_SPI_MASTERM_SSEL_1 // P1.0 // PINMODE_SPI_MASTERM_SSEL_1_NOPULL // // FIO_SPI_SSEL_1; // SSEL_1_HIGH; //S0SPCR = 0; S0SPCR = ((0x0 << SPI_CR_BITENABLE) | (ctl->spi_cpha_val << SPI_CR_CPHA) | (ctl->spi_cpol_val << SPI_CR_CPOL) | (0x1 << SPI_CR_MSTR) | (ctl->spi_lsbf_val << SPI_CR_LSBF) | (0x1 << SPI_CR_SPIE)); // master mode, MSB first, 16 bits per transfer // S0SPCR = (0x1 << SPI_CR_MSTR) ; ccount = spi_pclk/spifreq; #ifdef DEBUG_SPI if(ccount > 255) { printf_lpc(UART0, "ccount is out of range for requested spi clock frequency %u\n", spifreq); } #endif if(ccount % 2) ccount -= 1; // must be even number if(ccount < 8) ccount = 8; // min value for ccr (p 463, user manual.) if(ccount > 254) ccount = 254; // max value for ccr S0SPCCR = (uint8_t) ccount; #ifdef DEBUG_SPI volatile uint8_t spi_status; spi_status = spi_readstatus(); printf_lpc(UART0, "spi_status is %u\n", spi_status); printf_lpc(UART0, "spi_pclk is %u\n", spi_pclk); printf_lpc(UART0, "spifreq is %u\n", spifreq); printf_lpc(UART0, "S0SPCCR is %u for %u HZ\n", S0SPCCR, (spi_pclk/S0SPCCR)); printf_lpc(UART0, "S0SPCCR is %u for %u HZ\n", S0SPCCR, (spi_pclk/S0SPCCR)); #endif VICVectPriority10 = 0x1; VICVectAddr10 = (unsigned int) spi_isr; VICAddress = 0x0; DISABLE_SPI_INT; }
/*! \brief SPI Master transaction for 16 bits. * * spi_init_master_MSB_16 * * scale: factor to divide cclk for spi peripheral * spifreq: frequency to run SCLK. * example: spi_init(CCLK_DIV8, SPI_100KHZ) ; * * master mode, MSB first, 16 bits per transfer * * PULLUP Configuration Default * MISO - PULLUP * MOSI - PULLUP * SCK - PULLUP * SSEL - NONE * * Default Setting for SSEL is HIGH */ void spi_init_master_MSB_16(pclk_scale scale, spi_freq spifreq) { Freq cclk; uint32_t spi_pclk = 0; uint32_t ccount; FIO_ENABLE; mam_enable(); POWER_ON(PCSPI); init_binsem( &spi_binsem_g ); SET_PCLK(PCLK_SPI, scale); // cclk value cclk = pllquery_cclk_mhz(); switch(scale) { case CCLK_DIV1: spi_pclk = cclk; break; case CCLK_DIV2: spi_pclk = cclk/2; break; case CCLK_DIV4: spi_pclk = cclk/4; break; case CCLK_DIV8: spi_pclk = cclk/8; break; default: #ifdef DEBUG_SPI printf_lpc(UART0,"Bad choice for scale value.\n"); #endif break; } PINSEL_SPI_SCK ; PINMODE_SPI_SCK_NOPULL; PINSEL_SPI_MISO ; PINMODE_SPI_MISO_PULLUP ; PINSEL_SPI_MOSI ; PINMODE_SPI_MOSI_NOPULL ; // SSEL for master mode. PINSEL_SPI_MASTERM_SSEL_0 ; PINMODE_SPI_SSEL_PULLUP ; FIO_SPI_SSEL; SSEL_HIGH; SCK_HIGH; MOSI_HIGH; // no second device pin initialized. // PINSEL_SPI_MASTERM_SSEL_1 // P1.0 // PINMODE_SPI_MASTERM_SSEL_1_NOPULL // // FIO_SPI_SSEL_1; // SSEL_1_HIGH; // master mode, MSB first, 16 bits per transfer S0SPCR = (0x1 << SPI_CR_BITENABLE) | (0x1 << SPI_CR_MSTR) | (SPI_16BITS << SPI_CR_BITS); ccount = spi_pclk/spifreq; #ifdef DEBUG_SPI if(ccount > 255) { printf_lpc(UART0, "ccount is out of range for requested spi clock frequency %u\n", spifreq); } #endif if(ccount % 2) ccount -= 1; // must be even number if(ccount < 8) ccount = 8; // min value for ccr (p 463, user manual.) if(ccount > 254) ccount = 254; // max value for ccr S0SPCCR = (uint8_t) ccount; #ifdef DEBUG_SPI volatile uint8_t spi_status; spi_status = spi_readstatus(); printf_lpc(UART0, "spi_status is %u\n", spi_status); printf_lpc(UART0, "spi_pclk is %u\n", spi_pclk); printf_lpc(UART0, "spifreq is %u\n", spifreq); printf_lpc(UART0, "S0SPCCR is %u for %u HZ\n", S0SPCCR, (spi_pclk/S0SPCCR)); printf_lpc(UART0, "S0SPCCR is %u for %u HZ\n", S0SPCCR, (spi_pclk/S0SPCCR)); #endif }
int main(void) { POWER_ON(); // Turn the regulator ON PWRMODE_SETUP(); // Setup PWRMODE jumper input lcd_init(); // init LCD uint8_t tmp; ADCSRA = (1<<ADEN) | (1<<ADPS1) | (1<<ADPS0); // Enable ADC, set Prescale to 8 unsigned int rhval = eeprom_read_word(&R_H_VAL); // R_H unsigned int rlval = eeprom_read_word(&R_L_VAL); // R_L ctmode = eeprom_read_byte(&CapTestMode); // Compile time choice of test modes (0x22) cp1 = (ctmode & 12) >> 2; // Capacitor pin 1, DEFAULT 0 cp2 = ctmode & 3; // Capacitor pin 2, DEFAULT 2 ctmode = (ctmode & 48) >> 4; // Capacitor test mode, DEFAULT is 0x02 for all 6 cap tests. wdt_disable(); // Disable watch dog timer. if(MCU_STATUS_REG & (1<<WDRF)) { // Examine for Watchdog RESETs That enters, if the Watchdog 2s were not put back Can occur, lcd_clear(); // if the program in a continuous loop " itself; tangled" has. lcd_eep_string(TestTimedOut); // Message - "Timeout!" _delay_ms(3000); // Wait 3 sec wdt_enable(WDTO_2S); // Wait two seconds; if on power it will reset; on battery it will turn itself off while(1) { POWER_OFF(); // Power down in BAT mode or RESET in PWR mode } } LCDLoadCustomChar(); // Custom indication Diode symbol into LCD load lcd_eep_string(DiodeIcon); // Message - diode icon Line1(); // jump to start of first line start: // re-entry point, if button is re-pressed #ifdef WDT_enabled wdt_enable(WDTO_2S); // Watchdog Timer on, 2 seconds? #endif PartFound = PART_NONE; // Default all results tmpPartFound = PART_NONE; // " " NumOfDiodes = 0; // || PartReady = 0; // || PartMode = 0; // || ca = 0; // || cb = 0; // \/ // -> // Startup Message //////////////////////////////////////// lcd_clear(); // lcd_eep_string(StartupMessage); // LCD: ACT v#.# [XXX] // -> // Power selection and Battery Testing //////////////////// if(PWRMODE_GET()) { // Get the PWRMODE jumper logic PowerMode = PWR_9V; // Set powermode to PWR_9V _delay_us(250); ReadADC(5 | (1<<REFS1)); // Measure the 9V battery Supply ( - diode drop) hfe[0] = ReadADC(5 | (1<<REFS1)); // if in battery mode. lcd_eep_string(BatMode); // Tell user device in BAT mode Line2(); if (hfe[0] < BAT_WEAK) { // Compare 9v reading with BAT_WEAK variable if(hfe[0] < BAT_DEAD) { // If the batter is considered dead then lcd_eep_string(Bat); lcd_eep_string(BatEmpty); // Tell the user battery is DEAD _delay_ms(3000); // Wait a bit. while(1) { // Forever loop POWER_OFF(); // keep trying to kill the power forever. } } lcd_clear(); lcd_eep_string(Bat); // Battery isnt dead; its just weak lcd_eep_string(BatWeak); // tell the user; but keep testing... Line2(); // Start second line } } else { PowerMode = PWR_5V; // Power mode is constent v5, skip battery check. lcd_eep_string(PwrMode); // Tell user we are running in PWR mode. Line2(); } // -> // Begin testing sequince. /////////////////////////////// lcd_eep_string(TestRunning); // Tell user the testing has begun... UpdateProgress("00%"); // Progress at 00% and Testing CheckPins(TP1, TP2, TP3); // || UpdateProgress("16%"); // \/ CheckPins(TP1, TP3, TP2); // TESTING... UpdateProgress("33%"); // CheckPins(TP2, TP1, TP3); // || UpdateProgress("50%"); // \/ CheckPins(TP2, TP3, TP1); // TESTING... UpdateProgress("66%"); // CheckPins(TP3, TP2, TP1); // || UpdateProgress("83%"); // \/ CheckPins(TP3, TP1, TP2); // Almost there! UpdateProgress("99%"); // Testing Completed or 99% //---------------------------------------------CAPACITOR--------------------------------------- // Separate measurement to the test on condenser if(((PartFound == PART_NONE) || (PartFound == PART_RESISTOR) || (PartFound == PART_DIODE)) && (ctmode > 0)) { // Condenser unload; otherwise possibly no measurement is possible R_PORT = 0; R_DDR = (1<<(TP1 * 2)) | (1<<(TP2 * 2)) | (1<<(TP3 * 2)); _delay_ms(10); R_DDR = 0; if(ctmode == NORMAL_CAP_TESTS) { // see if we want to do all 6 Cap Tests ReadCapacity(cp1, cp2); // No - just read the pins both ways. ReadCapacity(cp2, cp1); } else { // DEFAULT ctmode == 0x02 to do all tests Line2(); lcd_eep_string(TestCapV); UpdateProgress("00%"); ReadCapacity(TP3, TP1); UpdateProgress("16%"); ReadCapacity(TP3, TP2); UpdateProgress("33%"); ReadCapacity(TP2, TP3); UpdateProgress("50%"); ReadCapacity(TP2, TP1); UpdateProgress("66%"); ReadCapacity(TP1, TP3); UpdateProgress("83%"); ReadCapacity(TP1, TP2); UpdateProgress("99%"); } } lcd_clear(); // Finished, now evaluate, the results //---------------------------------------------DIODE------------------------------------------------ if(PartFound == PART_DIODE) { if(NumOfDiodes == 1) { // Standard-Diode lcd_eep_string(Diode); // Message - "Diode: " lcd_eep_string(Anode); // Message - "A=" lcd_data(GetPinAlias(diodes[0].Anode + ASCII_1)); // Display 1, 2, or 3 lcd_eep_string(NextK); // Message - ";C=" lcd_data(GetPinAlias(diodes[0].Cathode + ASCII_1)); // Display 1, 2, or 3 Line2(); // Start second line lcd_eep_string(Uf); // Message - "Uf=" lcd_string(itoa(diodes[0].Voltage, outval, 10)); lcd_eep_string(mV); // Message - "mV" goto end; } else if(NumOfDiodes == 2) { // dual diode if(diodes[0].Anode == diodes[1].Anode) { // Common Anode lcd_eep_string(DualDiode); // Message - "Double diode €" lcd_eep_string(CA); // Message - "CA" Line2(); // Start second line lcd_eep_string(Anode); // Message - "A=" lcd_data(GetPinAlias(diodes[0].Anode + ASCII_1)); // Display 1, 2, or 3 lcd_eep_string(K1); // Message - ";C1=" lcd_data(GetPinAlias(diodes[0].Cathode + ASCII_1)); // Display 1, 2, or 3 lcd_eep_string(K2); // Message - ";C2=" lcd_data(GetPinAlias(diodes[1].Cathode + ASCII_1)); // Display 1, 2, or 3 goto end; } else if(diodes[0].Cathode == diodes[1].Cathode) { // Common Cathode lcd_eep_string(DualDiode); // Message - "Double diode €" lcd_eep_string(CC); // Message - "CC" Line2(); // Start second line lcd_eep_string(K); // Message - "C=" lcd_data(GetPinAlias(diodes[0].Cathode + ASCII_1)); // Display 1, 2, or 3 lcd_eep_string(A1); // Message - ";A1=" lcd_data(GetPinAlias(diodes[0].Anode + ASCII_1)); // Display 1, 2, or 3 lcd_eep_string(A2); // Message - ";A2=" lcd_data(GetPinAlias(diodes[1].Anode + ASCII_1)); // Display 1, 2, or 3 goto end; } else if ((diodes[0].Cathode == diodes[1].Anode) && \ (diodes[1].Cathode == diodes[0].Anode)) { // Antiparallel lcd_eep_string(TwoDiodes); // Message - "2 diodes" Line2(); // Start second line lcd_eep_string(Antiparallel); // Message - "anti-parallel" goto end; } } else if(NumOfDiodes == 3) { // Series connection from 2 diodes; as 3 diodes one recognizes b = 3; c = 3; // Check to see if it is series connection of 2 diodes. // But 2 cathodes, and 2 anodes must agree. // Then the 2 diodes are a single dual-diode. if((diodes[0].Anode == diodes[1].Anode) || (diodes[0].Anode == diodes[2].Anode)) b = diodes[0].Anode; if(diodes[1].Anode == diodes[2].Anode) b = diodes[1].Anode; if((diodes[0].Cathode == diodes[1].Cathode) || (diodes[0].Cathode == diodes[2].Cathode)) c = diodes[0].Cathode; if(diodes[1].Cathode == diodes[2].Cathode) c = diodes[1].Cathode; if((b<3) && (c<3)) { lcd_eep_string(TwoDiodes); // Message - "2 diodes" Line2(); // Start second line lcd_eep_string(InSeries); // Message - "serial A=€€" lcd_data(GetPinAlias(b + ASCII_1)); // Display 1, 2, or 3 lcd_eep_string(NextK); // Message - ";C=" lcd_data(GetPinAlias(c + ASCII_1)); // Display 1, 2, or 3 goto end; } } } //---------------------------------------------TRANSISTOR-------------------------------------------- else if (PartFound == PART_TRANSISTOR) { if(PartReady == 0) { // 2nd examination never made, e.g. a transistor with protection diode. hfe[1] = hfe[0]; uBE[1] = uBE[0]; } if((hfe[0]>hfe[1])) { // If the amplification factor with the first test was higher: swap C and E hfe[1] = hfe[0]; uBE[1] = uBE[0]; tmp = c; c = e; e = tmp; } if(PartMode == PART_MODE_NPN) lcd_eep_string(NPN); // Message - "NPN" else lcd_eep_string(PNP); // Message - "PNP" lcd_eep_string(bstr); // Message - " B=" lcd_data(GetPinAlias(b + ASCII_1)); // Display 1, 2, or 3 lcd_eep_string(cstr); // Message - ";C=" lcd_data(GetPinAlias(c + ASCII_1)); // Display 1, 2, or 3 lcd_eep_string(estr); // Message - ";E=" lcd_data(GetPinAlias(e + ASCII_1)); // Display 1, 2, or 3 Line2(); // Start second line // Amplification factor compute, hFE = Emitter current/base current lhfe = hfe[1]; lhfe *= (((unsigned long)rhval * 100) / (unsigned long)rlval); // 500000/750 = 666.666r if(uBE[1]<11) uBE[1] = 11; lhfe /= uBE[1]; hfe[1] = (unsigned int) lhfe; lcd_eep_string(hfestr); // Message - "hFE=" lcd_string(utoa(hfe[1], outval, 10)); SetCursor(2,7); // Cursor on line 2, character 7 if(NumOfDiodes > 2) // Transistor with protection diode lcd_data(LCD_CHAR_DIODE); // Diode indicate else lcd_data(' '); for(c=0;c<NumOfDiodes;c++) { if(( (diodes[c].Cathode == e) && (diodes[c].Anode == b) && \ (PartMode == PART_MODE_NPN)) || ((diodes[c].Anode == e) && \ (diodes[c].Cathode == b) && (PartMode == PART_MODE_PNP))) { lcd_eep_string(Uf); // Message - "Uf=" lcd_string(itoa(diodes[c].Voltage, outval, 10)); lcd_data('m'); goto end; } } goto end; } //---------------------------------------------FET--------------------------------------------------- else if (PartFound == PART_FET) { // JFET or MOSFET if(PartMode & 1) // N-channel lcd_data('N'); else lcd_data('P'); // P-channel if((PartMode == PART_MODE_N_D_MOS) || (PartMode == PART_MODE_P_D_MOS)) { lcd_eep_string(dmode); // Message - "-D" lcd_eep_string(mosfet); // Message - "-MOS" } else { if((PartMode == PART_MODE_N_JFET) || (PartMode == PART_MODE_P_JFET)) lcd_eep_string(jfet); // Message - "-JFET" else { lcd_eep_string(emode); // Message - "-E" lcd_eep_string(mosfet); // Message - "-MOS" } } // Gate capacity if(PartMode < 3) { // Enrichment MOSFET lcd_eep_string(GateCap); // Message - " C=" ReadCapacity(b,e); // Measurement hfe[0] = (unsigned int)cv; if(hfe[0]>2) hfe[0] -= 3; utoa(hfe[0], outval2, 10); tmpval = strlen(outval2); tmpval2 = tmpval; if(tmpval>4) tmpval = 4; // If capacity > 100nF drop fractional part to fit on the LCD lcd_show_format_cap(outval2, tmpval, tmpval2); lcd_data('n'); } Line2(); // Start second line lcd_eep_string(gds); // Message - "GDS=" lcd_data(GetPinAlias(b + ASCII_1)); // Display 1, 2, or 3 lcd_data(GetPinAlias(c + ASCII_1)); // Display 1, 2, or 3 lcd_data(GetPinAlias(e + ASCII_1)); // Display 1, 2, or 3 if((NumOfDiodes > 0) && (PartMode < 3)) // MOSFET with protection diode; it gives only with enrichment FETs lcd_data(LCD_CHAR_DIODE); // Diode indicate else lcd_data(' '); // Blank if(PartMode < 3) { // Enrichment MOSFET gthvoltage=(gthvoltage/8); lcd_eep_string(vt); // Message - "Vt=" lcd_string(utoa(gthvoltage, outval, 10)); // Gate threshold voltage, was determined before lcd_data('m'); } goto end; } //---------------------------------------------THYRISTOR--------------------------------------------- else if (PartFound == PART_THYRISTOR) { lcd_eep_string(Thyristor); // Message - "Thyristor" Line2(); // Start second line lcd_eep_string(GAK); // Message - "GAC=" lcd_data(GetPinAlias(b + ASCII_1)); // Display 1, 2, or 3 lcd_data(GetPinAlias(c + ASCII_1)); // Display 1, 2, or 3 lcd_data(GetPinAlias(e + ASCII_1)); // Display 1, 2, or 3 goto end; } //---------------------------------------------TRIAC------------------------------------------------- else if (PartFound == PART_TRIAC) { lcd_eep_string(Triac); // Message - "Triac" Line2(); // Start second line lcd_eep_string(Gate); // Message - "G=" lcd_data(GetPinAlias(b + ASCII_1)); // Display 1, 2, or 3 lcd_eep_string(A1); // Message - ";A1=" lcd_data(GetPinAlias(e + ASCII_1)); // Display 1, 2, or 3 lcd_eep_string(A2); // Message - ";A2=" lcd_data(GetPinAlias(c + ASCII_1)); // Display 1, 2, or 3 goto end; } //---------------------------------------------RESISTOR---------------------------------------------- else if(PartFound == PART_RESISTOR) { lcd_eep_string(Resistor); // Message - "Resistor: €€" lcd_data(GetPinAlias(ra + ASCII_1)); // Display 1, 2, or 3 Pin data lcd_data('-'); lcd_data(GetPinAlias(rb + ASCII_1)); // Display 1, 2, or 3 Line2(); // Start second line if(rv[0] > HALF_ADC_RANGE) // Examine, how far the Voltages across the test resistances deviate from 512 hfe[0] = (rv[0] - HALF_ADC_RANGE); else hfe[0] = (HALF_ADC_RANGE - rv[0]); if(rv[1] > HALF_ADC_RANGE) hfe[1] = (rv[1] - HALF_ADC_RANGE); else hfe[1] = (HALF_ADC_RANGE - rv[1]); if(hfe[0] > hfe[1]) { radcmax[0] = radcmax[1]; rv[0] = rv[1]; // Result use, which is more near because of 512 (accuracy improves) rv[1] = rhval; // High - Test resistance } else rv[1] = rlval; // Low - Test resistance if(rv[0] == 0) rv[0] = 1; lhfe = (unsigned long)((unsigned long)((unsigned long)rv[1] * \ (unsigned long)rv[0]) / (unsigned long)((unsigned long)radcmax[0] - (unsigned long)rv[0])); // Resistance compute ultoa(lhfe,outval,10); if(rv[1] == rhval) { // 470k- Resisted? ra = strlen(outval); // Necessarily, in order to indicate comma for(rb=0;rb<ra;rb++) { lcd_data(outval[rb]); if(rb == (ra-2)) lcd_data(','); // comma } lcd_data ('K'); // Kilo ohm, if 470k uses resistance } else lcd_string(outval); lcd_data(LCD_CHAR_OMEGA); // Omega for ohms goto end; } //---------------------------------------------CAPACITOR--------------------------------------------- else if(PartFound == PART_CAPACITOR) { // Capacitor measurement lcd_eep_string(Capacitor); // Message - "Capacitor: €€" lcd_data(GetPinAlias(ca + ASCII_1)); // Display 1, 2, or 3 Pin - Data lcd_data('-'); lcd_data(GetPinAlias(cb + ASCII_1)); // Display 1, 2, or 3 Line2(); // Start second line tmpval2 = 'n'; // n for nF if(cv > 99999) { // Too big cv /= 1000; // convert to Micro Farads tmpval2 = LCD_CHAR_U; // change n to greek char for micro } ultoa(cv, outval, 10); // outval now a string version of cv tmpval = strlen(outval); lcd_show_format_cap(outval, tmpval, tmpval); lcd_data(tmpval2); // display the SI Suffix lcd_data('F'); // F for Farads goto end; } //---------------------------------------------NOT-FOUND-OR-DAMAGED--------------------------------------------------------- if(NumOfDiodes == 0) { // Nothing found. Tell user. lcd_eep_string(TestFailed1); Line2(); lcd_eep_string(TestFailed2); } else { // Data found but bad result or no positive ident lcd_eep_string(BadResult1); Line2(); lcd_eep_string(BadResult2); lcd_data(NumOfDiodes + ASCII_0); lcd_data(LCD_CHAR_DIODE); } end: while(!(ON_PIN_REG & (1<<RST_PIN))); // wait, to tracers released _delay_ms(200); for(hfe[0] = 0;hfe[0]<10000;hfe[0]++) { // 10 Seconds untill power off. if(!(ON_PIN_REG & (1<<RST_PIN))) // if the button is pressed, start all over goto start; wdt_reset(); // We want to wait the full 10 Seconds _delay_ms(1); // 1mS 10,000 times = 10 seconds } if(PowerMode==PWR_9V) { // If in battery mode; try to turn off; otherwise wait for a reset POWER_OFF(); } wdt_disable(); // Watchdog out // Continuous loop, no timer while(1) { if(!(RESET_GET())) // only one reaches, if the automatic disconnection was not inserted goto start; } return 0; } // End of main()