Skip to content

Instantly share code, notes, and snippets.

@xiupos
Last active April 8, 2018 11:02
Show Gist options
  • Save xiupos/76f57229bf9200c05c2cab816442247f to your computer and use it in GitHub Desktop.
Save xiupos/76f57229bf9200c05c2cab816442247f to your computer and use it in GitHub Desktop.
PIC18F14K50 Blink(1)
// とりあえずLチカ
// ha2zakura
#include <xc.h> // PIC のハードウエア定義
#define _XTAL_FREQ 48000000
#pragma config FOSC = HS, PLLEN = ON, FCMEN = OFF
#pragma config IESO = OFF, USBDIV = OFF, CPUDIV = NOCLKDIV
#pragma config PWRTEN = OFF, BOREN = OFF, WDTEN = OFF
#pragma config HFOFST = OFF, MCLRE = ON
#pragma config STVREN = ON, BBSIZ = OFF, LVP = OFF
#pragma config XINST = OFF
#pragma config CP0 = OFF, CP1 = OFF, CPB = OFF
#pragma config WRT0 = OFF, WRT1 = OFF, WRTB = OFF, WRTC = OFF
#pragma config EBTR0 = OFF, EBTR1 = OFF, EBTRB = OFF
void delay(int num)
{
while(--num > 0) __delay_us(1000);
}
void main(void){
OSCCON = 0b00000000; // 外部クロックx4
OSCCON2 |= (1 << 2); // PRI_SD = 1
LATB = 0; // PortBのすべてのビットを0に
TRISB = 0b00000000; // LEDの接続されているポートを出力に設定
while(1){
LATB |= (1 << 7);
delay(1000);
LATB &= ~(1 << 7);
delay(1000);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment