TI中文支持网
TI专业的中文技术问题搜集分享网站

msp430fr5969 利用定时器触发ad采样问题,急急!!

你好,我现在利用定时器A3触发ad采样,每周期采样128点,但是配置完毕调试状态发现没有触发ad中断,不知道哪里配置有错误,请大神们指导下,配置文件见附件,其中,Timer3_A2_Init(void)配置采样定时器,void ADC12_B_Init(void) 配置AD

Triton Zhang:

给你个参考代码,TIMER 触发ADC,ADC直接触发DMA,采样结束后DMA中断里直接取数据。芯片用的MSP430FR6972.

/********************************************************************************* Function : msp430_timerA0_init                                             **** Descrpt  :                                                                 **** Input    :                                                                 **** Output   :                                                                 **** Return   :                                                                 **================================================================================** Author : Triton Zhang                                                      **** Date   : May.03,2015                                                       *********************************************************************************/ void msp430_timerA0_init(void){    // TA0 UP模式,1MS 中断    TA0CCR0 = TA0CCR0_VAL;                      // PWM Period              //by slf 2015/11/30 modified adc    TA0CCR1 = TA0CCR1_VAL;                      // TACCR1 PWM Duty Cycle    //by slf 2015/11/30 modified adc        TA0CCTL1 = OUTMOD_7;                        // TACCR1 set/reset    TA0CTL = TASSEL__ACLK | MC__UP | TACLR;     // ACLK, up mode}

/********************************************************************************* Function : msp430f_adc12_init                                              **** Descrpt  :                                                                 **** Input    :                                                                 **** Output   :                                                                 **** Return   :                                                                 **================================================================================** Author : Triton Zhang                                                      **** Date   : May.03,2015                                                       *********************************************************************************/ void msp430_adc12b_init(void){    PORT_ADC_SEL0 |= (ADC_PIN0 + ADC_PIN1 + ADC_PIN2 + ADC_PIN3);       PORT_ADC_SEL1 |= (ADC_PIN0 + ADC_PIN1 + ADC_PIN2 + ADC_PIN3);         ADC12CTL2 = ADC12RES_2 + ADC12PWRMD;   // 12-bit conversion results, low power mode}/********************************************************************************* Function : board_current_adc_init                                          **** Descrpt  :                                                                 **** Input    :                                                                 **** Output   :                                                                 **** Return   :                                                                 **================================================================================** Author : Triton Zhang                                                      **** Date   : May.03,2015                                                       *********************************************************************************/ void board_current_adc_init(uint8_t nMode){    PORT_ADC_SEL0 |= (ADC_PIN0 + ADC_PIN1 + ADC_PIN2 + ADC_PIN3);       PORT_ADC_SEL1 |= (ADC_PIN0 + ADC_PIN1 + ADC_PIN2 + ADC_PIN3);           msp430_adc_sample();     msp430_dma0_init(ADC_GROUP_NUM);    // by slf 2015/11/30 modified adc    msp430_timerA0_init();}

uint8_t msp430_adc_sample(uint8_t Mod){    uint8_t i = 0;    uint8_t timeout = 24;            ADC12CTL0 &= ~ADC12ENC;    ADC12CTL0 &= ~ADC12ON;    __delay_cycles(10);        ADC12CTL0 = ADC12SHT0_2 | ADC12SHT1_2| ADC12ON;     ADC12CTL1 = ADC12SHP | ADC12CONSEQ_2 | ADC12SHS_1; //|;      // Timer TA0 Trigger ADC    ADC12CTL2 = ADC12RES_2 + ADC12PWRMD;                    // 12-bit conversion results, low power mode    ADC12CTL3 = 0;

    ADC12MCTL0 = ADC_CHN[3];    ADC12CTL0 |= ADC12ENC | ADC12SC;                        // Start sampling/conversion

    return 1;}

吐个槽,最烦用库函数来写代码了。出了问题找起来累死个人。

灰小子:

回复 Triton Zhang:

楼上是大牛,一般新手用库函数能更快上手。

jj z:

回复 灰小子:

你好,还是不行,能给看看配置哪里错误了吗

赞(0)
未经允许不得转载:TI中文支持网 » msp430fr5969 利用定时器触发ad采样问题,急急!!
分享到: 更多 (0)