chicken 630 Posted October 13, 2015 Author Share Posted October 13, 2015 @@altineller The timer/counters can be fed from various clocks. From the MSP430x2xx Family User's Guide: The library currently only uses the external clock (TACLK), but with a small change this can be changed to an internal source. The relevant bits are TASSELx (9 and 8) in the register TACTL. From the MSP430x2xx Family User's Guide: TASSELx Bits 9-8 Timer_A clock source select 00 TACLK 01 ACLK 10 SMCLK 11 INCLK (INCLK is device-specific and is often assigned to the inverted TBCLK) (see the devicespecific data sheet) Simply add those bits when my library starts the timer, e.g. around line 115 for the MSP430G2553: // configure timer A0 to count upwards based on TA0CLK input // halt timer, disable interrupts, TACLK clock source, reset counter TACTL = TACLR | divider1_bits; // clears MCx, TAIE, TASSEL TACTL |= BIT8; // set ACLK as timer input I don't know what speeds ACLK and SMCLK are setup by Energia, so you will probably have to play with with dividers and/or adjust your original code a bit. Officially supporting internal clocks as input is actually a good idea and I might add it in the future. Quote Link to post Share on other sites
chicken 630 Posted October 13, 2015 Author Share Posted October 13, 2015 RE clock speed in Energia: Looking at the source (wiring.c), SMCLK seems to be running at CPU clock. Not quite sure what ACLK is set to. I think it's the external crystal, or internal LFO (8KHz or thereabouts) if there's no crystal. Quote Link to post Share on other sites
StevenSegal 0 Posted December 12, 2015 Share Posted December 12, 2015 Is there a way of sampling an analog input (audio signal) and processing the signal with the on board ADC for input into this particular frequency counter on the F5529? Quote Link to post Share on other sites
Fmilburn 445 Posted December 12, 2015 Share Posted December 12, 2015 Hi @@StevenSegal @@chicken will surely have a better answer than me but here are some thoughts. First, CounterLib is a digital counter. It will count every time the signal cycles LOW to HIGH. So, if that is what you are looking for it might work for you. Can you supply additional information on the signal and what you are trying to do with it? Is it a 0-3 V signal? Are you only interested in when it goes above a threshold? StevenSegal 1 Quote Link to post Share on other sites
StevenSegal 0 Posted December 13, 2015 Share Posted December 13, 2015 @@Fmilburn Yes I am looking for some type of counter that increments by the signal being equal to some threshold. I have revamped my initial question in a new thread seen HERE Quote Link to post Share on other sites
Jonoveve 4 Posted February 22, 2016 Share Posted February 22, 2016 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 Serial.begin(9600); } void loop() { MyCounter.reset(); delay(1000); 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"); Serial.println(cont); delay(1000); } 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. chicken, dubnet and Fmilburn 3 Quote Link to post Share on other sites
erharishkrs 0 Posted March 12, 2016 Share Posted March 12, 2016 please provide the support for msp430fr4133. I want to run it on my msp430fr4133 launchpad. Quote Link to post Share on other sites
Fmilburn 445 Posted March 12, 2016 Share Posted March 12, 2016 @@erharishkrs I don't have a FR4133 so can't test the code but try this: #elif defined(__MSP430FR4133__) enum CL_TIMER_t { CL_TimerA0, // FR4133 P1.5, pin 11 on LaunchPad CL_TimerA1, // FR4133 P8.2, pin 9 on LaunchPad }; // clk pin setup for each supported timer #define CL_TA0CLK_PIN_SETUP { P1DIR &= ~BIT5; P1SEL0 &= ~BIT5; P1SEL1 |= BIT5; } #define CL_TA1CLK_PIN_SETUP { P8DIR &= ~BIT2; P8SEL0 &= ~BIT2; P8SEL1 |= BIT2; } Insert it into CounterLib_t.h just before the section at line 72 with the following code #else #error 1) This microcontroller is not supported by CounterLib #endif If, in my haste, I did this correctly it should work with the examples on Pin 11 of the FR4133. Please report back whether or not this works for you. tripwire and chicken 2 Quote Link to post Share on other sites
chicken 630 Posted March 14, 2016 Author Share Posted March 14, 2016 I noticed that the library attached to the first post was a bit out of date. I replaced the ZIP file with a link to GitHub and also updated the table of supported devices. I will include the FR4133 once someone confirms that it's working. Quote Link to post Share on other sites
erharishkrs 0 Posted March 15, 2016 Share Posted March 15, 2016 @@Fmilburn After editing for msp430fr4133 in the counterLib it is showing compilation error- In member function 'void Counter<timer>::start(CL_DIVIDER_t, uint8_t)': 'P1SEL1' & 'P8SEL1' were not declared in this scope Quote Link to post Share on other sites
erharishkrs 0 Posted March 15, 2016 Share Posted March 15, 2016 @@erharishkrs I don't have a FR4133 so can't test the code but try this: #elif defined(__MSP430FR4133__) enum CL_TIMER_t { CL_TimerA0, // FR4133 P1.5, pin 11 on LaunchPad CL_TimerA1, // FR4133 P8.2, pin 9 on LaunchPad }; // clk pin setup for each supported timer #define CL_TA0CLK_PIN_SETUP { P1DIR &= ~BIT5; P1SEL0 &= ~BIT5; P1SEL1 |= BIT5; } #define CL_TA1CLK_PIN_SETUP { P8DIR &= ~BIT2; P8SEL0 &= ~BIT2; P8SEL1 |= BIT2; } Insert it into CounterLib_t.h just before the section at line 72 with the following code #else #error 1) This microcontroller is not supported by CounterLib #endif If, in my haste, I did this correctly it should work with the examples on Pin 11 of the FR4133. Please report back whether or not this works for you. After editing for msp430fr4133 in the counterLib it is showing compilation error- In member function 'void Counter<timer>::start(CL_DIVIDER_t, uint8_t)': 'P1SEL1' & 'P8SEL1' were not declared in this scope Quote Link to post Share on other sites
Fmilburn 445 Posted March 15, 2016 Share Posted March 15, 2016 @@erharishkrs OK, I just tried it and got the error as well. I don't use the FR4133 and don't know what is going on. The family guide has PxSEL1 but they aren't in the header file. So, not sure whether I am misinterpreting things or not. Maybe someone else familiar with it can have a look? Quote Link to post Share on other sites
Anik96 1 Posted January 25, 2018 Share Posted January 25, 2018 Hello, can anyone help me to configure this library for TM4C123G launchpads ?? they have 80MHz clock speed. I want to measure upto 20MHz frequency( simple square wave with 50% duty cycle). Quote Link to post Share on other sites
Fmilburn 445 Posted January 26, 2018 Share Posted January 26, 2018 Hello @Anik96 The TM4C123G is an ARM processor and differs in both timers and registers from the MSP430 but read through chicken’s posts here: He describes clearly how to do it but you will need to account for the difference in processors. Quote Link to post Share on other sites
Anik96 1 Posted January 26, 2018 Share Posted January 26, 2018 Thanks for the reply. Is there any way to read/write registers directly in energia? Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.