本帖最后由 ddllxxrr 于 2015-3-2 20:33 编辑
在Atmle Studio6.2环境中插入开发板,则自动弹出开发板界面,这时可直接打开例程。
今天的例程是这样,让用户按键,每按下一个键输出的时钟都会改变,大概按四次左右,又恢复起始状态。
这里是判断按键按下和抬起的函数:
static void wait_for_switches(void)
{
do {
} while (ioport_get_pin_level(GPIO_PUSH_BUTTON_1));
mdelay(1);
do {
} while (!ioport_get_pin_level(GPIO_PUSH_BUTTON_1));
mdelay(1);
}
而所有的晶振的源宏定义,都在genclk.h中:
enum genclk_source {
GENCLK_PCK_SRC_SLCK_RC = 0, //!< Internal 32kHz RC oscillator as PCK source clock
GENCLK_PCK_SRC_SLCK_XTAL = 1, //!< External 32kHz crystal oscillator as PCK source clock
GENCLK_PCK_SRC_SLCK_BYPASS = 2, //!< External 32kHz bypass oscillator as PCK source clock
GENCLK_PCK_SRC_MAINCK_4M_RC = 3, //!< Internal 4MHz RC oscillator as PCK source clock
GENCLK_PCK_SRC_MAINCK_8M_RC = 4, //!< Internal 8MHz RC oscillator as PCK source clock
GENCLK_PCK_SRC_MAINCK_12M_RC = 5, //!< Internal 12MHz RC oscillator as PCK source clock
GENCLK_PCK_SRC_MAINCK_XTAL = 6, //!< External crystal oscillator as PCK source clock
GENCLK_PCK_SRC_MAINCK_BYPASS = 7, //!< External bypass oscillator as PCK source clock
GENCLK_PCK_SRC_PLLACK = 8, //!< Use PLLACK as PCK source clock
GENCLK_PCK_SRC_MCK = 9, //!< Use Master Clk as PCK source clock
};
而主函数的循环如下:
运行结果当我按下板子上的KEY0键时,PA6刚开始是系统时钟,然后减半,然后又是一个新时钟,接着又是外新时钟。然后回到开始。
|