共2条
1/1 1 跳转至页
ADC10,DTC 请教怎样用C来编写ADC10的DTC(高速转换支持)功能!!!
问
请教怎样用C来编写ADC10的DTC(高速转换支持)功能? :confused:
我定义了一静态数组:
我的处理是:
#include "MSP430x11x2.h"
.
.
.
static unsigned short ADC10temp_array[8];
.
.
.
void Init_ADC10(void)
{
P2SEL = 0x0f;
ADC10CTL0 &= ~ENC;
ADC10CTL1 = ADC10DIV_3+ADC10SSEL_0+CONSEQ_2;
ADC10CTL0 = SREF_1+ADC10SHT_3+REFON+ADC10ON+ADC10IE;
//Vr+=Vref+=1.5V ON interrupt
ADC10SA = &ADC10temp_array[0]; //<--此处提示错误,错误说明见底下
ADC10DTC0 = 0;
ADC10DTC1 = 8;
}
.
.
Error[Pe513]: a value of type "unsigned short *" CANnot be assigned to an entity of type "unsigned short"
请问是什么原因? :confused:
正确的C又应该怎样编写DTC的处理程序呢??? :confused:
我的邮箱:lzygiant163.com
小弟先谢各位大侠了!
:light: :light: :light: 答 1: 请帮忙解答一下吧,各位了解此问题的专家,谢谢了! 答 2: 顶一下 答 3: 为什么MSP430F1122的DTC功能一直启动不了呢?弄了好久一直未搞定,快来帮帮忙吧! 答 4: 怎样才能将DTC在RAM中的值用C程序进行取平均呢?哪位能写出具体的C函数程序借鉴一下! 答 5: 改为 ADC10SA = ADC10temp_array[0]测试 答 6: www.lierda.com网站>资料库>源程序代码 里有有关ADC10的设置,请查阅。 答 7: 改成ADC10SA = ADC10temp_array[0];也是不行的。
其实只要能用C的指针访问到RAM的地址(如:0x200),就有办法解决了,
有谁知道了,请来顶一下。 答 8: //******************************************************************************
// MSP-FET430P120 Demo - ADC10/DTC Sample A0 64x, AVcc, Repeat Single DCO
//
// Description; Use DTC to sample A0 64 times with reference to AVcc. Software
// writes to ADC10SC to trigger sample burst. In Mainloop MSP430 waits in LPM0
// to save power until ADC10 conversion burst complete, ADC10_ISR(DTC) will
// force exit from any LPMx in Mainloop on reti. ADC10 internal oscillator
// times sample period (16x) and conversion (13x). DTC transfers conversion
// code to RAM 200h - 280h. P1.0 set at start of conversion burst, reset on
// completion.
// //*MSP430F1232 or MSP430F1132 Device Required*//
//
// MSP430F1232
// -----------------
// /|\| XIN|-
// | | |
// --|RST XOUT|-
// | |
// >---|A0 P1.0|-->LED
//
// M. Buccini
// Texas Instruments, Inc
// October 2003
// Built with IAR Embedded Workbench Version: 1.26B
// February 2004
// Updated for IAR Embedded Workbench Version: 2.21B
//******************************************************************************
#include <MSP430x12x2.h>
void main(void)
{
unsigned int loop,sample;
unsigned int MAXAMAL, MINIMAL;
unsigned int Sum;
unsigned int *pointer;
pointer = 0x00;
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P3DIR = 0xCf; // Test
P3SEL = 0x30; // Test
ADC10CTL1 = CONSEQ_2; // Repeat single channel
// ADC10CTL0 = ADC10SHT_2 + MSC + REF2_5V + ADC10ON + ADC10IE; // ADC10ON, interrupt enabled
// ADC10CTL0 = ADC10SHT_2 + MSC + ADC10ON + ADC10IE;
ADC10CTL0 = (SREF_1 + ADC10SHT_2 + MSC + ADC10SR + REF2_5V + REFON + ADC10ON + ADC10IE);
ADC10CTL1 &= 0x0fff; // Test
// ADC10CTL1 |= INCH_1; // temperature
// ADC10CTL1 |= INCH_2; // PPM
// ADC10CTL1 |= INCH_10; // temp. Sensor
ADC10CTL1 |= INCH_11; // Vcc
ADC10DTC1 = 0x60;
ADC10AE |= 0x07; // P2.0~P2.2 ADC option select
P1DIR |= 0x00; // Set P1.0 to output direction
for (;;)
{
Sum = 0x00;
MAXAMAL=0x0000;
MINIMAL=0x03ff;
for(loop = 0; loop<0x60; loop++)
{
sample = *(pointer + 0x200 + loop);
if(sample > MAXAMAL) MAXAMAL = sample;
if(sample < MINIMAL) MINIMAL = sample;
Sum += (sample & 0x03ff);
}
Sum = Sum/96;
ADC10CTL0 &= ~ENC;
while ((ADC10CTL1 & BUSY)); // Wait if ADC10 core is active
ADC10SA = 0x200; // Data buffer start
// P1OUT |= 0x01; // Set P1.0 LED on
ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start
_BIS_SR(CPUOFF + GIE); // LPM0, ADC10_ISR will force exit
// P1OUT &= ~0x01; // Clear P1.0 LED off
}
}
// ADC10 interrupt service routine
#pragma vector=ADC10_VECTOR
__interrupt void ADC10_ISR (void)
{
_BIC_SR_IRQ(CPUOFF); // Clear CPUOFF bit from 0(SR)
}
用MSP430F1232采样传感器处理后的信号,不知为何波动很大,连续采样,采样值在450左右时,波动在70左右。尝试10通道温度传感器,11通道半电源采集通道,波动在5个字左右。请帮忙分析,谢谢 答 9: 引用: 答 10: 出错原因是类型不匹配,
改成下面的句子应该可以:
ADC10SA = &ADC10temp_array; 答 11: lzygiant 问题解决没?
是定义问题,在数组前加“&”和“ *”的传送目的是不一样的。
我定义了一静态数组:
我的处理是:
#include "MSP430x11x2.h"
.
.
.
static unsigned short ADC10temp_array[8];
.
.
.
void Init_ADC10(void)
{
P2SEL = 0x0f;
ADC10CTL0 &= ~ENC;
ADC10CTL1 = ADC10DIV_3+ADC10SSEL_0+CONSEQ_2;
ADC10CTL0 = SREF_1+ADC10SHT_3+REFON+ADC10ON+ADC10IE;
//Vr+=Vref+=1.5V ON interrupt
ADC10SA = &ADC10temp_array[0]; //<--此处提示错误,错误说明见底下
ADC10DTC0 = 0;
ADC10DTC1 = 8;
}
.
.
Error[Pe513]: a value of type "unsigned short *" CANnot be assigned to an entity of type "unsigned short"
请问是什么原因? :confused:
正确的C又应该怎样编写DTC的处理程序呢??? :confused:
我的邮箱:lzygiant163.com
小弟先谢各位大侠了!
:light: :light: :light: 答 1: 请帮忙解答一下吧,各位了解此问题的专家,谢谢了! 答 2: 顶一下 答 3: 为什么MSP430F1122的DTC功能一直启动不了呢?弄了好久一直未搞定,快来帮帮忙吧! 答 4: 怎样才能将DTC在RAM中的值用C程序进行取平均呢?哪位能写出具体的C函数程序借鉴一下! 答 5: 改为 ADC10SA = ADC10temp_array[0]测试 答 6: www.lierda.com网站>资料库>源程序代码 里有有关ADC10的设置,请查阅。 答 7: 改成ADC10SA = ADC10temp_array[0];也是不行的。
其实只要能用C的指针访问到RAM的地址(如:0x200),就有办法解决了,
有谁知道了,请来顶一下。 答 8: //******************************************************************************
// MSP-FET430P120 Demo - ADC10/DTC Sample A0 64x, AVcc, Repeat Single DCO
//
// Description; Use DTC to sample A0 64 times with reference to AVcc. Software
// writes to ADC10SC to trigger sample burst. In Mainloop MSP430 waits in LPM0
// to save power until ADC10 conversion burst complete, ADC10_ISR(DTC) will
// force exit from any LPMx in Mainloop on reti. ADC10 internal oscillator
// times sample period (16x) and conversion (13x). DTC transfers conversion
// code to RAM 200h - 280h. P1.0 set at start of conversion burst, reset on
// completion.
// //*MSP430F1232 or MSP430F1132 Device Required*//
//
// MSP430F1232
// -----------------
// /|\| XIN|-
// | | |
// --|RST XOUT|-
// | |
// >---|A0 P1.0|-->LED
//
// M. Buccini
// Texas Instruments, Inc
// October 2003
// Built with IAR Embedded Workbench Version: 1.26B
// February 2004
// Updated for IAR Embedded Workbench Version: 2.21B
//******************************************************************************
#include <MSP430x12x2.h>
void main(void)
{
unsigned int loop,sample;
unsigned int MAXAMAL, MINIMAL;
unsigned int Sum;
unsigned int *pointer;
pointer = 0x00;
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P3DIR = 0xCf; // Test
P3SEL = 0x30; // Test
ADC10CTL1 = CONSEQ_2; // Repeat single channel
// ADC10CTL0 = ADC10SHT_2 + MSC + REF2_5V + ADC10ON + ADC10IE; // ADC10ON, interrupt enabled
// ADC10CTL0 = ADC10SHT_2 + MSC + ADC10ON + ADC10IE;
ADC10CTL0 = (SREF_1 + ADC10SHT_2 + MSC + ADC10SR + REF2_5V + REFON + ADC10ON + ADC10IE);
ADC10CTL1 &= 0x0fff; // Test
// ADC10CTL1 |= INCH_1; // temperature
// ADC10CTL1 |= INCH_2; // PPM
// ADC10CTL1 |= INCH_10; // temp. Sensor
ADC10CTL1 |= INCH_11; // Vcc
ADC10DTC1 = 0x60;
ADC10AE |= 0x07; // P2.0~P2.2 ADC option select
P1DIR |= 0x00; // Set P1.0 to output direction
for (;;)
{
Sum = 0x00;
MAXAMAL=0x0000;
MINIMAL=0x03ff;
for(loop = 0; loop<0x60; loop++)
{
sample = *(pointer + 0x200 + loop);
if(sample > MAXAMAL) MAXAMAL = sample;
if(sample < MINIMAL) MINIMAL = sample;
Sum += (sample & 0x03ff);
}
Sum = Sum/96;
ADC10CTL0 &= ~ENC;
while ((ADC10CTL1 & BUSY)); // Wait if ADC10 core is active
ADC10SA = 0x200; // Data buffer start
// P1OUT |= 0x01; // Set P1.0 LED on
ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start
_BIS_SR(CPUOFF + GIE); // LPM0, ADC10_ISR will force exit
// P1OUT &= ~0x01; // Clear P1.0 LED off
}
}
// ADC10 interrupt service routine
#pragma vector=ADC10_VECTOR
__interrupt void ADC10_ISR (void)
{
_BIC_SR_IRQ(CPUOFF); // Clear CPUOFF bit from 0(SR)
}
用MSP430F1232采样传感器处理后的信号,不知为何波动很大,连续采样,采样值在450左右时,波动在70左右。尝试10通道温度传感器,11通道半电源采集通道,波动在5个字左右。请帮忙分析,谢谢 答 9: 引用: 答 10: 出错原因是类型不匹配,
改成下面的句子应该可以:
ADC10SA = &ADC10temp_array; 答 11: lzygiant 问题解决没?
是定义问题,在数组前加“&”和“ *”的传送目的是不一样的。
共2条
1/1 1 跳转至页
回复
有奖活动 | |
---|---|
【有奖活动】分享技术经验,兑换京东卡 | |
话不多说,快进群! | |
请大声喊出:我要开发板! | |
【有奖活动】EEPW网站征稿正在进行时,欢迎踊跃投稿啦 | |
奖!发布技术笔记,技术评测贴换取您心仪的礼品 | |
打赏了!打赏了!打赏了! |
打赏帖 | |
---|---|
与电子爱好者谈读图四被打赏50分 | |
与电子爱好者谈读图二被打赏50分 | |
【FRDM-MCXN947评测】Core1适配运行FreeRtos被打赏50分 | |
【FRDM-MCXN947评测】双核调试被打赏50分 | |
【CPKCORRA8D1B评测】---移植CoreMark被打赏50分 | |
【CPKCORRA8D1B评测】---打开硬件定时器被打赏50分 | |
【FRDM-MCXA156评测】4、CAN loopback模式测试被打赏50分 | |
【CPKcorRA8D1评测】--搭建初始环境被打赏50分 | |
【FRDM-MCXA156评测】3、使用FlexIO模拟UART被打赏50分 | |
【FRDM-MCXA156评测】2、rt-thread MCXA156 BSP制作被打赏50分 |