#include <NUC029xAN.h>
#include <stdio.h>
void sys_init(void) {
SYS_UnlockReg();
CLK_EnableXtalRC(CLK_PWRCON_XTL12M_EN_Msk);
CLK_WaitClockReady(CLK_CLKSTATUS_XTL12M_STB_Msk);
CLK_EnablePLL(CLK_PLLCON_PLL_SRC_HXT, FREQ_100MHZ);
CLK_WaitClockReady(CLK_CLKSTATUS_PLL_STB_Msk);
CLK_SetHCLK(CLK_CLKSEL0_HCLK_S_PLL, CLK_CLKDIV_HCLK(2));
SystemCoreClockUpdate();
}
void led_init(void) {
SYS->P3_MFP &= ~(SYS_MFP_P32_Msk | SYS_MFP_P33_Msk | SYS_MFP_P34_Msk | SYS_MFP_P35_Msk);
SYS->P3_MFP |= SYS_MFP_P32_GPIO | SYS_MFP_P33_GPIO | SYS_MFP_P34_GPIO | SYS_MFP_P35_GPIO;
GPIO_SetMode(P3, BIT2 | BIT3 | BIT4 | BIT5, GPIO_PMD_OUTPUT);
}
void delay(volatile uint32_t t) {
for ( ; t; t--) {
}
}
int main(void) {
sys_init();
led_init();
for ( ; ; ) {
P35 = 0;
P32 = 1;
delay(1000000);
P32 = 0;
P33 = 1;
delay(1000000);
P33 = 0;
P34 = 1;
delay(1000000);
P34 = 0;
P35 = 1;
delay(1000000);
}
return 0;
}
离线