Jump to content

Search the Community

Showing results for tags 'timer'.

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 33 results

  1. Can someone provide a code for implementing a watchdog timer to autoreset in TIVA TM4C1294ncpdt using energia?
  2. Hi, i'm trying to start a pwm signal and stop it after 50 miliseconds. But i can't because i can't use timer interrupt vector properly. my count never increments. Here is my code #include <msp430.h> #include <msp430g2553.h> void startPWM(void); unsigned char counter=0; void stopPWM(void); int main(void) { WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer BCSCTL1 = CALBC1_1MHZ; // Set range DCOCTL = CALDCO_1MHZ; CCTL0 = CCIE; P2DIR |= BIT2; //IR transmitter P2SEL |= BIT2;// Select pwm pin (transmitter) P2OUT=0x00; while(1){ if((P1IN & BIT4)!=BIT4) //button is pressed { startPWM(); //send pwm stopPWM(); // stop after 50 ms } } } void startPWM(void) // pwm signal { TA1CCR0 = 26-1; // Period Register TA1CCR1 = 13; // 50% dutycycle TA1CCTL1 |= OUTMOD_6; // TA1CCR1, Reset/Set TA1CTL = TASSEL_1 + MC_1 + TACLR; } void stopPWM(void) // trying to stop after 50 ms { CCR0 = 5000; // CCR0 5 ms TACTL = TASSEL_2 + MC_2; // } #pragma vector=TIMER0_A0_VECTOR // Timer0_A0 __interrupt void Timer_A (void) { if(++counter==10){ // is counter 10 (5*10=ms) TA1CCR1 = 0; ; // Stop timer so it can't send PWM signal counter = 0; } }
  3. I would like to trigger the sampling from a timer, but somehow cannot find the required information about the ADC12SHS bits in the ADC12CTL1 register. The family manual tells me to look in the specific device datasheet for that information, but I can't find it there (the MSP430F5529 datasheet). Also looked into the mspware C examples, but none uses timer triggered A/D. Where should I look for that info (which timers can be used, and how to set ADC12SHS bits to use them)?
  4. I am developing a timeout / soft timer library for the MSP43x and would like to share it with you. It's still in the initial version, but all the functions are working. I'm developing and testing on MSP430F6736, but it worked fine on launchpad EXP430F5529LP. The library uses a timer to periodically generate ticks. In the base version developed by Felipe Lavratti, the timer-tick occur every 1us through a 32-bit timer (ARM Cotex). To avoid overloading the CPU I modified the code to accept longer time intervals and also functions to automatically calculate the Capture / Compare value of the timer. I also tried to isolate the timer configuration in a separate file, so in the future it would allow to select from more than one timer source or different devices, perhaps with compatibility with the old Value Line uCs. How the objective is not to give a perfect time base in us, I'm using ticks of 100us (10kHz) and works very well. The library has delay, getTime, and Timeout functions, the latter two of which are interesting for managing tasks without holding down processing like a normal delay. The example using the EXP430F5529LP use delay_Ms function to toggle 4 times both leds, geTime_ms() to toggle LED1 every 234ms and timeoutCheck_ms() to toggle LED2 every 1s. Feel free to leave your opinions and contribute to the project - Github of project Thank you.
  5. Hello Guys, Good Day for All. May I ask whether there any library or function for using Timer in energia as in arduino? For example if in arduino we can use Timer1.attachInterrupt() I appreciate your help. Best Regards, Lukman
  6. I need a one example of timer interrupt like timerone.h for arduino, yhank you, for help me!!!
  7. 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?
  8. Hello folks, I recently wrote a library that performs an application requiring using 5 timer modules, leaving the 6th out. I looked through some of energia's source code afterwords in case there would be any conflicts, and I noticed that at least the analog write function utilizes a timer to generate its pwm. I might be able to bypass that since I leave 1 timer open for other usage. Does anyone know what timers energia needs to use in its libraries that would cause conflicts?
  9. Hi, Sorry for the repost, I save my preview topic in the wrong place I think (http://forum.43oh.com/topic/9286-msp432-servo-librairy-conflicting-with-pwm-analogwrite/, if someone can delete this one...). I am using an MSP432P401R launchpad Rev B with Energia 17 on Windows 10. I've recently got this issue: I can't control servomotors with the Servo.h librairy and at the same time send several PWM. As soon as I called the "attach" function from Servo, the others call to analogWrite in my code don't work anymore. I think it is due to some timer conflicts (both functions using A0 timer ?), but I can't figured out how to fix the problem. I see something wierd in the Servo librairy code (in Servo.cpp:72): //timerParams.clockSource = Timer_Source_SMCLK; This instruction, that seems to choose the timer to use, is commented. Moreover I noticed that several defined are not used in the code of Servo (from Servo.h): #define SERVO_TIMER TIMERA0_BASE #define SERVO_TIME_CFG TIMER_CFG_B_PERIODIC | TIMER_CFG_SPLIT_PAIR #define SERVO_TIMER_TRIGGER TIMER_TIMB_TIMEOUT #define SERVO_TIMER_INTERRUPT INT_TIMERA0B #define SERVO_TIMER_AB TIMER_B #define SERVO_TIMER_PERIPH PRCM_TIMERA0 I have tried to modify "A0" by "A1" without success. Did someone run in a similare problem and could give me some clue to fix it ? Thanks Nathan
  10. Hello all together, I need a very accurate timer for a midi clock. For that reason I need a timer, that is giving me for every beat 24 beats back. At hte same time, I need a serial connection with 31250baud. My question is now, how do I get a very, very accurate timer. The timer quarz is normaly 32768, and this is maybe a little bit to slow, becaus I want my bpm with one digit after the point like 121,1bpm. I have a MSP430G2553. Can I connect a 1MHz or even a 4MHz cristal to the
  11. Hi , I have written my scheduler which uses the Timer0 subtimer A to generate interrupt for Multi-tasking. I have tested the waverforms generating accurately and arriving at the right time periods. Now the issue that I am facing is PWM waves are not arrived at the expected time. Is PWM interfere with the Timer functionality? What is the work around? Are there any free timers available which I can use it for my scheduler? Some insights to this would really help. Thanks, Peeyush
  12. Hi everyone. I just got a cc3200 launchpad and am coding on a Mac with Energia. I'm impressed with what this setup can do. I'm trying to get a handle on how on how to how to use the timer functions to create one-shots or functions called at specific intervals. I can find references in Energia.h and driverlib/timer.h but no docs or samples. If anyone has any tips on getting started please pass them on, I'd appreciate it. Looking forward to coding... - eric
  13. Hi all, I am facing problem while reading DHT values in timer ISR function. I am able to get the data if use i dht.readHumidity() (using dht library) in loop function but not able to get when i use in timer ISR function. Can anyone please help me out. Thanks in Advance.
  14. Hello all. I'm new to CC3200 and trying to develop an application for the launchpad using a Timer. Energia has the timer.h module, and I've found TI's documentation for the General Purpose Timer module, along with a few code snippets. My code dies when calling TimerConfigure(base, type). I think that this is because the timer peripherals need need to be enabled as a system peripheral before they can be manipulated. It looks like SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMERx) is what you'd call before calling the TimerXxx functions. However, the cc3200 driverlib doesn't have a sysctl.h (or .c), and thus the method is not available. Is there an alternate approach to using the timer facilities? Thanks for any insights! - eric
  15. All, Here is me again struggling with the timer. What I am trying to do is count to CCR0, passing through CCR1, generating interrupts when timer overflows and when it reaches CCR1 value as well. From TI examples I had understood I should set up something like this, adding code to the appropriate "switch" cases: #pragma vector=TIMERA1_VECTOR __interrupt void Timer_A(void) { switch( TAIV ) { case 2: break; // CCR1 not used case 4: break; // CCR2 not used case 10: P1OUT ^= 0x01; // overflow break; } } Well, it is getting to the ISR no problem, but at all times TAIV = 0x000A (10). Even then, the code in the "case 10" statement is not executed. Also, it seems like the interrupt is not being called when the counter reaches CCR1. Here is the full code. I have commented out my original code in the ISR (which was supposed to toggle the led in P1.0 when counter reached CCR1, and P1.6 when timer overflows). I tried both hexa and decimal numbers in the "case" statements. The part not commented is copied straight from TI's example (msp430x20x3_ta_03, see see slac163 and slaa428) without any changes. Am I doing something fundamentally wrong? Is my intent to do something when timer reaches both CCR0 and CCR1 possible at all? #include <msp430.h> #include <stdlib.h> int main( void ) { //---------------- // // Hardware config // //---------------- // WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer // DCO configuration DCOCTL = CALDCO_1MHZ; //Set DCO to 1 MHz BCSCTL1 = CALBC1_1MHZ; // Calibrate internal clock for 1 MHz // Port 1 configuration P1DIR |= BIT0 + BIT2 + BIT6; P1SEL |= BIT2; P1OUT = 0x00; // Timer A configuration //CCTL0 = CCIE; // Enable interrupts CCTL1 = CCIE; // Enable interrupts TACTL = TASSEL_2 + // Set clock to internal DCO ID_0 + // No frequency divider TAIE + // Interrupts MC_0; // Stopped to begin with CCR0 = 1000-1; // PWM Period (1 us) CCTL1 = OUTMOD_7; // CCR1 reset/set CCR1 = 500; // CCR1 PWM duty cycle //----------- // // Main logic // //----------- // TACTL |= MC_1; _BIS_SR(GIE + LPM0_bits); } //#pragma vector = TIMERA0_VECTOR //__interrupt void Timer_A0 (void) //{ // P1OUT ^= BIT6; //} #pragma vector = TIMERA1_VECTOR __interrupt void Timer_A1 (void) { switch( TAIV ) { case 2: break; // CCR1 not used case 4: break; // CCR2 not used case 10: P1OUT ^= 0x01; // overflow break; } // P1OUT ^= BIT0; // switch (TAIV) // { // case 0x02: // CCR1 // { // P1OUT ^= BIT0; // } break; // case 0x04: // CCR2 // { // // // } break; // case 0x0A: // CCR0 // { // P1OUT ^= BIT6; // } break; // } // return; } P.S.: I am using IAR and the G2231 chip if that makes any difference.
  16. All, Can I output a PWM signal to P1.0 pin (G2231 chip) using timer A in up mode and setting CCR0 / CCR1 accordingly? In short, I was going to use the example code provided by TI (see slac163 and slaa428, example I'm using is the "C" code msp430x21x2_ta_1.c), where pin P1.2 is used for the PWM output. Well, I tried to modify the code to output the signal to P1.0 but can't get it to work. My conclusion is that P1.0 cannot be selected for such function, but I cannot find anythere in the user guide or datasheets a confirmation. In fact, by reading the datasheet (page 6) I had understood it can do that... (link). What am I doing wrong? Can the timer output be in pin P1.0? Here is the code I'm using - below it is set to output to pin P1.2, but there's commented code for pin P1.0 that I tried using. #include <msp430.h> #include <stdlib.h> int main( void ) { //---------------- // // Hardware config // //---------------- // WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer // DCO configuration DCOCTL = CALDCO_1MHZ; //Set DCO to 1 MHz BCSCTL1 = CALBC1_1MHZ; // Calibrate internal clock for 1 MHz // Port 1 configuration P1DIR = 0x04; P1SEL |= BIT2; // P1DIR = 0x01; // P1SEL |= BIT0; // Timer A configuration TACTL = TASSEL_2 + // Set clock to internal DCO ID_0 + // No frequency divider MC_0; // Stopped to begin with CCR0 = 1000-1; // PWM Period (1 us) CCTL1 = OUTMOD_7; // CCR1 reset/set CCR1 = 500; // CCR1 PWM duty cycle //----------- // // Main logic // //----------- // TACTL |= MC_1; _BIS_SR(LPM0_bits); }
  17. Trying to use SysTick to set the sampling frequency of my ADC. Im a bit confused on the interaction of the two though. If my ADC is running at 125KSPS how do I need to set SysTick to 125KHz? 250Khz?? Or how does this work? my code: #include "Energia.h" #include "inc/lm4f120h5qr.h" #include <stdint.h> #include <stdbool.h> #include "driverlib/adc.h" #include "inc/hw_types.h" #include "driverlib/adc.h" #include "driverlib/gpio.h" #include "driverlib/sysctl.h" #include "inc/hw_ints.h" #include "driverlib/interrupt.h" #include "driverlib/sysctl.h" #include "driverlib/timer.h" #include "driverlib/cpu.h" int result; int i = 0; volatile unsigned long Counts=0; void SysTick_Init(unsigned long period); void SysTick_Handler(void); void ADC0_InitSWTriggerSeq3_Ch9(void); unsigned long ADC0_InSeq3(void); byte audio_buff[511]; void setup(){ // running at 16 MHz SysCtlClockSet(SYSCTL_SYSDIV_2_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN); ADC0_InitSWTriggerSeq3_Ch9(); SysTick_Init(50); // initialize SysTick timer, f = 1/(1/16000000/50) ROM_IntMasterEnable(); // enable after everything initialized } void loop(){ while(1){ // interrupts every 1ms, 500 Hz flash } } void SysTick_Init(unsigned long period){ NVIC_ST_CTRL_R = 0; // disable SysTick during setup NVIC_ST_RELOAD_R = period-1;// reload value NVIC_ST_CURRENT_R = 0; // any write to current clears it NVIC_SYS_PRI3_R = (NVIC_SYS_PRI3_R&0x00FFFFFF)|0x40000000; // priority 2 NVIC_ST_CTRL_R = 0x07; // enable SysTick with core clock and interrupts // enable interrupts after all initialization is finished } void SysTick_Handler(void){ if(i==511){ i = 0; } ADC0_PSSI_R = 0x0008; // 1) initiate SS3 while((ADC0_RIS_R&0x08)==0){}; // 2) wait for conversion done result = ADC0_SSFIFO3_R&0xFFF; // 3) read result audio_buff = result; ADC0_ISC_R = 0x0008; // 4) acknowledge completion i++; } void ADC0_InitSWTriggerSeq3_Ch9(void){ volatile unsigned long delay; SYSCTL_RCGC2_R |= 0x00000010; // 1) activate clock for Port E delay = SYSCTL_RCGC2_R; // allow time for clock to stabilize GPIO_PORTE_DIR_R &= ~0x04; // 2) make PE4 input GPIO_PORTE_AFSEL_R |= 0x04; // 3) enable alternate function on PE2 GPIO_PORTE_DEN_R &= ~0x04; // 4) disable digital I/O on PE2 GPIO_PORTE_AMSEL_R |= 0x04; // 5) enable analog function on PE2 SYSCTL_RCGC0_R |= 0x00010000; // 6) activate ADC0 delay = SYSCTL_RCGC2_R; SYSCTL_RCGC0_R &= ~0x00000300; // 7) configure for 125K ADC0_SSPRI_R = 0x0123; // 8) Sequencer 3 is highest priority ADC0_ACTSS_R &= ~0x0008; // 9) disable sample sequencer 3 ADC0_EMUX_R &= ~0xF000; // 10) seq3 is software trigger ADC0_SSMUX3_R &= ~0x000F; // 11) clear SS3 field ADC0_SSMUX3_R += 9; // set channel Ain9 (PE4) ADC0_SSCTL3_R = 0x0006; // 12) no TS0 D0, yes IE0 END0 ADC0_ACTSS_R |= 0x0008; // 13) enable sample sequencer 3 }
  18. What is the preferred way to stop doing analogWrite (PWM) on a pin in Energia? For instance how should I change a pin to digitalWrite, or change it to input, or to just prepare to stop using the pin? In particular, how do you stop the timer (which is used to generate the PWM)? Studying the code for analogWrite, digitalWrite and pinMode I do not see where PWM timers are ever stopped once they are started. (I looked at the code on MSP430, Stellaris, and CC3200). To confirm my impression, I ran a little test on an MSP430. While I can change mode to output and/or do a digitalWrite to change the pin after doing an analogWrite, it appears that the timer just keeps ticking away, even though it is no longer controlling the pin. (I haven't tested this on the other platforms or tested whether changing the pin to input stops the timer.) Is there some glitch where the timers have to be left running once started? Why would one care if the timer keeps running? It uses power (or is this an insignificant amount of power, even on an MSP430 or CC3200 running on a battery). It might make bookkeeping a little easier if unused timers were stopped. (e.g. easier to tell which ones could safely be used for other purposes). Thanks.
  19. Hi all, I have made a couple of MSP430 Tutorials and thought I would share the links here: ADC tutorial and example code I did this one awhile ago and just covers the ADC with 3 example codes, multiple channels, multiple reads etc http://coder-tronics.com/msp430-adc-tutorial/ Timer tutorial and example code Only posted recently and covers both timers on the MSP430G2253, again with 3 examples PWM, interrupts etc. http://coder-tronics.com/msp430-timer-tutorial/ Programming tutorial covering the GPIO and peripheral registers I found this all a little confusing when I started out and had a question from someone recently, so thought I would try and break it down into simple terms. http://coder-tronics.com/msp430-programming-tutorial-pt1/ http://coder-tronics.com/msp430-programming-tutorial-pt2/ Switch Debouncing tutorial with several MSP430 code examples Just some useful information on switch debouncing as well as some code useful code examples http://coder-tronics.com/switch-debouncing-tutorial-pt1/ http://coder-tronics.com/switch-debouncing-tutorial-pt2/ Hopefully they are of some use , Cheers, Ant
  20. Hey all, I've run into a peculiar problem where my main loop doesn't execute. I know my interrupt routine is executing because I can uncomment the led toggle and I can see it blink. From what I've researched thus far, I believe the issue might be that the ISR is starving the main loop from ever executing. If that is the case, I'm not sure what the solution would be. The reason I have my main loop set up this way is because I am going to need different functions executing at different intervals. I'm still fairly new to MSP430 development, so any help will be appreciated! #include <msp430g2553.h> #define MS_TIME 1000 volatile unsigned int s_cnt = 0; unsigned int last_cnt = 0; int main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop WDT P1DIR |= BIT0 + BIT6; // P1.0 and P1.6 are the red+green LEDs P1OUT &= ~(BIT0 + BIT6); // Both LEDs off TA0CCTL0 = CCIE; // Enable Timer A0 interrupts TA0CCR0 = 22; // Count limit TA0CTL = TASSEL_1 + MC_1; // Timer A0 with ACLK, count UP _BIS_SR(LPM0_bits + GIE); // Enable interrupts while(1) { if (last_cnt != s_cnt) { last_cnt = s_cnt; if (last_cnt == MS_TIME) { P1OUT ^= BIT6; // Toggle green LED s_cnt = 0; } } } } #pragma vector=TIMER0_A0_VECTOR // Timer0 A0 interrupt service routine __interrupt void Timer0_A0 (void) { s_cnt++; //P1OUT ^= BIT6; }
  21. Attached find a driver for an HC-SR04 ultrasonic distance sensor (configurable for other similar devices) I had a lot of issues with the sensors operating very unreliably when they operate beyond max distance so there is a bit of additional code to handle this It supports single pings, multiple pings (with and without averaging) and a continual ping mode driven by a timer - so you can start it and then just check a variable at any time to get the most current measurement. Also supports returning statistics on the ping history I'm still new to Stellaris and C in general so probably more bloated than it needs to be feel free to suggest better ways of doing things - I'm still learning and open to feedback. Also a few questions 1) Is there a better way to dynamically pass the port/pin assignments dynamically instead of using a header file - I guess I'm more used to object oriented approaches where it would be easier to instantiate multiple instances of a driver to support multiple devices. 2) Is there a better way to return data from an ISR than a global variable? 3) Any good examples of a driver for a device that returns data -most of the examples I found are one way Anyway hope someone can use it. HC_SR04.zip
  22. Okay... yet another project from me. But this one is close to being real. Basically, it's a toothbrush timer for my nephew. The intent is that he can press a button when he's getting ready to brush his teeth, and the unit will do some LED dances that eventually turn into an LED blinking seconds, and 3 LED's light up based on how far along he is into the brushing ritual Blue LED is the 'second' indicator. Red LED indicates he's in the first minute of brushing. Yellow LED indicates he's in the second minute of brushing. Green LED indicates he's in the third, and final, minute of brushing. Once complete, the unit blinks LED's and such.... *edit- maybe not so close to complete now that other things are being brought in.
  23. Dear all, I am an AVR atmega8 refugee, and msp's clocking scheme seems pretty feature rich (not to mention complex!). I am using MSP430G2 launchpad (g2553). This program uses TImerA, and hardware UART with interrupt. It runs at 1Mhz from DCO. And the peripherals take clock from SMCLK. The UART just echos whatever it receives. The timer generate 500ms delay, and toggles the red and green leds on board http://pastebin.com/yApLyFbu The problem is, I can only have one peripheral at a time using the SMCLK. If I have the above code running exactly as it is, the timer will correctly run and toggle the leds as expected, but the UART echo wont work. If I comment out line 8, TACTL = TASSEL1; //set SMCLK as source - TASSELx = 10 (which means timer is not turned-on at all, right?) then UART echo works. So is it something wrong with my code, or is it like that with the MSP430G2253 ? -- Thanks and Regards, Aurabindo
  24. Hello, I am trying to read in two PWM signals from an RC receiver. I have managed to read in one and have got the result I expected. However, I am unable to read in two channels. The interrupt handlers never get called. I have modified the startup.ccs.c file to call the appropriate handler. Here is the configuration code that I am using: //Enable PortB Interrupt SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER2); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); GPIOPinConfigure(GPIO_PB0_T2CCP0); GPIOPinConfigure(GPIO_PB1_T2CCP1); GPIOPinTypeTimer(GPIO_PORTB_BASE, GPIO_PIN_0); GPIOPinTypeTimer(GPIO_PORTB_BASE, GPIO_PIN_1); TimerConfigure(TIMER2_BASE, TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_CAP_TIME | TIMER_CFG_B_CAP_TIME); TimerControlEvent(TIMER2_BASE, TIMER_A, TIMER_EVENT_BOTH_EDGES); TimerControlEvent(TIMER2_BASE, TIMER_B, TIMER_EVENT_BOTH_EDGES); TimerEnable(TIMER2_BASE, TIMER_BOTH); TimerIntClear(TIMER2_BASE, TIMER_CAPA_EVENT | TIMER_CAPB_EVENT); // // Enable interrupts to the processor. // ROM_IntEnable(INT_TIMER2A | INT_TIMER2B); TimerIntEnable(TIMER2_BASE, TIMER_CAPA_EVENT | TIMER_CAPB_EVENT); ROM_IntMasterEnable(); I have put breakpoints at the interrupt handlers and it never reaches them. I had this working with one channel, now expanding to two. Thanks
  25. Hello everyone, I'm trying to add some sound to my robot. The Energia example sketch "toneMelody" compiles without error unless you also include the library Servo.h. I have read that Arduinos have the same problem, it is because both libraries call upon the same timer. Is it possible to change the code for one of the libraries so that it uses a different timer, if one exists, so that the libraries do not conflict? I'm still a novice at all of this so any help would be much appreciated, thank you. I am using the m430g2553 chip on the Ti Launchpad MSP430 rev.1.5 board. Energia v0101e0011. Win7. simple code: #include <Servo.h> #include "pitches.h" // notes in the melody: int melody[] = { NOTE_C4, NOTE_G3,NOTE_G3, NOTE_A3, NOTE_G3,0, NOTE_B3, NOTE_C4}; // note durations: 4 = quarter note, 8 = eighth note, etc.: int noteDurations[] = { 4, 8, 8, 4,4,4,4,4 }; void setup() { // iterate over the notes of the melody: for (int thisNote = 0; thisNote < 8; thisNote++) { // to calculate the note duration, take one second // divided by the note type. //e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc. int noteDuration = 1000/noteDurations[thisNote]; tone(8, melody[thisNote],noteDuration); // to distinguish the notes, set a minimum time between them. // the note's duration + 30% seems to work well: int pauseBetweenNotes = noteDuration * 1.30; delay(pauseBetweenNotes); // stop the tone playing: noTone(8); } } void loop() { // no need to repeat the melody. } Error message when code is compiled: core.a(Tone - Copy.cpp.o): In function `TIMER0_A0_ISR()': C:\TiLaunchpad\energia-0101E0011-windows\energia-0101E0011\hardware\msp430\cores\msp430/Tone - Copy.cpp:208: multiple definition of `__isr_9' Servo\Servo.cpp.o:C:\TiLaunchpad\energia-0101E0011-windows\energia-0101E0011\hardware\msp430\libraries\Servo/Servo.cpp:89: first defined here collect2: ld returned 1 exit status
  • Create New...