Created
May 16, 2020 13:47
-
-
Save dev001hajipro/f8cb6dee20157f1be5bbd02b07d81ff7 to your computer and use it in GitHub Desktop.
MCLREをONにしているので、リセット回路を追加する必要がある。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define _XTAL_FREQ 4000000L | |
// PIC16F628A Configuration Bit Settings | |
// 'C' source line config statements | |
// CONFIG | |
#pragma config FOSC = INTOSCIO // Oscillator Selection bits (INTOSC oscillator: I/O function on RA6/OSC2/CLKOUT pin, I/O function on RA7/OSC1/CLKIN) | |
#pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled) | |
#pragma config PWRTE = ON // Power-up Timer Enable bit (PWRT enabled) | |
#pragma config MCLRE = ON // RA5/MCLR/VPP Pin Function Select bit (RA5/MCLR/VPP pin function is digital input, MCLR internally tied to VDD) | |
#pragma config BOREN = ON // Brown-out Detect Enable bit (BOD enabled) | |
#pragma config LVP = OFF // Low-Voltage Programming Enable bit (RB4/PGM pin has digital I/O function, HV on MCLR must be used for programming) | |
#pragma config CPD = OFF // Data EE Memory Code Protection bit (Data memory code protection off) | |
#pragma config CP = OFF // Flash Program Memory Code Protection bit (Code protection off) | |
// #pragma config statements should precede project file includes. | |
// Use project enums instead of #define for ON and OFF. | |
#include <xc.h> | |
void main(void) { | |
PCON = 0b00001000; // 4MHz | |
OPTION_REG = 0b00000000; // PORTB Pull-up Enable(bit7) | |
CMCON = 0b00000111; // CM<2:0> = 111. Comparators Off | |
VRCON = 0b00000000; | |
TRISA = 0b00010000; // RA<4:0> as outputs, TRISA<5> always reas as '1' | |
TRISB = 0b00000000; | |
PORTA = 0x00; | |
PORTB = 0x00; | |
while(1) { | |
RB0 = 1; | |
__delay_ms(500); | |
RB0 = 0; | |
__delay_ms(500); | |
} | |
return; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment