|
|
| | -文章搜索 - 最新文章 - | |
MSP430F423 sigma-delta code |
| 发布时间:2006年8月3日 点击次数:1325 |
| 来源: 作者: |
// MSP430x42x0 Demo - SD16_A, Using the Integrated Battery Sensor // //Description: This example shows how to use the SD16_A module''s integrated //Battery sensor (connected to input channel 5) to measure VCC. //A single conversion is initiated and then the CPU is disabled by entering //LPM0. Once the conversion has completed, a SD16_A interrupt occurs and //stores the result in variable "ADCresult".LED lights if batter is low //ACLK = LFXT1 = 32768 Hz, MCLK = SMCLK = DCO = 32 x ACLK = 1048576 Hz ////* An external watch crystal on XIN XOUT is required for ACLK *// ////* Minimum Vcc is required for SD16_A module - see datasheet*// ////* 100nF cap btw Vref and AVss is recommended when using 1.2V ref *// // //MSP430F4270 // ----------------- // / \ XIN - // 32kHz //-- RSTXOUT - // // A5+ ( A5+, A5- connected internally ) // A5- // // VREF ---+ // // -+- 100nF // -+- // // AVss ---+ // // //L. Westlund / S. Karthikeyan //Texas Instruments Inc. //June 2005 //Built with IAR Embedded Workbench Version: 3.30A //***************************************************************************** #include #define LOW_BAT 0xBFFF// ~3V static unsigned int ADCresult; void main(void) { volatile unsigned int i;// Use volatile to prevent removal // by compiler optimization P1DIR = 0x01; WDTCTL = WDTPW + WDTHOLD; // Stop WDT FLL_CTL0 = XCAP14PF; // Configure load caps for (i = 0; i < 10000; i++);// Delay for 32 kHz crystal to // stabilize SD16CTL = SD16REFON+SD16SSEL0;// 1.2V ref, SMCLK SD16CCTL0 = SD16SNGL+SD16IE ;// Single conv, enable interrupt SD16INCTL0 = SD16INCH_5; // Select Channel A5 for (i = 0; i < 0x3600; i++); // Delay for 1.2V ref startup _EINT();// Enable general interrupts while (1) { SD16CCTL0 = SD16SC;// Set bit to start conversion _BIS_SR(LPM0_bits); // Enter LPM0 if( ADCresult < LOW_BAT ) { P1OUT = 0x01; } else { P1OUT &= ~0x01; } _NOP(); //SET BREAKPOINT HERE } } #pragma vector=SD16_VECTOR __interrupt void SD16ISR(void) { switch (SD16IV) { case 2: // SD16MEM Overflow break; case 4: // SD16MEM0 IFG ADCresult = SD16MEM0; // Save results (clears IFG) break; } _BIC_SR_IRQ(LPM0_bits); // Exit LPM0 } |
|
|
|
|
[单片机] 相关文章: 单片机开平方的快速算法简介:
单片机开平方的快速算法 因为工作的需要,要在单片机上实现开根号的操作。目前开平方的方法大部分是用牛顿 迭代法。我在查了一些资料以后找到了一个比牛顿迭代法更加快速的方法。不敢独享,介 绍给大家,希望会有些帮助。 1.原理 因为排版的原因,用pow(X,Y)表示X的Y次幂,用B[0],B[1],...,B[m-1]表示一个序列, 其中[x]为下标。 假设: B[x],b[x]都是二进制序列,取值0或1。 M =&n...... 关于指针函数的范例
怎样在我的源程序中实现软件复位?
AT89C2051单片机驱动步进电机的电路和源码
c51控制双色点阵左移显示与右移显示.
用PIC写高效的位移操作
一个高效的模拟SPI的读写函数
PIC8位在PICC中的数据类型
转:CRC算法原理及C语言实现
初浅研究PIC之延时函数和循环体优化 |
|
|
|