Quantcast
Channel: MSP430 Technical Forums
Viewing all articles
Browse latest Browse all 2077

Using interrupts with comparator A+

$
0
0

Hi everione.

I'm trying to use the internal comparator since i need sometigh a bit faster than the ADC and it just needs to reach a point.

 

My problem is using the interrupt. I saw 1 or 2 examples in C assembly.

Also noticed a problem in energia so i'm aware of the rising interrupt issue: http://forum.43oh.com/topic/3214-how-to-using-attachinterrupt/

 

I don't know how to work with interrupts in assembly. So i though of using the comparator output pin with attachInterrupt();

Problem is there is 2 outputs in msp430g2553. Wich one is it? Or can i just use the register CAOUT like this:

boolean estado=0;
boolean estado2=0;

void setup(){
  pinMode(P1_0,OUTPUT);
  
  CACTL1 = 0000110;              // normal; V+; sem referencia; On; Falling; no interrupt pending 
  CACTL2 = 01001000;             //no short; CA4; CA1; no cap; 
  
  attachInterrupt(CAOUT, func, FALLING);
}

void loop(){ 
  if (estado2!=estado){
    digitalWrite(P1_0,estado);
    delay(100);
  }
}

void func(){
  estado2=estado;
  estado=!estado;
}

Viewing all articles
Browse latest Browse all 2077

Trending Articles