用Work_Bench创建了一个AT的工程,在做实验时能遇到一些问题,以后慢慢提问并解决。如果解决了,会将代码放上一起学习。
四、DAC问题,初始化代码没有问题,初始化代码如下:void wk_dac_init(void)
{
/* add user code begin dac_init 0 */
/* add user code end dac_init 0 */
gpio_init_type gpio_init_struct;
gpio_default_para_init(&gpio_init_struct);
/* add user code begin dac_init 1 */
/* add user code end dac_init 1 */
/*gpio------------------------------------------------------------------------------*/
/* configure the OUT1 pin */
gpio_init_struct.gpio_pins = DAC1_PIN;
gpio_init_struct.gpio_mode = GPIO_MODE_ANALOG;
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
gpio_init(DAC1_GPIO_PORT, &gpio_init_struct);
/* configure the OUT2 pin */
gpio_init_struct.gpio_pins = DAC2_PIN;
gpio_init_struct.gpio_mode = GPIO_MODE_ANALOG;
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
gpio_init(DAC2_GPIO_PORT, &gpio_init_struct);
/*dac OUT1 init--------------------------------------------------------------------*/
dac_trigger_enable(DAC1_SELECT, TRUE);
dac_trigger_select(DAC1_SELECT, DAC_SOFTWARE_TRIGGER);
dac_wave_generate(DAC1_SELECT, DAC_WAVE_GENERATE_TRIANGLE);
/*Triangular amplitude select------------------------------------------------------*/
dac_mask_amplitude_select(DAC1_SELECT, DAC_LSFR_BITB0_AMPLITUDE_4095);//DAC_LSFR_BIT10_AMPLITUDE_3);//
dac_output_buffer_enable(DAC1_SELECT, TRUE);
dac_dma_enable(DAC1_SELECT, TRUE);
dac_enable(DAC1_SELECT, TRUE);
/*dac OUT2 init--------------------------------------------------------------------*/
dac_trigger_enable(DAC2_SELECT, TRUE);
dac_trigger_select(DAC2_SELECT, DAC_SOFTWARE_TRIGGER);
dac_wave_generate(DAC2_SELECT, DAC_WAVE_GENERATE_TRIANGLE);
/*Triangular amplitude select------------------------------------------------------*/
dac_mask_amplitude_select(DAC2_SELECT, DAC_LSFR_BITA0_AMPLITUDE_2047);//DAC_LSFR_BIT90_AMPLITUDE_1023);//DAC_LSFR_BIT20_AMPLITUDE_7);//
dac_output_buffer_enable(DAC2_SELECT, TRUE);
dac_enable(DAC2_SELECT, TRUE);
/* add user code begin dac_init 2 */
/* add user code end dac_init 2 */
}
初始化后PA_4,PA_5没有动静,将这两行放入一段代码中,
dac_software_trigger_generate(DAC1_SELECT);
dac_software_trigger_generate(DAC2_SELECT);
DAC三角波就出来了,速度非常慢,我选择的是软件触发,就将这两行放到AT32F403a_407_int.c中的tick函数中,结果是能出来稍快一点的三角波,并且比较圆滑。看厂家提供的工程是采用time2触发DAC,如果仅仅用软件触发我的方法肯定不对,但应该如何写呢?
谢谢
|