Last active
March 20, 2017 00:24
-
-
Save xiupos/7a538211149290e7b8e7a3d36806203d to your computer and use it in GitHub Desktop.
LPC810についていろいろメモ(2)GPIO出力関連
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
// LPC810についていろいろメモ(2)GPIO出力関連 | |
// ha2zakura | |
// 参考: | |
// http://www.nxp.com/documents/user_manual/UM10601.pdf | |
// http://d.hatena.ne.jp/mikkabo/20150401/1427886535 | |
// 省略部分はメモ(1) | |
// ___ ___ | |
// PIO0_5 [1|O U |8] PIO0_0 | |
// PIO0_4 [2| |7] GND | |
// PIO0_3 [3| |6] 3.3V | |
// PIO0_2 [4|_______|5] PIO0_1 | |
#include "LPC8xx.h" | |
// CMSISライブラリをinclude | |
int main(void) { | |
LPC_SYSCON->SYSAHBCLKCTRL |= (1<<7); | |
// clock有効化の設定...? | |
// 省略 | |
LPC_SWM->PINENABLE0 = 0xffffffbfUL; | |
// 有効化するピンの設定...? | |
// 省略 | |
LPC_GPIO_PORT->DIR0 |= (1<<2); | |
// GPIOの設定 | |
// 省略 | |
volatile int i; | |
//ループ用変数 | |
while(1){ | |
LPC_GPIO_PORT->SET0 |= (1<<2); | |
// GPIO出力をHIGH | |
// UM10601 7.6.7 Table 88. | |
// 1:HIGH | |
// 0 => PIO0_0 | |
// 1 => PIO0_1 | |
//>2 => PIO0_2 | |
// ... | |
// 17 => PIO0_17 | |
// 注:LPC810は5(PIO0_5)まで | |
for(i = 0; i < 200000; i++) {} | |
// 適当にループして間隔をあける | |
LPC_GPIO_PORT->CLR0 |= (1<<2); | |
// GPIO出力をLOW | |
// UM10601 7.6.8 Table 89. | |
// 1:LOW | |
// 0 => PIO0_0 | |
// 1 => PIO0_1 | |
//>2 => PIO0_2 | |
// ... | |
// 17 => PIO0_17 | |
// 注:LPC810は5(PIO0_5)まで | |
for(i = 0; i < 200000; i++) {} | |
// 適当にループして間隔をあける | |
} | |
return 0 ; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment