在Atmel Studio6.2开发环境中,直接插入开发板,则开发板信息直接弹出来。
打开ioport_example1例程。
可以看出:晶振是在conf_clock.h中定义:
- // ===== PLL0 (A) Options (Fpll = (Fclk * PLL_mul) / PLL_div)
- // Use mul and div effective values here.
- #define CONFIG_PLL0_SOURCE PLL_SRC_MAINCK_8M_RC
- #define CONFIG_PLL0_MUL 25
- #define CONFIG_PLL0_DIV 1
- // ===== Target frequency (System clock)
- // - Internal RC frequency: 8MHz
- // - System clock source: PLLA
- // - System clock prescaler: 2 (divided by 2)
- // - PLLA source: 8M_RC
- // - PLLA output: 8M_RC * 25 / 1
- // - System clock: 8M_RC * 25 / 1 / 2 = 100MHz
- #endif /* CONF_CLOCK_H_INCLUDED */
我认为这个晶振可以不用变,就是说在以后的自己写程序或开发板,可以照搬过来,就象模板一样。
管脚的方向配置在主函数的这里:
- /* Set output direction on the given LED IOPORTs */
- ioport_set_port_dir(EXAMPLE_LED_PORT, EXAMPLE_LED_MASK,
- IOPORT_DIR_OUTPUT);
而EXAMPLE_LED_PORT和EXAMPLE_LED_MASK是在:
conf_example.h中
- #ifndef CONF_EXAMPLE_H_INCLUDED
- #define CONF_EXAMPLE_H_INCLUDED
- /* Using LED0 SAM4N-XPLAINED-PRO (PB14) */
- #define EXAMPLE_LED_PORT (1)
- #define EXAMPLE_LED_MASK ((1 << 14))
- /* Using button SW0 on SAM4N-XPLAINED-PRO (PA30) */
- #define EXAMPLE_BUTTON_PORT (0)
- #define EXAMPLE_BUTTON_MASK ((1 << 30))
- #endif /* CONF_EXAMPLE_H_INCLUDED */
而IOPORT_DIR_OUTPUT是在ioport.h中定义:
- /** \brief IOPORT pin directions */
- enum ioport_direction {
- IOPORT_DIR_INPUT, /*!< IOPORT input direction */
- IOPORT_DIR_OUTPUT, /*!< IOPORT output direction */
- };
而主函数 如下:
可以看出,在主函数里就是定义了LED的方向后,不断地转换电平,即高变低低变高,给我的感觉就是开发板的默认程序:
|