Jump to content
43oh

MSP430F149 Timer A capture


Recommended Posts

My synth used Timer A in capture mode if you don't mind having to wade through all the unrelated stuff.

 

viewtopic.php?f=9&t=513&start=10#p5281

 

I think this is the important part:

 

P1SEL |= PIN_MIDI_DATA; // Timer A capture input

TACCTL1 |= CCIE + CAP + CM_3; // enable capture and interrupt on rising and falling edge

 

...

 

// CCR1 capture interrupt. Triggers on both edges, adds fresh midi data

#pragma vector=TIMERA1_VECTOR

__interrupt void CCR1_interrupt(void){

TAR = 0;

TACCTL0 &= ~CCIFG;

unsigned int tEdge = TACCR1;

midiRXBitState = PIN_MIDI_DATA & P1IN;

TAIV = 0;

 

addBits(tEdge, !midiRXBitState);

}

Link to post
Share on other sites

This will help me also. Can you comment what is going on in the ISR below.

 

// CCR1 capture interrupt. Triggers on both edges, adds fresh midi data

#pragma vector=TIMERA1_VECTOR

__interrupt void CCR1_interrupt(void){

TAR = 0;

TACCTL0 &= ~CCIFG;

unsigned int tEdge = TACCR1;

midiRXBitState = PIN_MIDI_DATA & P1IN;

TAIV = 0;

 

addBits(tEdge, !midiRXBitState);

}

 

Thanks a bunch!

Link to post
Share on other sites

#pragma vector=TIMERA1_VECTOR

__interrupt void CCR1_interrupt(void){
//needed for capture **
TAR = 0;   //clears TAR to 0-- reset counter**

TACCTL0 &= ~CCIFG; //clear Interrupt flag in capture 0 register**

unsigned int tEdge = TACCR1;  //captured count  goes into tEdge varible **


midiRXBitState = PIN_MIDI_DATA & P1IN;  //check pin for state---

TAIV = 0;  //clear main interrupt flag -

addBits(tEdge, !midiRXBitState); ///looks like it just ads bits together but i have no idea.....

}

 

natureTM correct me if i am wrong pn the comments

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...