Created
July 8, 2018 13:24
-
-
Save nickfox-taterli/9bfdb436a2e388deb3442dd2cf135605 to your computer and use it in GitHub Desktop.
LPC43xx SCT Blink
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 "LPC43xx.h" | |
void SCT_Init(void) | |
{ | |
LPC_CCU1->CLK_M4_SCT_CFG = (1 << 0); | |
LPC_SCT->CONFIG |= 1; /* 1 = 不拆分定时器 0 = 双16位定时器 */ | |
LPC_SCT->MATCHREL[0].U = 100000000; /* 匹配计数值 */ | |
LPC_SCT->EVENT[0].STATE = 0x00000001; // EVENT0 只在 STATE0 有效. | |
LPC_SCT->EVENT[0].CTRL = (0 << 0) | | |
(1 << 12) | // 匹配模式 | |
(1 << 14) | | |
(1 << 15); // 切换STATE = 1 | |
LPC_SCT->EVENT[1].STATE = 0x00000002; // EVENT1 只在 STATE1 有效. | |
LPC_SCT->EVENT[1].CTRL = (0 << 0) | | |
(1 << 12) | // 匹配模式 | |
(1 << 14) | | |
(0 << 15); // 切换STATE = 0 | |
/* LPC_SCT->SCTx_OUTy[y = 数组内的数值] (m << n) m = 使能位 n = EVENT号 */ | |
LPC_SCT->OUT[0].SET = (1 << 0); | |
LPC_SCT->OUT[0].CLR = (1 << 1); | |
/* 告知处理器用了哪些EVENT.这里用了1和0. */ | |
LPC_SCT->LIMIT_L = 0x0003; | |
LPC_SCT->CTRL_U &= ~(1 << 2); // HALT标记,HALT就是关机,类似别人寄存器里面的EN. | |
LPC_SCU->SFSP2_8 = (2 << 3) | 0x01; /* 关闭上拉 + FUNC1 */ | |
} | |
int main(void) | |
{ | |
SCT_Init(); | |
while (1) | |
{ | |
__WFI(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment