Created
April 16, 2020 16:35
-
-
Save houmei/9039abb116260d3e83af0bc5a8bcb266 to your computer and use it in GitHub Desktop.
PIC12F1822 2MHz OSC / based on mc6800crgen 6800伝説
This file contains 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
:040000000128FE2FA6 | |
:100FA000F0302100990023008C01210095130B30B3 | |
:100FB0008C0022009D148C3025009300033020000B | |
:100FC0009B00023025009100940120009C011C151B | |
:100FD00022008C120930F1001E30F000E430890B41 | |
:100FE000EF2FF00BEF2FF10BEF2F003222008C16BA | |
:100FF00020000C18F62F22008C12F82F2000D02F82 | |
:020000040001F9 | |
:04000E00E4FFFFFF0D | |
:00000001FF |
This file contains 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
#include <xc.h> | |
#pragma config FOSC = INTOSC | |
#pragma config WDTE = OFF | |
#pragma config MCLRE = ON | |
#pragma config CLKOUTEN = OFF | |
#pragma config PLLEN = ON | |
#define _XTAL_FREQ 32000000 | |
void main(void) { | |
// initialize | |
OSCCON = 0b11110000; // 4xPLL,8 or 32MHz HF,FOSC<2:0> | |
ANSELA = 0; // PORTA RA4/RA2/RA1/RA0=digital | |
nWPUEN = 0; // weak PULLUP | |
TRISA = 0b00001011; // RA3/RA1/RA0=input,RA4/RA2=output | |
P1BSEL = 1; // RA4=P1B function | |
// clock generate | |
CCP1CON = 0b10001100; // Halfbridge output,PWM mode P1A/C/B/D active H | |
PR2 = 3; // Period=(3+1) * (4*Tosc*TMR1 Prescale Val) ... 4/32 | |
CCPR1L = 2; // PulseWidth=Tosc*CCPR1L<7:0>*CCP1CON<5:4>*TMR1 Prescale val | |
PWM1CON = 0; // P1RSEN=0,P1DC1=1 (4*Tosc*1) | |
T2CON = 0; // 1:1 PostScalar,Prescalar=1 | |
TMR2ON = 1; // Timer2 ON | |
// reset | |
LATA5 = 0; | |
__delay_ms(200); | |
LATA5 = 1; | |
// manual reset | |
while(1) | |
LATA5 = RA0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment