还是上次的那些模块。
然后打开快速指导的Quick Start Guide for TC - Match Frequency Wave Generation
按照提示完成程序:
#include <asf.h>
#define PWM_MODULE EXT1_PWM_MODULE
#define PWM_OUT_PIN EXT1_PWM_0_PIN
#define PWM_OUT_MUX EXT1_PWM_0_MUX
struct tc_module tc_instance;
void configure_tc(void);
int main (void)
{
system_init();
configure_tc();
while (1)
{
}
}
void configure_tc(void)
{ struct tc_config config_tc;
tc_get_config_defaults(&config_tc);
config_tc.counter_size = TC_COUNTER_SIZE_16BIT;
config_tc.wave_generation = TC_WAVE_GENERATION_MATCH_FREQ;
config_tc.counter_16_bit.compare_capture_channel[0] = 4000;
config_tc.pwm_channel[0].enabled = true;
config_tc.pwm_channel[0].pin_out = PWM_OUT_PIN;
config_tc.pwm_channel[0].pin_mux = PWM_OUT_MUX;
tc_init(&tc_instance, PWM_MODULE, &config_tc);
tc_enable(&tc_instance);}
查了下,管脚是PB02
|