完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
//******************************************************************************
// MSP-FET430P140 Demo - ADC12, Repeated Single Channel Conversions // // Description: This example shows how to perform repeated conversions on a // single channel using "repeat-single-channel" mode. AVcc is used for the // reference and repeated conversions are performed on Channel A0. Each // conversion result is moved to an 8-element array called results[]. Test by // applying a voltage to channel A0, then running. To view the conversion results // open a watch window and view 'results.' // This can run even in LPM4 mode as ADC has its own clock // // MSP430F149 // --------------- // | | // Vin -->|P6.0/A0 | // | | // // // M. Mitchell // Texas Instruments Inc. // Feb 2005 // Built with IAR Embedded Workbench Version: 3.21A //****************************************************************************** #include #define Num_of_Results 8 static unsigned int results[Num_of_Results]; // Needs to be global in this // example. Otherwise, the // compiler removes it because it // is not used for anything. void main(void) { WDTCTL = WDTPW+WDTHOLD; // Stop watchdog timer P6SEL |= 0x01; // Enable A/D channel A0 ADC12CTL0 = ADC12ON+SHT0_8+MSC; // Turn on ADC12, set sampling time ADC12CTL1 = SHP+CONSEQ_2; // Use sampling timer, set mode ADC12IE = 0x01; // Enable ADC12IFG.0 ADC12CTL0 |= ENC; // Enable conversions ADC12CTL0 |= ADC12SC; // Start conversion _BIS_SR(LPM0_bits + GIE); // Enter LPM0,Enable interrupts } #pragma vector=ADC_VECTOR __interrupt void ADC12ISR (void) { static unsigned int index = 0; results[index] = ADC12MEM0; // Move results index = (index+1)%Num_of_Results; // Increment results index, modulo } |
|
相关推荐 |
|
只有小组成员才能发言,加入小组>>
3056个成员聚集在这个小组
加入小组2985 浏览 1 评论
MSP430FR5994 使用库函数 定时器触发AD问题请教
3710 浏览 2 评论
请问怎么把下面51单片机的代码改成msp430 g2 pocket的代码,还有改下时间变成30秒
2367 浏览 1 评论
4834 浏览 1 评论
2595 浏览 1 评论
1632浏览 3评论
MSP430FR5994 使用库函数 定时器触发AD问题请教
3715浏览 2评论
2987浏览 1评论
1828浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-29 02:03 , Processed in 1.247032 second(s), Total 39, Slave 33 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号