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

  1. 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)?
  2. agaelema

    Timeout Library for MSP43x

    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.
  3. 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
  4. electronic624

    Timer Interrupt

    I need a one example of timer interrupt like timerone.h for arduino, yhank you, for help me!!!
  5. 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?
  6. cantthinkofaname1029

    Energia reserved timers

    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?
  7. Can someone provide a code for implementing a watchdog timer to autoreset in TIVA TM4C1294ncpdt using energia?
  8. 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
  9. sven222

    Very accurate timer

    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
  10. 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
  11. efixler

    Hello from New York!

    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
  12. SureshBonagiri

    DHT11 sensor reading under timer ISR

    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.
  13. 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
  14. vinicius.jlantunes

    Use of Timer A interrupts

    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.
  15. vinicius.jlantunes

    Simple PWM using timer

    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); }
  16. openanalog

    Timer Interrupt ADC

    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 }
  17. 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.
  18. Antscran

    Made a couple of MSP430 tutorials

    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
  19. 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; }
  20. lawrence_jeff

    SR04 Ultrasonic Driver

    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
  21. abecedarian

    Tooth brushing minder.

    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.
  22. jayaura

    SMCLK cant drive 2 peripherals?

    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
  23. superbrew

    Timer Interrupts

    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
  24. 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
  25. grahamf72

    Timed Camera Remote

    Here's what has been keeping me busy (apart from my real job) since just after Christmas - a timed camera remote. It is mostly code complete, although could do with a few tweaks here and there. The hardware however isn't quite finished as I'm still waiting for a few parts to be delivered before I can finally finish it - the most critical of which is the 2.5mm stereo plug to go into the camera. Consequently it hasn't actually fired my camera yet, but I'm confident it will work correctly when the final parts arrive. Background Many moons ago, I created a serial port remote release for my Samsung GX10 DSLR, designed to be triggered from my Palm Pilot. I had a program for the palm that would run through a timed sequence, and could trigger the camera remote release through the Palm's serial port. A circuit diagram of the original is here: http://www.flickr.com/photos/gdaj/1317816870/ (my apologies for the link to an image on another site - this was done years ago, and is only slightly relevant to this project). It worked well but was very limited, and unfortunately after several house moves, the Palm Pilot and the cable seem to have vanished. So when I started playing around with the MSP430, I thought a proper timed shutter release would be a good project. After months of procrastination I finally set to work creating it just after Christmas. Functions I wanted something that could do more than just fire off a shot every n seconds for x shots. So my aim was for the timer to have multiple modes. The things I wanted it to be able to do were: Timed bulb shots (I love night-time photography), capable of handling bracketed shots - so instead of just firing the camera once every n seconds, it should fire it 3 times, or 5 times etc capable of bracketing multiple bulb shots - so the timer has to control longer or shorter exposure times. allow for the camera's inbuilt noise reduction for long exposures - my cameras will do dark-frame subtraction after a long bulb exposure, whereby they take another photograph of the same length of time but with the shutter closed. This means taking multiple bulb shots would have to allow for this time delay I came up with a flow control that allows for all these different scenarios, but still with a fairly straight forward user interface. The Camera Interface I have a Samsung GX10 (Pentax KD10 copy), and a Canon EOS 450D. Both of these cameras use the same interface for the remote release. Physically, the camera has a 2.5mm stereo headphone socket. Electronically, the tip is the shutter, the ring is the focus, and the sleeve is ground. To activate shutter or focus, the tip or ring is connected to ground. An open collector transistor is suitable for this. The trick is though, that the focus has to be grounded before the shutter. If you look at the above diagram, you'll see they both get their signal from the same pin, and are therefore both grounded at the same time. This mostly works, but if the camera goes into sleep mode, the focus activation will wake it, but it won't acknowledge the shutter press. My final code allows you to set the delay between when the focus is activated and the shutter is activated, to give the camera time to wake up. This also allows you to use auto-focus if you really want to, by increasing the delay long enough to allow focus. The Hardware The brains behind the operation is an MSP430G2452, currently on the launchpad, but it will ultimately be on a standalone board. To drive the camera interface, all the MSP430 does is drive a pair of open-collector NPN transistors - I use BC549's but pretty much any small-signal NPN transistor will do the trick. To convey all the information to the user, a standard 16x2 text LCD module is used, in 4 bit mode. I use a transistor to switch the backlight, controlled from a pin on the 430, and also use a couple of transistors to switch power to the whole module. This allows me to turn the display completely off when not in use, or while doing a long shooting sequence to save power. Finally, the user interface is controlled by a rotary-coder switch. This uses 3 pins on the 430 - two for the grey-coded rotation and one for the push-button. I initially was using hardware debouncing with capacitors & resistors, and the fact the 430 has Schmidt inputs, but was running into hassles getting reliable operation, so changed to software debouncing. The 32khz crystal is used to manage the timing. All up I'm using all but one GPIO pin. Pin allocation is as follows: P1.0 - LCD RS P1.1 - LCD EN P1.2 - LCD Backlight control P1.3 - LCD Power control P1.4-P1.7 - LCD D4-D7 P2.0 - Rotary Coder Pushbutton P2.1 & P2.2 - Rotary Coder rotation sensor P2.3 - Focus Control P2.4 - Shutter Control P2.5 - spare. P2.6 & P2.7 - 32kHz crystal Note - on the attached circuit diagram, you'll see some scribble next to the TEST pin of the MSP430 - this was a mistake and I couldn't find any whiteout. The capacitor and resistor are obviously connected to the RESET pin, not TEST. Software I started out using Energia, but very soon into the design I started running into RAM problems on the 2452, so I put in the 2553. I didn't get much further when I started running into RAM problems with it too. Energia is great in that it is simple to use, and has ready-to-use libraries for a lot of things. But those libraries come with overhead - for example 32 bytes of RAM just to store the list of interrupt functions, even if I'm only using interrupts on 3 pins. So I started again - still in the Energia IDE (because CCS refuses to run on my main development machine), but I didn't use any of the Energia framework. Consequently my code will look familiar to CCS developers. The main file has the .ino extension like all Energia sketches, but if you rename it to .cpp it should compile with GCC no problems. I am using C++, although the only C++ extension I'm using is function type overides. No classes to help keep the code lean. By restarting in this manner, I was able to go back to the 2452 with 6.6k of code, and no RAM problems. For readability the code is arranged into separate files for different functions. CameraTimerGCC.ino contains main() and has the general flow control. clocks.cpp sets up the clocks (1MHz main clock, 32.768 crystal for ACLK, WatchDog Timer running at 4Hz) as well as implementing a Wait() routine using TIMER-A & the crystal to pause for a few milliseconds in LPM3. encoder.cpp implements the rotary encoder. It contains the P2 interrupt which handles the grey-coded rotation sensor and the pushbutton. A variable holds the relative value of the rotation sensor and indicates if the button has been pressed. flashsave.cpp copies the current settings to flash or reads from flash. I use the 3 user segments of flash (Segments B, C & D) as 3 "slots" to save your settings into. lcd.cpp is a basic library to drive the LCD. Only the functions that I needed are implemented. sequence.cpp handles the logic of shooting the programmed sequence textconstants.cpp - pretty self explanatory holds most (I need to do some tidying up so it is all) of the text constants used for the display. ui.cpp - implements the main menu UPDATE - 26 January 2014 - Nearing Completion Well I finally managed to track down a cable with a 2.5mm plug - after checking all the local "electronics" shops again and drawing a blank, I just happened to be wandering through a department store and saw a lone 2.5mm cable in ratty packaging. Hooked it all up, and nothing. I switched to bulb mode, and still nothing. Then I touched one of the base resistors into one of the transistors, and the camera went nuts. I soon discovered my error - I hadn't made the connection between the emitters of my driver transistors and ground. With no ground reference the MSP wasn't turning the transistors on, so nothing at the camera. Fixed that, ran a sequence, and the camera woke from sleep but still did nothing. A little tweaking and I discovered my program was sound, the problem was just that the time it was holding the shutter down was too short. Dialled up 100mSec instead of 25mSec and everything leapt into action and was working perfectly. Then came the trickiest part of the whole exercise - converting my breadboarded circuit into stripboard. After a few hours with a piece of paper printed with a 1/10" grid I finally worked out a layout that would work. It is probably a long way from optimal, and when I look at the board I see a huge amount of wasted space as well as more wire links than I would like, but it works, that's the main thing. I did end up changing a few pin allocations to things that would allow a more efficient board layout. So last night I sat down and soldered it up. Updated the code with the new pin allocations, flashed it to the 2452, plugged it into the board, connected power, and nothing. Actually not quite true, the backlight flickered a bit. So I poured over the board layout, and found one fault - I had pins P1.6 & P1.7 connected to the LCD's DB7 & DB6 respectively instead of 1.6->DB6, 1.7->DB7. That shouldn't cause the backlight to flicker but it would stop the LCD starting up, so I fixed that and still just had a flickering backlight. All the voltages were what they should be - my 5V line was held at 5.1V by the Zener, my 3.3V line was exactly 3.3V. All the pins on the MSP430 were held at 0, even the rotary coder inputs which should be pulled high. Thinking I may have blown the MSP430 I unplugged it and put it back on the launchpad. With the pin changes, the backlight was now controlled by P1.0, so in theory when I put it back on the launchpad the red led should light for a few seconds before turning off. Nothing. I was pretty sure I'd wrecked the MSP430, so just to test I loaded Energia's basic blinking light program. It was then that I noticed that down the bottom of Energia it said "LaunchPad w/ msp430g2553". Changed that to the msp430g2452, and the blinking light worked. Re-flashed my code and the red led lit up for 10 seconds before turning off. Plugged the 430 back into my board, and everything lit up perfectly just like it should. Did a test run and it operated perfectly, except I noticed the backlight wasn't going out. So, now I was trying to find the reason why the backlight stayed on. My first suspicion was a bridged solder track or similar, but couldn't find any. Next idea was that maybe the controlling transistor had gone short circuit - it had been a little stubborn when I was trying to solder it, the solder didn't want to take. Desoldered it, but I was still getting 0 ohms between the backlight Cathode and ground. Maybe the 10k resistor that I had across the transistor to provide the low backlight was the issue? Removed it, and I was still getting 0 ohms. I came to the conclusion that the problem had to be on the LCD module itself - I was using a brand new module, not the one I had breadboarded. I noticed that the pin for the backlight LED went extremely close to the ground-plane - could it be shorting there? I desoldered the lead (it is sort of wrapped around the end of the board), and the short circuit went away. Soldered the lead back in place and the short circuit was still gone - there must have been a bit of stray solder or something linking it to the ground plane. With that sorted, I put the transistor & resistor back in place, and the backlight control was now working perfectly. All that remains is to put it in a case, and to change the 2 x 2AA holders for a 4AA holder when it arrives. Here's a video showing a run-down of the completed unit. Overall I'm very happy with the result. It is working, and does what I intended for it. Hopefully we'll have some clear nights soon so I can do some long exposure shots. Another Update Now attached is an updated version of the source code. New in this version is: Reflects the final pinout that I used when I went to the stripboard. Time display is improved. Instead of just displaying the time in seconds, the time is now displayed as a combination of days, hours, minutes & seconds, eg "1 hr 5 min" Improved logic within the menus - it skips over the "Burst Interval" option if the Burst Count is 1. When bulb mode is off, it states "Bulb Mode Off" Instead of just having a time of 0. Improved logic when dialing up large values - For times larger than 3 hours it now goes in 15 minute increments. Increased maximum focus time to 10 seconds. Here's a picture of the (near) finished product on stripboard and showing an example of the new time display. CameraTimerUpdated.zip