Jump to content


  • Content Count

  • Joined

  • Last visited

Posts posted by Jonoveve

  1. Hello

    I am working whit msp432 and trying to measure frequency like you, but i have problem with the result, i can't measure more than 32888 Hz and i don't know the problem.




    Would it be possible a little help? someone can see the problem?



    My code is a Energia sketch:

    #include <driverlib.h>
    volatile uint32_t R10=0;
    volatile uint32_t R20=0;
    volatile uint32_t Cont=0;
    const Timer_A_CaptureModeConfig captureModeConfig =
            TIMER_A_CAPTURECOMPARE_REGISTER_1,        // CC Register 1
            TIMER_A_CAPTUREMODE_RISING_EDGE,          // Rising Edge
            TIMER_A_CAPTURE_INPUTSELECT_CCIxB,        // CCIxB Input Select
            TIMER_A_CAPTURE_SYNCHRONOUS,              // Synchronized Capture
            TIMER_A_CAPTURECOMPARE_INTERRUPT_ENABLE,  // Enable interrupt
    void TA1_0_IRQHandler(void)
      MAP_Timer_A_clearCaptureCompareInterrupt(TIMER_A1_BASE, TIMER_A_CAPTURECOMPARE_REGISTER_0); //clear
    void TA2_0_IRQHandler(void)
      MAP_Timer_A_clearCaptureCompareInterrupt(TIMER_A2_BASE, TIMER_A_CAPTURECOMPARE_REGISTER_1); //clear
    void setup()
      MAP_CS_initClockSignal(CS_SMCLK,CS_HFXTCLK_SELECT,CS_CLOCK_DIVIDER_4);      //Set system clock 12 MHz
      //Set GPIO 4.2 as timer
      MAP_GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P4, GPIO_PIN2, GPIO_PRIMARY_MODULE_FUNCTION);
      // Timer TA1 SMCLK/1
      TA1CTL = TASSEL_2;
      TA1CCTL0 = CCIE;
      TA1CCR0 = 60000;
      // Timer TA2 capture mode (CC Register 1, Rising Edge, CCIxB Input Select, Synchronized Capture, Enable interrupt)
      MAP_Timer_A_initCapture(TIMER_A2_BASE, &captureModeConfig);
      //Register interrupts
      MAP_Timer_A_registerInterrupt(TIMER_A2_BASE,TIMER_A_CCRX_AND_OVERFLOW_INTERRUPT, TA2_0_IRQHandler);
      MAP_Timer_A_registerInterrupt(TIMER_A1_BASE,TIMER_A_CCR0_INTERRUPT, TA1_0_IRQHandler);
    void loop()
      Serial.print(R20); //Timer A2 count
      Serial.print(" ");
      R10 = 0;
      R20 = 0;
      TA1R = 0; // clear timer counter
      TA2R = 0; // clear timer counter
      MAP_Timer_A_startCounter(TIMER_A2_BASE, TIMER_A_CONTINUOUS_MODE); //Star timers
      MAP_Timer_A_startCounter(TIMER_A1_BASE, TIMER_A_UP_MODE);
      while (R10 !=200 ){} // wait
      TA2CTL &= ~MC0; // stop timers
      TA1CTL &= ~MC1;

    If i get to measure frequency before that your replies, i will share the code with everyone.

    I will be working.


    Thank you for all.

  2. Hello.

    I have a quartz oscillator with fo=1.6 MHz and I have changed it features and now it band width is around 20 kHz. For this, i need to a good precision.

    I am using the board msp430fr6989.


    My code is the next:

    #include <CounterLib_t.h>
    Counter<CL_TimerB0> MyCounter; //pin P2.0
    void setup() {
      MyCounter.start(CL_Div2); // 2 pulses 
    void loop()
        Serial.print((MyCounter.read()+32767.5*23)*2+32800);  //32765.5 = 65535/2          **CL_Div2**
                                                              //(MyCounter.read()+...)*2   **CL_Div2**
                                                              //32800 manual calibrate 
        Serial.println(" Hz");

    With this code i get:

    - From frequency generator: F=1.58 MHz     -> Measure with the board: F=1579589 Hz     -> Error: 0.026%

    - From frequency generator: F=1.6 MHz       -> Measure with the board: F=1600093 Hz     -> Error: 0.0058%

    - From frequency generator: F=1.62 MHz     -> Measure with the board: F=1620377 Hz     -> Error: 0.023%


    The total BW is 127000 Hz

    - From 1,542 MHz with error=0.077% to 1,669 MHz with error=0,074


    For my proyect is a good precision.


    I put images like a sample.




  3. Hello.


    I need to measure a frequency from output VCO with a Timer, this frequency is between 1 MHz and 2 MHz.


    Whit my other board i don't have any problem because i can use de library ''CounterLib'' for MSP430 with Energia.


    Can i use any library for TivaC for use like a ''CounterLib'' with Energia?


    Best Regard.





    You can use analogResolution() to set the PWM resolution. Note that this is tied with the analogFrequency() by default it is set to ~490 Hz (F_CPU/490).

    This means that for the MSP430FR6989 running at 16 Mhz the max you can count up to is 16 MHz/490 = 32653 which is your max resolution.



    #define PWM_PIN 11
    #define PWM_FREQ 490 // the default
    #define PWM_RES (F_CPU / PWM_FREQ)
    void setup() {
      /* set the PWM frequency */
      /* set the PWM resolution */
      /* 490 Hz / 50% duty cycle on pin 11 */
      analogWrite(11, PWM_RES/2); 
    void loop() 

    Thanks you very much. it was what i want.

  5. Hello.


    I am trying to change the output PWM resolution in my board for feed a VCO .

    With enegia i can use 8 bits resolution but in the datasheet i can see that the output PWM resolution is 16 bits.


    I have read this Topic http://forum.43oh.com/topic/5765-analogwrite-precision-question/ they use PWMWrite(Pin,Steps,duty cycle,Frequency) but, with msp430 it does not work.


    There are any solution to increase the resolution of PWM output for msp430 like in Tiva C?



    Best Regards.


  • Create New...