使用TimerA.out1触发ADC采样,采样周期由定时器A设定,我写的代码进行硬件仿真时,总是无法采集到任何信息,还有什么其他方法可以采样5Hz左右的信号吗?求助一下,谢谢
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
使用TimerA.out1触发ADC采样,采样周期由定时器A设定,我写的代码进行硬件仿真时,总是无法采集到任何信息,还有什么其他方法可以采样5Hz左右的信号吗?求助一下,谢谢
jing lin,
使用TimerA.out1触发ADC采样时,一般是控制timer A输出PWM波。对应的例程应该在MSP430Ware中有,
Schroch Adam,
提供的附件代码时MSP430G2x33芯片使用的,是个可以直接参考的例子,不可以直接给MSP430F5438A使用。如果是MSP430F5438A的话,请从下列link下载对应的code example, 但是关于Timer触发的机制的话,没有现成的,需要参考之前附件的。
http://www.ti.com/product/MSP430F5438A/toolssoftware
MSP430F543xA, MSP430F541xA Code Examples (Rev. F) (ZIP 630 KB ) 849 views, 03 Oct 2014
msp430x54xA_adc12_01.c ADC12, Sample A0, Set P1.0 if A0 > 0.5*AVcc
msp430x54xA_adc12_02.c ADC12, Using the Internal Reference
msp430x54xA_adc12_05.c ADC12, Using an External Reference
msp430x54xA_adc12_06.c ADC12, Repeated Sequence of Conversions
msp430x54xA_adc12_07.c ADC12, Repeated Single Channel Conversions
msp430x54xA_adc12_09.c ADC12, Sequence of Conversions (non-repeated)
msp430x54xA_adc12_10.c ADC12, Sample A10 Temp and Convert to oC and oF
你快告诉我这段代码为什么不能运行:
#include "msp430f5438a.h"
void Init_ADC()
{
ADC12CTL1 = ADC12SHS_1 + ADC12CONSEQ_2;
ADC12CTL0 = ADC12ON + ADC12SHT0_3;
ADC12MCTL0 = ADC12INCH_0;
ADC12IE = 0xff;
ADC12CTL0|=ADC12ENC;
}
void Init_TimerA0()
{
TA0CCR0 = 1024;
TA0CCTL1=OUTMOD_3;
TA0CCR1=1022;//SHI上升沿电平
TA0CTL=TASSEL_1+MC_1+TACLR;
}
int main( void )
{
// Stop watchdog timer to prevent time out reset
WDTCTL = WDTPW + WDTHOLD;
P4DIR|=BIT7;
P5DIR|=BIT4;
P4OUT|=BIT7;
P5OUT|=BIT4;
P6DIR&=~BIT0;
P6SEL|=BIT0;
P1SEL|=BIT2;
_EINT();
Init_TimerA0();
Init_ADC();
while(1);
}
#pragma vector=ADC12_VECTOR
__interrupt void ADC12_ISR(void)
{
unsigned int temp=ADC12MEM0;
//waters+=(double)temp/409600*vcc*kv*0.05;
}
5438A定时器触发ADC12采样的定时器是TA0.0,TB0.0,TB0.1。选用TA触发,必须是TA0.0。最近刚好做到这块儿,430ware例程中是TB触发,改成TA触发的时候发现没采样值,查看5438A手册发现的,每个芯片的定时器触发源可能会有所差别的。