Jump to content

Search the Community

Showing results for tags 'timera'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • News
    • Announcements
    • Suggestions
    • New users say Hi!
  • Spotlight!
    • Sponsor Spotlight
    • Sponsor Giveaways
  • Energia
    • Energia - MSP
    • Energia - TivaC/CC3XXX
    • Energia - C2000
    • Energia Libraries
  • MSP Technical Forums
    • General
    • Compilers and IDEs
    • Development Kits
    • Programmers and Debuggers
    • Code vault
    • Projects
    • Booster Packs
    • Energia
  • Tiva-C, Hercules, CCXXXX ARM Technical Forums
    • General
    • SensorTag
    • Tiva-C, Hercules, CC3XXX Launchpad Booster Packs
    • Code Vault
    • Projects
    • Compilers and IDEs
    • Development Kits and Custom Boards
  • Beagle ARM Cortex A8 Technical Forums
    • General
    • Code Snippets and Scripts
    • Cases, Capes and Plugin Boards
    • Projects
  • General Electronics Forum
    • General Electronics
    • Other Microcontrollers
  • Connect
    • Embedded Systems/Test Equipment Deals
    • Buy, Trade and Sell
    • The 43oh Store
    • Community Projects
    • Fireside Chat
  • C2000 Technical Forums
    • General
    • Development Kits
    • Code Vault
    • Projects
    • BoosterPacks


There are no results to display.

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start



Website URL





