共2条
1/1 1 跳转至页
msp430f149 msp430f149中A/D转换时间和采样频率怎么设置啊???
问
我想用AD12进行数据采集,利用多通道多次转换,但是不知道采样频率怎么设置,哪位大侠帮帮忙了。谢谢了
答 1:
ADC12CTL0的SHT0和SHT1是设置采样频率的。你可以参考下面程序:
//******************************************************************************
// MSP-FET430P140 Demo - ADC12, Repeated Sequence of Conversions
//
// This example shows how to perform a repeated sequence of conversions using
// "repeat sequence-of-channels" mode. AVcc is used for the reference and
// repeated sequence of conversions is performed on Channels A0, A1, A2, and
// A3. Each conversion result is stored in ADC12MEM0, ADC12MEM1, ADC12MEM2,
// and ADC12MEM3 respectively. After each sequence, the 4 conversion results
// are moved to A0results[], A1results[], A2results[], and A3results[]. Test
// by applying voltages to channels A0 - A3. Open a watch window in C-Spy and
// view the results. Set a breakpoint in the last line to see the array values
// change sequentially.
//
// Note that a sequence has no restrictions on which channels are converted.
// For example, a valid sequence could be A0, A3, A2, A4, A2, A1, A0, and A7.
// See the MSP430x1xx User's Guide for instructions on using the ADC12.
//
//
// MSP430F149
// -----------------
// | |
// | A0 |<---- Vin0
// | A1 |<---- Vin1
// | A2 |<---- Vin2
// | A3 |<---- Vin3
// | |
//
//
// M.Mitchell
// Texas Instruments, Inc
// January, 2002
// Built with IAR Embedded Workbench Version: 1.25A
// December 2003
// Updated for IAR Embedded Workbench Version: 2.21B
//******************************************************************************
#include "MSP430x14x.h" // Standard Equations
#define Num_of_Results 8
static unsigned int A0results[Num_of_Results]; // These need to be global in
static unsigned int A1results[Num_of_Results]; // this example. Otherwise, the
static unsigned int A2results[Num_of_Results]; // compiler removes them because
static unsigned int A3results[Num_of_Results]; // they are not used
void main(void)
{
WDTCTL = WDTPW+WDTHOLD; // Stop watchdog timer
P6SEL = 0x0F; // Enable A/D channel inputs
ADC12CTL0 = ADC12ON+MSC+SHT0_8; // Turn on ADC12, extend sampling time
// to avoid overflow of results
ADC12CTL1 = SHP+CONSEQ_3; // Use sampling timer, repeated sequence
ADC12MCTL0 = INCH_0; // ref+=AVcc, channel = A0
ADC12MCTL1 = INCH_1; // ref+=AVcc, channel = A1
ADC12MCTL2 = INCH_2; // ref+=AVcc, channel = A2
ADC12MCTL3 = INCH_3+EOS; // ref+=AVcc, channel = A3, end seq.
ADC12IE = 0x08; // Enable ADC12IFG.3
ADC12CTL0 |= ENC; // Enable conversions
_EINT(); // Enable interrupts
ADC12CTL0 |= ADC12SC; // Start conversion
_BIS_SR(LPM0_bits); // Enter and stay in LPM0
}
#pragma vector=ADC_VECTOR
__interrupt void ADC12ISR (void)
{
static unsigned int index = 0;
A0results[index] = ADC12MEM0; // Move A0 results, IFG is cleared
A1results[index] = ADC12MEM1; // Move A1 results, IFG is cleared
A2results[index] = ADC12MEM2; // Move A2 results, IFG is cleared
A3results[index] = ADC12MEM3; // Move A3 results, IFG is cleared
index = (index+1)%Num_of_Results; // Increment results index, modulo; Set Breakpoint here
} 答 2: 版主大人,你还没有具体告诉我这个程序怎么个解释啊,ADC12CTL0 = ADC12ON+MSC+SHT0_8; // Turn on ADC12, extend sampling time。这句有告诉我频率是多少吗?
我真的很笨,但我愿意学,你不要生气吗! 答 3: 采样时间由SHT0_8确定
T=4*ADC12CLK周期*8 答 4: 谢谢了!时钟是系统时钟吧!
//******************************************************************************
// MSP-FET430P140 Demo - ADC12, Repeated Sequence of Conversions
//
// This example shows how to perform a repeated sequence of conversions using
// "repeat sequence-of-channels" mode. AVcc is used for the reference and
// repeated sequence of conversions is performed on Channels A0, A1, A2, and
// A3. Each conversion result is stored in ADC12MEM0, ADC12MEM1, ADC12MEM2,
// and ADC12MEM3 respectively. After each sequence, the 4 conversion results
// are moved to A0results[], A1results[], A2results[], and A3results[]. Test
// by applying voltages to channels A0 - A3. Open a watch window in C-Spy and
// view the results. Set a breakpoint in the last line to see the array values
// change sequentially.
//
// Note that a sequence has no restrictions on which channels are converted.
// For example, a valid sequence could be A0, A3, A2, A4, A2, A1, A0, and A7.
// See the MSP430x1xx User's Guide for instructions on using the ADC12.
//
//
// MSP430F149
// -----------------
// | |
// | A0 |<---- Vin0
// | A1 |<---- Vin1
// | A2 |<---- Vin2
// | A3 |<---- Vin3
// | |
//
//
// M.Mitchell
// Texas Instruments, Inc
// January, 2002
// Built with IAR Embedded Workbench Version: 1.25A
// December 2003
// Updated for IAR Embedded Workbench Version: 2.21B
//******************************************************************************
#include "MSP430x14x.h" // Standard Equations
#define Num_of_Results 8
static unsigned int A0results[Num_of_Results]; // These need to be global in
static unsigned int A1results[Num_of_Results]; // this example. Otherwise, the
static unsigned int A2results[Num_of_Results]; // compiler removes them because
static unsigned int A3results[Num_of_Results]; // they are not used
void main(void)
{
WDTCTL = WDTPW+WDTHOLD; // Stop watchdog timer
P6SEL = 0x0F; // Enable A/D channel inputs
ADC12CTL0 = ADC12ON+MSC+SHT0_8; // Turn on ADC12, extend sampling time
// to avoid overflow of results
ADC12CTL1 = SHP+CONSEQ_3; // Use sampling timer, repeated sequence
ADC12MCTL0 = INCH_0; // ref+=AVcc, channel = A0
ADC12MCTL1 = INCH_1; // ref+=AVcc, channel = A1
ADC12MCTL2 = INCH_2; // ref+=AVcc, channel = A2
ADC12MCTL3 = INCH_3+EOS; // ref+=AVcc, channel = A3, end seq.
ADC12IE = 0x08; // Enable ADC12IFG.3
ADC12CTL0 |= ENC; // Enable conversions
_EINT(); // Enable interrupts
ADC12CTL0 |= ADC12SC; // Start conversion
_BIS_SR(LPM0_bits); // Enter and stay in LPM0
}
#pragma vector=ADC_VECTOR
__interrupt void ADC12ISR (void)
{
static unsigned int index = 0;
A0results[index] = ADC12MEM0; // Move A0 results, IFG is cleared
A1results[index] = ADC12MEM1; // Move A1 results, IFG is cleared
A2results[index] = ADC12MEM2; // Move A2 results, IFG is cleared
A3results[index] = ADC12MEM3; // Move A3 results, IFG is cleared
index = (index+1)%Num_of_Results; // Increment results index, modulo; Set Breakpoint here
} 答 2: 版主大人,你还没有具体告诉我这个程序怎么个解释啊,ADC12CTL0 = ADC12ON+MSC+SHT0_8; // Turn on ADC12, extend sampling time。这句有告诉我频率是多少吗?
我真的很笨,但我愿意学,你不要生气吗! 答 3: 采样时间由SHT0_8确定
T=4*ADC12CLK周期*8 答 4: 谢谢了!时钟是系统时钟吧!
共2条
1/1 1 跳转至页
回复
有奖活动 | |
---|---|
【有奖活动】分享技术经验,兑换京东卡 | |
话不多说,快进群! | |
请大声喊出:我要开发板! | |
【有奖活动】EEPW网站征稿正在进行时,欢迎踊跃投稿啦 | |
奖!发布技术笔记,技术评测贴换取您心仪的礼品 | |
打赏了!打赏了!打赏了! |
打赏帖 | |
---|---|
【笔记】生成报错synthdesignERROR被打赏50分 | |
【STM32H7S78-DK评测】LTDC+DMA2D驱动RGBLCD屏幕被打赏50分 | |
【STM32H7S78-DK评测】Coremark基准测试被打赏50分 | |
【STM32H7S78-DK评测】浮点数计算性能测试被打赏50分 | |
【STM32H7S78-DK评测】Execute in place(XIP)模式学习笔记被打赏50分 | |
每周了解几个硬件知识+buckboost电路(五)被打赏10分 | |
【换取逻辑分析仪】RA8 PMU 模块功能寄存器功能说明被打赏20分 | |
野火启明6M5适配SPI被打赏20分 | |
NUCLEO-U083RC学习历程2-串口输出测试被打赏20分 | |
【笔记】STM32CUBEIDE的Noruletomaketarget编译问题被打赏50分 |