Skip to content

Instantly share code, notes, and snippets.

@jitomesky
Created October 15, 2013 09:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jitomesky/6989014 to your computer and use it in GitHub Desktop.
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コンパイラを利用しました。
#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