Found 2 results

  1. I'm trying to find the frequency of an incoming signal. I set the incoming signal (sine wave = 162 MHz, amp=3V) as the clock for TimerA0. TimerA2 will be used to keep count in order to calculate the frequency. Once the freq is calculated I'm setting the DCO for the SMCLK. Frequency should be around 20 MHz. The TIMER_A2 ISR is not accessed at all. Not sure if the correct ISR is being used or even if this is the best/simplest way to find the frequency. Thanks void main(void) { Port_Mapping(); // Access port mapping code SetVcoreUp (0x01); // Increase Vcore setting to level 3 to support 25MHz. SetVcoreUp (0x02); SetVcoreUp (0x03); WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer /////// Clock Settings for SMCLK and ACLK ////////// UCSCTL1 |= DCORSEL_4; // DCORSEL =4 (12.3 to 28.2 MHz range) UCSCTL4 |= SELM__XT1CLK + SELS__DCOCLK + SELA__XT1CLK; //Selects MCLK, ACLK, SMCLK UCSCTL8 = SMCLKREQEN + ACLKREQEN + MCLKREQEN; /////// Output Pins ///////// P2SEL |=BIT2; // SMCLK Output Pin (ACLK is same pin as TA0CLK input) P2DIR |=BIT2; P1DIR &= ~BIT0; // Input for TA0CLK P1SEL |= BIT0; ///// // TimerA0 Settings (Used with incoming signal from PSTAR) ///// TA0CTL= TASSEL__TACLK + MC__UP + ID_3 + TAIE; //set External clock, up mode, divide by 8, enable interrupt TA0CCTL1 = CM_1 + CAP + OUTMOD_4; // capture on rising edge, capture mode enabled, Toggle output TA0CCTL0 |=CCIE; // capture compare interrupt enable TA0CCR0 = 1000; // 1000 rising edge samples (should take 50 us) 20MHz/(1/50us) /////// TimerA2 Settings (Used to calculate frequency of incoming signal) ///// TA2CTL= TASSEL__ACLK + MC__CONTINUOUS + TAIE; // select ACLK, continuous mode, enable interrupt TA2CCTL1 = CM_1 + CAP + OUTMOD_7; // capture on rising edge, capture mode enabled, output set to reset/set TA2CCTL0 |=CCIE; // capture compare interrupt enable _EINT(); //Global interrupt enable _bis_SR_register(GIE); } /////// Timer_A2 ISR //////// int static timer_count = 0; // Variables used in TIMER ISR int frequency_input; int frequency_output; int n; #pragma vector=TIMER2_A0_VECTOR __interrupt void TIMER_A2 (void) { if (TA0CCR0 == 1) { timer_count++; // Starts count and is associated with TIMER A2 } if (TA0CCR0 == 1000) { //// Configure SMClK based on timer_count result //// frequency_input = 1000/timer_count; // Calculation of input frequency based on 1000 rising edges frequency_output = frequency_input/32768; // Multiplier calculation for DCOCLK register for SMCLK frequency n = frequency_output - 1; // variable for register setting of DCOCLK UCSCTL2 = n; // for DCOCLK frequency multiplier used by SMCLK P4DIR |= BIT7; // LED 2 turns on to verify ISR is being accessed P4SEL &= ~BIT7; timer_count = 0; // Reset timer_count for next TA0CCR0 up count } }
  2. Hello, I'm a beginner so I think the answer is simple. I have an HC-SR04 connected to 4 AA batteries at 5.4V. The echo from the ultrasonic sensor goes through a voltage divider with 20k and 10k ohm resistors before going into P1.1. My f2013 is being powered by the usb programming tool and is using P1.2 as the out/trigger pin for the hc-sr04. I beleive the sr04 can take a 3.3V trigger. This is my code below, I just can't figure out why my interrupt isn't triggering. I borrowed some code from the internet. I can't remember his username, but the guy with the wall racer with two hc-sr04's. For quick reference: F2013 Datasheet #define LED0 BIT0 #define ECHO BIT1 #define TRIG BIT2 #include <msp430f2013.h> volatile unsigned distance_in_cm=0; volatile unsigned int start_time; volatile unsigned int total_time; volatile unsigned int up=0; void main(void) { //setup ports, cpu speed, timers //send 2 microseconds of off to p1.1 //send 10 microseconds of on to p1.1 //wait 60 microseconds // listen and count time on p1.0 //distance in cm is counted time/58 WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer BCSCTL1 = CALBC1_1MHZ; DCOCTL = CALDCO_1MHZ; //set speed to 1 megahertz TACTL = 0; //stop the clock P1DIR = (LED0 + TRIG); // set all of P1.0 P1.2 to output and P1.1 to input P1SEL = ECHO; //select echo pin as input for timerA TACCTL0 |= CM_3 + SCS + CAP + CCIE + CCIS_0; //capture rising and falling edge, syncronize(always do this),capture mode, interrupt enabled TACTL = TASSEL_2 + ID_0 + MC_2; // SMCLK,/1, continuous up mode, clear _BIS_SR(GIE); // general interrupt enable while (1) { volatile unsigned int i = 0; up = 1; //Next catch on Timer1A0 should be rising edge - helps with capture timer P1OUT |= TRIG; //turn trig on _delay_cycles(20); //double the required 10 microseconds for good measure //TODO set to 10 again if possible P1OUT &= ~TRIG; //turn trig off _delay_cycles(60000); //wait 60ms before testing again. the interrupt should happen somewhere here } } #pragma vector=TIMERA0_VECTOR __interrupt void timerA0 (){ if (up){ start_time = TACCR0; } else { total_time = TACCR0 - start_time; distance_in_cm = total_time/58; if (distance_in_cm < 20){ P1OUT |= LED0; } else{ P1OUT &= ~LED0; } } up=!up; //if this was the rising edge, the next one will be a falling edge, and vice-versa TA0CTL &= ~TAIFG; //clear timer A interrupt flag, so the chip knows we handled the interrupt TACCTL0 &= ~CCIFG;//clears capture interrupt flag, should already be done automatically though TODO } /* #define MC_0 (0*0x10u) Timer A mode control: 0 - Stop #define MC_1 (1*0x10u) Timer A mode control: 1 - Up to CCR0 #define MC_2 (2*0x10u) Timer A mode control: 2 - Continous up #define MC_3 (3*0x10u) Timer A mode control: 3 - Up/Down #define ID_0 (0*0x40u) Timer A input divider: 0 - /1 #define ID_1 (1*0x40u) Timer A input divider: 1 - /2 #define ID_2 (2*0x40u) Timer A input divider: 2 - /4 #define ID_3 (3*0x40u) Timer A input divider: 3 - /8 #define TASSEL_0 (0*0x100u) Timer A clock source select: 0 - TACLK #define TASSEL_1 (1*0x100u) Timer A clock source select: 1 - ACLK #define TASSEL_2 (2*0x100u) Timer A clock source select: 2 - SMCLK #define TASSEL_3 (3*0x100u) Timer A clock source select: 3 - INCLK #define CCIS_0 (0*0x1000u) Capture input select: 0 - CCIxA #define CCIS_1 (1*0x1000u) Capture input select: 1 - CCIxB #define CCIS_2 (2*0x1000u) Capture input select: 2 - GND #define CCIS_3 (3*0x1000u) Capture input select: 3 - Vcc #define CM_0 (0*0x4000u) Capture mode: 0 - disabled #define CM_1 (1*0x4000u) Capture mode: 1 - pos. edge #define CM_2 (2*0x4000u) Capture mode: 1 - neg. edge #define CM_3 (3*0x4000u) Capture mode: 1 - both edges */
  • Create New...