/* * timerA_input_capture_example.c * * Created on: 10/9/18 * Author: johnsontimoj */ ////////////////////////////////////// // // Timer A setup to capture on pin 35 // Captures data in an array and then prints // the array out - this is to prevent the printing // from impacting the access to the register // //////////////////////////////////// // // Pin 35 is P6.7 // P6.7 is TimerA_2, Input 4 // // Use SMCLK for timer clock // SMCLK defaults to HSMCLK which defaults to HFXTCLK // all with a default of divide by 1 // --> SMCLK = 3MHz // set divide on the Timer // to get 4us resolution need 3MHz/12 // /12 --> /4/3 // /////////////////////////////////// #include "msp.h" #include void setup_timer(void); int main(){ int data[100]; setup_timer(); int i; for(i=0; i<100; i++){ data[i] = TIMER_A2->CCR[4]; } for(i=0; i<100; i++){ printf("%i\n", data[i]); } return 0; } // end main void setup_timer(void){ // // setup pins // // P6.7 in PSEL=01 mode and set as input P6->SEL0 |= 0x80; P6->SEL1 &= ~0x80; P6->DIR &= ~0x80; // // TIMER_A2 // CTL // SMCLK /4 cont noclr no int // xxxx xx 10 10 10 x 0 0 x TIMER_A2->CTL = 0x02A0; // // EX0 // xxxx xxxx xxxx x /3 // 0000 0000 0000 0 010 TIMER_A2->EX0 = 0x0002; // // CCTL[4] // both CCIxA sync x x cap xxx no int x x x x // 11 00 1 0 0 1 000 0 0 0 0 0 TIMER_A2->CCTL[4] = 0xC900; return; } // end setup_timer