Skip to content

Instantly share code, notes, and snippets.

@tai
Created September 30, 2018 07:04
Show Gist options
  • Select an option

  • Save tai/e755527afafb3f2ff9a0b608d85b6cb2 to your computer and use it in GitHub Desktop.

Select an option

Save tai/e755527afafb3f2ff9a0b608d85b6cb2 to your computer and use it in GitHub Desktop.
//
// blink test for PIC18K14K50
//
#define _XTAL_FREQ 16000000 /* depends on FOSC and OSCCON */
#include <xc.h>
// configure clock
#pragma config CPUDIV=NOCLKDIV, USBDIV=OFF
#pragma config FOSC=IRC, PLLEN=OFF
// enable reset
#pragma config MCLRE=ON
// no code/data protection
#pragma config CP0=OFF, CP1=OFF, CPB=OFF, CPD=OFF
int
main(void) {
// set clock
OSCCON = 0x7C; // IDLEN=0, ICF=111, OSTS=1, HFIOFS=1, SCS=00
TRISBbits.RB6 = 0; // RB6 as output
for (;;) {
PORTBbits.RB6 = 0; // LED ON
__delay_ms(1000); // 1 Second Delay
PORTBbits.RB6 = 1; // LED OFF
__delay_ms(1000); // 1 Second Delay
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment