Search the Community

Showing results for tags 'frequency'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • 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

Calendars

There are no results to display.


Found 5 results

  1. I'm new to MSP430 and I'm trying to do a frequency/period measurement. I've read about timers and get the main concepts though I'm still learning. To get an idea of how they work, I'm using this code. It outputs a PWM on one pin which I connect to another pin for capturing period: http://coecsl.ece.illinois.edu/ge423/datasheets/MSP430Ref_Guides/Cexamples/MSP430G2xx3 Code Examples/C/msp430g2xx3_ta_21.c After making some modifications (removing unneeded code to light led and adding calculations for frequency) it works with the original pins. However, I want to change which input pin will take measurements. I want pin 2.0 to do so. Currently, TimerA0 captures and TimerA1 outputs PWM. Since PIN 2.0 uses TimerA1 and not A0, I assumed I would just need to flip the timers and pins. However, it's not working. I looked at the datasheet and can't figure out whats wrong. What am I missing? Here is my code: #include <msp430.h> unsigned char Count, First_Time; unsigned int REdge1, REdge2, FEdge; int main(void) { unsigned int Period, ON_Period; unsigned char DutyCycle; WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer // P1SEL |= BIT0; if (CALBC1_8MHZ==0xFF) // If calibration constant erased { while(1); // do not load, trap CPU!! } DCOCTL = 0; // Select lowest DCOx and MODx settings BCSCTL1 = CALBC1_8MHZ; // Set DCO to 8MHz DCOCTL = CALDCO_8MHZ; // Configure Port Pins P1DIR |= BIT2; // P2.1/TA1.1 Output P1SEL |= BIT2; // TA1.1 Option select P2DIR &= ~BIT0; // P1.1/TA0.1 Input Capture P2SEL |= BIT0; // TA0.1 option select // Configure TA1.1 to output PWM signal // Period = 82/32khz = 2.5ms ~ 400Hz Freq TA0CCR0 = 82-1; // Period Register TA0CCR1 = 21; // TA1.1 25% dutycycle TA0CCTL1 |= OUTMOD_7; // TA1CCR1, Reset/Set TA0CTL = TASSEL_1 + MC_1 + TACLR; // ACLK, upmode, clear TAR // Configure the TA0CCR1 to do input capture TA1CCTL1 = CAP + CM_3 + CCIE + SCS + CCIS_0; // TA0CCR1 Capture mode; CCI1A; Both // Rising and Falling Edge; interrupt enable TA1CTL |= TASSEL_2 + MC_2 + TACLR; // SMCLK, Cont Mode; start timer // Variable Initialization Count = 0x0; First_Time = 0x01; while(1) { __bis_SR_register(LPM0_bits + GIE); // Enter LPM0 __no_operation(); // For debugger // On exiting LPM0 if (TA1CCTL1 & COV) // Check for Capture Overflow while(1); // Loop Forever Period = REdge2 - REdge1; // Calculate Period ON_Period = FEdge-REdge1; // On period DutyCycle = ((unsigned long)ON_Period*100/Period); } } // TA0_A1 Interrupt vector #pragma vector = TIMER1_A1_VECTOR __interrupt void TIMER1_A1_ISR (void) { switch(__even_in_range(TA1IV,0x0A)) { case TA1IV_NONE: break; // Vector 0: No interrupt case TA1IV_TACCR1: // Vector 2: TACCR1 CCIFG if (TA1CCTL1 & CCI) // Capture Input Pin Status { // Rising Edge was captured if (!Count) { REdge1 = TA1CCR1; Count++; } else { REdge2 = TA1CCR1; Count=0x0; __bic_SR_register_on_exit(LPM0_bits + GIE); // Exit LPM0 on return to main } if (First_Time) First_Time = 0x0; } else { // Falling Edge was captured if(!First_Time) { FEdge = TA1CCR1; } } break; case TA1IV_TACCR2: break; // Vector 4: TACCR2 CCIFG case TA1IV_6: break; // Vector 6: Reserved CCIFG case TA1IV_8: break; // Vector 8: Reserved CCIFG case TA1IV_TAIFG: break; // Vector 10: TAIFG default: break; } } I checked and there is a pulse going into P2.0 but P2.0 is not capturing it. Is it just not possible with this pin or am I missing something obvious?
  2. Hi, I tried my hand for the first time on a servo and my experience may be helpful to other people. Servos are controlled by the length of a pulse. This pulse is repeated ca. every 20mS. The pulse length can vary coarsly between 1 and 2 mS. The pulse length determines the rotation angle. If the servo starts up, it goes to a middle position, corresponding to a ca. 1.5 mS pulse. For shorter pulses the servo turns in one direction, for longer pulses to the other. The range is limited, mostly to +/- 90 degree, the accurate values depend on the servo, as does the min/max widths. Mine had a range of a bit more than 180 degree for a min pulse width of 680 uS and a max width of 2.62 mS. However, you should not use these values but allow for some safety margin. Otherwise the motor may just not reach (e.g. due to slip or play) the position and the motor tries hard and gets hot. Most servos have 3 wires that are color coded from bright to dark, the color may change. The brightest is the signal pin where the pulses are fed. The middle one, mostly red, goes to Plus and the darkest one (brown, black..) goes to ground. Energia comes with a helpful server library. There an object: "Servo" is declared. You initiated the server by the method "attach". It comes in 2 varieties (assuming we declared an object "myservo"): myservo.attach(pinNo); myservo.attach(pinNo,minVal,maxVal); where pinNo means the launchpad pin number of the pin used to control the servo. min/maxVal are the minimal/maximal pulse width you want to use. This is not clearly described in the library and confused me bit. In further commands you can confortably deal with degrees beween 0 and 180. The library will transform the degree values into pulse widths, where 0 degree corresponds to the minimal pulse width and 180 degree to the max you specified. If you do not specify min/max values, some default values are used. In may case the lower default value could not be reached and the motor got hot. Therefore, it is better to determine correct values and specify these, using the second form of "attach". After initialization the servo goes to the 90 degree position. To send it to the 0 degree positio you would write: myservo.write(0); My servo did not respond quit linear. To send it to the 90 degree position I had to say 83 degree. Here is a small test program: // test for 9g Servo // 1. Button press -> 0 degree // 2. Button press -> 90 degree. Due due nonlinearity we need 83 degree // 3. Button press -> 180 degree. // 4. Button press -> 90 degree. #define sig P1_4 // signal for servo #define but P1_3 // button #define minWidth 770 // min pulse width in uSec of servo (680 allowed) #define maxWidth 2595 // max pulse width in uSec of servo (2620 allowed) #include <Servo.h> Servo myservo; void setup() { myservo.attach(sig,minWidth,maxWidth); pinMode(but, INPUT_PULLUP); } void loop() { while (digitalRead(but)); myservo.write(0); delay(500); while (digitalRead(but)); myservo.write(83);delay(500); while (digitalRead(but)); myservo.write(180);delay(500); while (digitalRead(but)); myservo.write(83); delay(500); } Note that due to nonlinearity of the servo I need to specify 83 degree for a 90 degree rotation. For test purposes you may power the servo directly from the launchpad (provided you do not have a monster servo with a hugh current consumption). In the enclosed picture I control the servo from launchpad pin P1_4 and power it directly from the launchpad. Have fun, Daniel
  3. Just as an FYI - I was concerned about using the built in DCO in the FR5969 for UART because the spec sheet says although it's factory trimmed, it's still +/-3.5%. Generally it needs to be within 2% for a UART to work correctly so I measured the two FR5969's I have on our 2.4GHz frequency counter and this is what I got. 2 is obviously not a big sample size, but the frequency trimmed DCO on the FR series looks pretty good @ room temp and 8MHz or under. I found another doc from TI that's a comparison between F5xxx and FR5xxx and it mentions the DCO is generally within 2% "within a restricted temperature range" and within 3.5 in the full temperature range (-40C to 85C). I may need to re-measure at 4C because that's typically where our project will be operating.
  4. How can I get the sampling frequency of MSP430g2553
  5. How to change the output frequency of the analogWrite() function in Energia??