Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. /* --COPYRIGHT--,BSD_EX
  2. * Copyright (c) 2012, Texas Instruments Incorporated
  3. * All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions
  7. * are met:
  8. *
  9. * * Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. *
  12. * * Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. *
  16. * * Neither the name of Texas Instruments Incorporated nor the names of
  17. * its contributors may be used to endorse or promote products derived
  18. * from this software without specific prior written permission.
  19. *
  20. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  21. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  22. * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  23. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  24. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  25. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  26. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  27. * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  28. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  29. * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  30. * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. *
  32. *******************************************************************************
  33. *
  34. * MSP430 CODE EXAMPLE DISCLAIMER
  35. *
  36. * MSP430 code examples are self-contained low-level programs that typically
  37. * demonstrate a single peripheral function or device feature in a highly
  38. * concise manner. For this the code may rely on the device's power-on default
  39. * register values and settings such as the clock configuration and care must
  40. * be taken when combining code from several examples to avoid potential side
  41. * effects. Also see www.ti.com/grace for a GUI- and www.ti.com/msp430ware
  42. * for an API functional library-approach to peripheral configuration.
  43. *
  44. * --/COPYRIGHT--*/
  45. //******************************************************************************
  46. // MSP430G2x13/G2x53 Demo - Comp_A, Output Reference Voltages on P1.1
  47. //
  48. // Description: Output Comparator_A reference levels on P1.1. Program will
  49. // cycle through the on-chip comparator_A reference voltages with output on
  50. // P1.1. Normal mode is LPM0, TA0_ISR will interrupt LPM0.
  51. // ACLK = n/a, MCLK = SMCLK = default DCO
  52. //
  53. // MSP430G2x13/G2x53
  54. // -----------------
  55. // /|\| XIN|-
  56. // | | |
  57. // --|RST XOUT|-
  58. // | |
  59. // | P1.1/CA1|--> Vref
  60. // | |
  61. //
  62. // D. Dang
  63. // Texas Instruments Inc.
  64. // December 2010
  65. // Built with CCS Version 4.2.0 and IAR Embedded Workbench Version: 5.10
  66. //******************************************************************************
  67.  
  68. #include <msp430.h>
  69.  
  70. void delay(void); // Software delay
  71.  
  72. int main (void)
  73. {
  74. WDTCTL = WDTPW + WDTHOLD; // Stop WDT
  75. CACTL2 = P2CA4; // CA1/P1.1 = +comp
  76. CCTL0 = CCIE; // CCR0 interrupt enabled
  77. TACTL = TASSEL_2 + ID_3 + MC_2; // SMCLK/8, cont-mode
  78. _EINT(); // enable interrupts
  79.  
  80. while (1) // Loop
  81. {
  82. CACTL1 = 0x00; // No reference voltage
  83. _BIS_SR(LPM0_bits); // Enter LPM0
  84. CACTL1 = CAREF0 + CAON; // 0.25*Vcc, Comp. on
  85. _BIS_SR(LPM0_bits); // Enter LPM0
  86. CACTL1 = CAREF1 + CAON; // 0.5*Vcc, Comp. on
  87. _BIS_SR(LPM0_bits); // Enter LPM0
  88. CACTL1 = CAREF1 + CAREF0 + CAON; // 0.55V, Comp. on
  89. _BIS_SR(LPM0_bits); // Enter LPM0
  90. }
  91. }
  92.  
  93. // Timer A0 interrupt service routine
  94. #pragma vector=TIMER0_A0_VECTOR
  95. __interrupt void Timer_A (void)
  96. {
  97. _BIC_SR_IRQ(LPM0_bits); // Clear LPM0 bits from 0(SR)
  98. }