MSP430 Comparator
MSP430 Comparator
MSP430 Comparator
--PRASANNA KUMAR M
-
MSP430 Comparator Registers
CBCTL1: Comparator_B Control Register – 1
Switch ON Comparator module
Comparator can be configured
using CBON bit
to operate in these modes
Exchange inputs:
•Comparator input selected by CBIMSEL will
be available at +ve input of comparator and
•Comparator input selected by CBIPSEL will
be available at -ve input of comparator
•Output is inverted.
Comparator o/p:
= 1 if V+ve input > V-ve input, while CBEX = 0
= 0 if V+ve input > V-ve input, while CBEX = 1
MSP430 Comparator Registers
CBCTL2: Comparator_B Control Register – 2
Option of selecting Shared
Using resistor divider network,
reference voltage
select the required reference
voltage CBREF1
3.3V
P1.0
P6.0/A0/CB0
+
5K Pot - CBOUT
Reference
Voltage
Generator
MSP430F5529
MSP430 Comparator Program example
In <msp430F5529.h> Wait for reference voltage generator to
CBIPEN = 0x0080 and CBIPSEL0 = 0x0000 get stabilized
So, CBCTL0 = 0x00800 #include <msp430F5529.h>
This will configure comparator module int main (void)
{
enabling +ve terminal and Selecting CB0 WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P1DIR |= 0x01; // P1.0 output
comparator input.
CBCTL0 |= CBIPEN + CBIPSEL0; // Enable comperator_B +Ve input and select CB0 input
In <msp430F5529.h> CBPWRMD_1 = CBCTL1 |= CBPWRMD_1;
CBCTL2 |= CBRSEL + CBRS0 + CBREF0_7;
// Configure comparator_B to operate in Normal mode
//Comperator_B Internal Ref.0(CBREF0),
0x0100 //Select 7, ; 8/32; 3.3 * 8 /32 = 0.50V