PIC16f877-WDT-MainFunction

by Marwen Maghrebi
void main() {
    // Set up the watchdog timer prescaler (1:32)
    OPTION_REGbits.PSA = 0;     // Prescaler is assigned to WDT
    OPTION_REGbits.PS = 0b100;  // Prescaler ratio 1:32

    TRISB = 0;                  // All PORTB pins are configured as outputs
    
    while(1) {
        PORTB = 0x0F;           // Set PORTB to 0x0F (00001111 in binary)
        long_delay_with_wdt(1000);  // 1 second delay while clearing WDT
        
        PORTB = 0xF0;           // Set PORTB to 0xF0 (11110000 in binary)
        long_delay_with_wdt(1000);  // 1 second delay while clearing WDT
    }
}
Are you sure want to unlock this post?
Unlock left : 0
Are you sure want to cancel subscription?
-
00:00
00:00
Update Required Flash plugin
-
00:00
00:00