This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hello,
I have an issue in slow reaction time of Comparator_A+, so I be happy for some answers. Reaction time is between 15 - 10 us and this is too much for my application. I`m using MSP430G2542 microcontroller.
This is code that I use:
int main(void) {
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
P1DIR |= 0x01; // Set P1.0 to output direction
CACTL1 = CAON + CARSEL + CAREF0;
CACTL2 = P2CA4 + CAF; //input V+ i P1.1 with output filter
for(;;) {
if(CACTL2 & CAOUT)
{
P1OUT |= 0x01;
}else
{
P1OUT &= ~0x01;
}
}
Thanks, ŽM
Ziga,
in general when expecting a fast response to an event you should use interrupts. In your small program this may not make a huge difference because there is nothing else to do, but polling a flag isn't a good idea for time critical things.
You can speed up your reaction time by increasing the clock frequency of the processor. When you do not initialize the DCO it runs with roughly 1MHz or even lower. You can set it to 16MHz (maximum) by writing
DCOCTL = CALDCO_16MHZ; // DCOCTL calibration data for 16MHz BCSCTL1 = CALBC1_16MHZ; // BCSCTL1 calibration data for 16MHz
Dennis
**Attention** This is a public forum