在线时间954 小时
UID336767
注册时间2011-12-29
NXP金币612
TA的每日心情 | 开心 2018-7-23 21:04 |
---|
签到天数: 103 天 [LV.6]常住居民II
金牌会员
- 积分
- 15344
- 最后登录
- 1970-1-1
|
楼主 |
发表于 2016-11-26 00:11:04
|
显示全部楼层
差点忘了最后上程序了
- /*
- ===============================================================================
- Name : 006_sct_base.c
- Author : $(lkl0305)
- Version : 1.0
- Copyright : $(copyright)
- Description : main definition
- ===============================================================================
- */
- #if defined (__USE_LPCOPEN)
- #if defined(NO_BOARD_LIB)
- #include "chip.h"
- #else
- #include "board.h"
- #endif
- #endif
- #include <cr_section_macros.h>
- // TODO: insert other include files here
- // TODO: insert other definitions and declarations here
- void SCT_Init(void)
- {
- Chip_SCT_Init(LPC_SCT);
- Chip_SCT_Config(LPC_SCT, SCT_CONFIG_32BIT_COUNTER | SCT_CONFIG_CLKMODE_BUSCLK);
- LPC_SCT->STATE_U = 0x00000000;
- LPC_SCT->REGMODE_U = 0x00000000;
- Chip_SCT_SetMatchCount(LPC_SCT, SCT_MATCH_0, SystemCoreClock / 1);
- Chip_SCT_SetMatchReload(LPC_SCT, SCT_MATCH_0, SystemCoreClock / 1);
- LPC_SCT->EV[0].CTRL = (0 << 0) | (1 << 12);
- LPC_SCT->EV[0].STATE = 0x00000001;
- LPC_SCT->LIMIT_U = 0x00000001;
- Chip_SCT_EnableEventInt(LPC_SCT, SCT_EVT_0);
- NVIC_EnableIRQ(SCT_IRQn);
- Chip_SCT_ClearControl(LPC_SCT, SCT_CTRL_HALT_L);
- }
- void SCT_IRQHandler(void)
- {
- if (LPC_SCT->EVFLAG & SCT_EVT_0)
- {
- Board_LED_Toggle(0);
- Chip_SCT_ClearEventFlag(LPC_SCT, SCT_EVT_0);
- }
- }
- int main(void) {
- #if defined (__USE_LPCOPEN)
- // Read clock settings and update SystemCoreClock variable
- SystemCoreClockUpdate();
- #if !defined(NO_BOARD_LIB)
- // Set up and initialize all required blocks and
- // functions related to the board hardware
- Board_Init();
- // Set the LED to the state of "On"
- Board_LED_Set(0, true);
- #endif
- #endif
- // TODO: insert code here
- SCT_Init();
- // Force the counter to be placed into memory
- volatile static int i = 0 ;
- // Enter an infinite loop, just incrementing a counter
- while(1) {
- i++ ;
- }
- return 0 ;
- }
复制代码 |
|