共2条
1/1 1 跳转至页
AD12 请问关于AD12模块的问题。
问
相关的函数是这样写的:
void init_adc(void)
{
// ADC12 Initialization
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
P6SEL = 0x1F;
ADC12CTL0 &=~ ENC; ADC12CTL0 = ADC12ON + MSC + REFON + REF2_5V + SHT0_0;
ADC12CTL1 = SHP + ADC12SSEL_2 + CONSEQ_0;
ADC12MCTL0 = INCH_1 + SREF_0 + EOS;
ADC12CTL0 |= ENC; // Enable conversion
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
}
void con_adc_data(void)
{
// Sampling and conversion;
ADC12CTL0 |= ADC12SC; // Sampling open;
ADC12CTL0 &= ~ADC12SC; // Sampling closed, start conversion;
while((ADC12CTL1 & ADC12BUSY) == 1) // Check up if the adc is busy;
{
_NOP();
}
}
//*************************************************************************************
// Adc data transmitting functions by USB port;
//*************************************************************************************
void adc_data_trans(unsigned int length)
{
unsigned int i = 0x00;
unsigned int j = 0x00;
for(j=0; j<length; j++)
{
for(i=0; i<0x08; i++)
{
con_adc_data();
EpBuf[i*8+0] = (ADC12MEM0 & 0x00FF);
EpBuf[i*8+1] = (ADC12MEM0 & 0x0F00) >> 8;
EpBuf[i*8+2] = (ADC12MEM1 & 0x00FF);
EpBuf[i*8+3] = (ADC12MEM1 & 0x0F00) >> 8;
EpBuf[i*8+4] = (ADC12MEM2 & 0x00FF);
EpBuf[i*8+5] = (ADC12MEM2 & 0x0F00) >> 8;
EpBuf[i*8+6] = (ADC12MEM3 & 0x00FF);
EpBuf[i*8+7] = (ADC12MEM3 & 0x0F00) >> 8;
}
D12_WriteEndpoint(0x05, 0x40, EpBuf);
}
}
我用它来对一个40Hz的正弦波采样,结果得到这样的结果:
附图:
请问这可能是什么原因?
谢谢!
void init_adc(void)
{
// ADC12 Initialization
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
P6SEL = 0x1F;
ADC12CTL0 &=~ ENC; ADC12CTL0 = ADC12ON + MSC + REFON + REF2_5V + SHT0_0;
ADC12CTL1 = SHP + ADC12SSEL_2 + CONSEQ_0;
ADC12MCTL0 = INCH_1 + SREF_0 + EOS;
ADC12CTL0 |= ENC; // Enable conversion
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
}
void con_adc_data(void)
{
// Sampling and conversion;
ADC12CTL0 |= ADC12SC; // Sampling open;
ADC12CTL0 &= ~ADC12SC; // Sampling closed, start conversion;
while((ADC12CTL1 & ADC12BUSY) == 1) // Check up if the adc is busy;
{
_NOP();
}
}
//*************************************************************************************
// Adc data transmitting functions by USB port;
//*************************************************************************************
void adc_data_trans(unsigned int length)
{
unsigned int i = 0x00;
unsigned int j = 0x00;
for(j=0; j<length; j++)
{
for(i=0; i<0x08; i++)
{
con_adc_data();
EpBuf[i*8+0] = (ADC12MEM0 & 0x00FF);
EpBuf[i*8+1] = (ADC12MEM0 & 0x0F00) >> 8;
EpBuf[i*8+2] = (ADC12MEM1 & 0x00FF);
EpBuf[i*8+3] = (ADC12MEM1 & 0x0F00) >> 8;
EpBuf[i*8+4] = (ADC12MEM2 & 0x00FF);
EpBuf[i*8+5] = (ADC12MEM2 & 0x0F00) >> 8;
EpBuf[i*8+6] = (ADC12MEM3 & 0x00FF);
EpBuf[i*8+7] = (ADC12MEM3 & 0x0F00) >> 8;
}
D12_WriteEndpoint(0x05, 0x40, EpBuf);
}
}
我用它来对一个40Hz的正弦波采样,结果得到这样的结果:
附图:
请问这可能是什么原因?
谢谢!
共2条
1/1 1 跳转至页
回复
有奖活动 | |
---|---|
【有奖活动】分享技术经验,兑换京东卡 | |
话不多说,快进群! | |
请大声喊出:我要开发板! | |
【有奖活动】EEPW网站征稿正在进行时,欢迎踊跃投稿啦 | |
奖!发布技术笔记,技术评测贴换取您心仪的礼品 | |
打赏了!打赏了!打赏了! |