Created
October 15, 2013 09:27
-
-
Save jitomesky/6989014 to your computer and use it in GitHub Desktop.
PIC12F509でGP2につなげたLEDを点灯するだけのサンプルです。
LEDはカソード側がGP2につながっています。
流れは
#pragma configで初期設定→OPTIONの設定→TRIS(IOモード)の設定→GP2を0にセット
こんなかんじです。 内蔵クロックはOSCCALで変更可能で、初期状態ではmaximumの4MHzとなっています。
コンパイラはXC8コンパイラを利用しました。
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
#pragma config OSC = IntRC, WDT = OFF, MCLRE = OFF, CP = OFF | |
#if defined(__XC) | |
#include <xc.h> /* XC8 General Include File */ | |
#elif defined(HI_TECH_C) | |
#include <htc.h> /* HiTech General Include File */ | |
#endif | |
void main(void) | |
{ | |
OPTION=0xDF; | |
TRIS = 0; | |
while(1) | |
{ | |
GPIObits.GP2 = 0; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment