#include <xc.h>
// PIC16F1719 Configuration Bit Settings
// For more on Configuration Bits, consult y**ice data sheet
// CONFIG1
#pragma config FOSC = ECH // External Clock, 4-20 MHz
#pragma config WDTE = OFF // Watchdog Timer (WDT) disabled
#pragma config PWRTE = OFF // Power-up Timer disabled
#pragma config MCLRE = ON // MCLR/VPP pin function is MCLR
#pragma config CP = OFF // Flash Memory Code Protection off
#pragma config BOREN = ON // Brown-out Reset enabled
#pragma config CLKOUTEN = OFF // Clock Out disabled.
#pragma config IESO = ON // Internal/External Switchover on
#pragma config FCMEN = ON // Fail-Safe Clock Monitor enabled
// CONFIG2
#pragma config WRT = OFF // Flash Memory Self-Write Protect off
#pragma config PPS1WAY = ON // PPS one-way control enabled
#pragma config ZCDDIS = ON // Zero-cross detect disabled
#pragma config PLLEN = OFF // Phase Lock Loop disable
#pragma config STVREN = ON // Stack Over/Underflow Reset enabled
#pragma config BORV = LO // Brown-out Reset low trip point
#pragma config LPBOR = OFF // Low-Power Brown Out Reset disabled
#pragma config LVP = OFF // Low-Voltage Programming disabled
void main(void) {
unsigned char portValue;
// Port D access
ANSELD = 0x0; // set to digital I/O (not analog)
TRISD = 0x0; // set all port bits to be output
// Port B access
ANSELB = 0x0; // set to digital I/O (not analog)
TRISB = 0x0; // set all port bits to be output
while(1) {
portValue = 0x05;
LATD = portValue; // write to port latch - RD[0:3] = LED[0:3]
LATB = portValue; // write to port latch - RB[0:3] = LED[4:7]
// delay value change
_delay(25000); // delay in instruction cycles
portValue = 0x0A;
LATD = portValue; // write to port latch - RD[0:3] = LED[0:3]]
LATB = portValue; // write to port latch - RB[0:3] = LED[4:7]
_delay(25000); // delay in instruction cycles
}
return;
}
|