Jump to content

Search the Community

Showing results for tags 'interrupts'.



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.


Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Location


Interests


Sparkfun


Github

Found 16 results

  1. I'm working on a reflow controller with a G2553 driving a solid state relay to control power. It also includes a rotary encoder with push button and two 7-segment displays to adjust and display the duty cycle. I've written it in assembler, and all of the activity takes place within the interrupt service routine triggered every 2ms by the watchdog timer in interval timer mode. Between interrupts, the processor sleeps. In assembler, the service routine does its magic in about 0.1ms, or 1/20th of the total time, so there's no danger of an overrun into the next trigger. There are no pin interrupts because the encoder and push button are serviced by polling. I'm thinking about converting the software to Energia to make it more accessible to others, and possibly also to Arduino for the same reason. But I'm having trouble finding Energia or Arduino examples of setting up timer-based interrupts other than fiddling directly with the registers. If anyone can point me to information on any higher-level commands that implement timer interrupts, I would appreciate it. One other general question I have concerns pin interrupts. My understanding is that MSP430 parts can do rising or falling edge interrupts, but I've seen examples of people using "change" interrupts as are available on Atmel parts. Can someone explain how an on-change interrupt is actually implemented for MSP430 parts? Thanks very much.
  2. I am using launchpad cc3200 and i saw the attachInterrupt function. Is there a function to set the priorities of multiple interrupts ? I wish to declare the interrupt priorities of two or more tasks Thanking you
  3. Hi , I am unable to use the Timers of CC3200 on Energia. Kindly view my code snippet and see what errors have I made.I am getting the errors which I have mentioned at the last. CODE:- #include <driverlib/timer.h> #include <inc/hw_timer.h> void setup() { pinMode(2,INPUT_PULLUP); pinMode(9,OUTPUT); noInterrupts(); TimerIntStatus(TIMERA0_BASE,true); TimerDisable(TIMERA0_BASE,TIMER_A); TimerIntDisable(TIMERA0_BASE,TIMER_TIMA_MATCH); TimerConfigure(TIMERA0_BASE,TIMER_CFG_A_PERIODIC_UP); TimerPrescaleSet(TIMERA0_BASE,TIMER_A,32); TimerMatchSet(TIMERA0_BASE,TIMER_A,7500); TimerIntRegister(TIMERA0_BASE,TIMER_A,start); TimerControlStall(TIMERA0_BASE,TIMER_A,false); TimerControlLevel(TIMERA0_BASE,TIMER_A,false); attachInterrupt(0,zeroCrossingInterrupt, RISING); interrupts(); TimerIntEnable(TIMERA0_BASE,TIMER_TIMA_MATCH); } void loop() { } void zeroCrossingInterrupt() { digitalWrite(9,LOW); TimerEnable(TIMERA0_BASE,TIMER_A); } void start() { digitalWrite(9,HIGH); TimerDisable(TIMERA0_BASE,TIMER_A); } Errors:- In file included from sketch_aug17a.ino:1:0: C:\energia-0101E0014-windows\energia-0101E0014\hardware\cc3200\cores\cc3200/driverlib/timer.h:164:31: error: 'tBoolean' has not been declared tBoolean bInvert); ^ C:\energia-0101E0014-windows\energia-0101E0014\hardware\cc3200\cores\cc3200/driverlib/timer.h:168:31: error: 'tBoolean' has not been declared tBoolean bStall); ^ C:\energia-0101E0014-windows\energia-0101E0014\hardware\cc3200\cores\cc3200/driverlib/timer.h:193:59: error: 'tBoolean' has not been declared extern unsigned long TimerIntStatus(unsigned long ulBase, tBoolean bMasked); Kindly help asap.
  4. I have experience with the traditional C programming in Code Composer and have implemented a timer interrupt routine in CCS for TIVA TM4C1294, now I want to create a timer ISR in Energia, how do I proceed ?
  5. DanielPHuber

    Interrupt and Counter

    A decoder from a motor has 2 square wave outputs that deliver 256 pulses/revolution (duty cycle 1:1). The two outputs are 90 degree out of phase for direction information. I want to count pulse, in one direction up, in the other down. Towards this aim I attach to the first decoder output following routine: void countStep(){ if(digitalRead(_CIN2)){_pos++;} else {_pos--;} } "_CIN2" is the second decoder output and "pos" the counter variable. This works well until up to approx. 16kHz. But for higher frequencies it counts in the wrong direction. I first guessed, that the phase relation between the 2 signals is not constant, but an independent measurement showed it to be rock stable. Another guess is, that the interrupt is too slow (maybe because of the "digitalRead"). I am running a MSP430G2553 with 16MHz. Can somebody verify or falsify this guess?
  6. Colleagues, The circuit that I'm working on is based on an 8-pin MSP430G2210. The RST#/NMI serves as a soft on/off switch. While the device is on, it will use the WDT in the interval mode for cyclic sleep (at least, that's my intent). I was able to make the NMI# interrupt work to wake up from LPM4. Separately, I was able to make the WDT interrupt work to wake up from LPM3. But I wasn't able to make them work together. // PURPOSE: Keep track of button presses #pragma vector=NMI_VECTOR __interrupt void nmi_isr(void) { g_nmiFlag = true; // set a flag, which will be examined in the main() loop for (volatile unsigned int i = 20000; i != 0; --i); // allow some time for contact bouncing to settle IFG1 &= ~NMIIFG; // re-clear NMI flag if there was bouncing IE1 |= NMIIE; // enable NMI __bic_SR_register_on_exit(LPM4_bits); // exit the LPM on return from the ISR } // PURPOSE: Allow cyclic wake up. #pragma vector=WDT_VECTOR __interrupt void wdt_isr(void) { __bic_SR_register_on_exit(LPM3_bits); // exit the LPM on return from the ISR } int main(void) { // Initialize the MSP430 P1DIR |= 0x04; // LED. Set P1.2 to output direction P1OUT |= 0x04; // LED off P1OUT &= ~0x20; // Make sure that sensors are powered down P1DIR |= 0x20; while (1) { // Enter the Dormant state WDTCTL = WDTPW | WDTHOLD // WDT off | WDTNMI // NMI (instead of reset). See section 10.3.1 in [1] and fig. 2-1 in [1]. | WDTNMIES; // NMI on falling edge IFG1 &= ~NMIIFG; // make sure that the interrupt flag is not set IE1 |= NMIIE; // Enable NMI __bis_SR_register(LPM4_bits | GIE); // Enter LPM4 w/interrupt // Button will cause the interrupt, which will end the dormant state. See NMI ISR. g_nmiFlag = false; // WDT is used for cyclic sleep. Set WDT to interval mode. BCSCTL1 |= DIVA_1; // ACLK/2 BCSCTL3 |= LFXT1S_2; // ACLK = VLO WDTCTL = WDTPW | WDTTMSEL // WDT in interval mode | WDTCNTCL // clear counter | WDTSSEL // clock WDT from ACLK | WDTNMI; // NMI (instead of reset). See section 10.3.1 in [1] and fig. 2-1 in [1]. IE1 |= WDTIE; // Enable WDT interrupt volatile bool remainAware = true; while (remainAware) { __bis_SR_register(LPM3_bits | GIE); // nap // awoken by the WDT interrupt // <bring-up> P1OUT &= ~0x04; // Set P1.0 LED on for (volatile int i = 5000; i>0; i--); // Delay P1OUT |= 0x04; // Reset P1.0 LED off // </bring-up> // Did user press the button to deactivate the unit? if (g_nmiFlag == true) { remainAware = false; } } } return 0; } The LED blinks only once after the NMI is created with a button. I expected that the WDT timer would make the LED blink repeatedly. What am I missing? Any suggestion, insight or reference is really appreciated! Cheers, - Nick
  7. Hi guys, do you know if there is a way to set different priorities to different threads of a sketch? For example, if we had a slow thread which senses a thermomenter and another one which sends data serially bit-banging a pin, and another one which senses an emergency stop (whatever, just imagine they are all pretty fast processes) I would like to set a list of priorities for the underlying TI/RTOS to handle possible needs. Is there a way to implement this? Also... if we set interrupts to handle certain events... how does Energia signal the RTOS the priority for this (like in don't interrupt an interrupt )? Thanks for your insights Gast
  8. I am trying a loopback test for msp430f5438a using interrupts. I have initialized the master and slave modules and have written their respective functions as interrupt service routines. The aim I to turn the LED off when the slave receives a character.However, the code is not working. Please tell me how to make it work --------------------------------------------------------------------------------------------------------------------------------- // To use interrupts to transmit and recieve text character(s) #include <msp430.h> /* * main.c */ ? ? void main(void) { WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer P1DIR |= BIT0; P1OUT |=BIT0; // setting up master P3SEL = BIT1|BIT2|BIT3; // B0 PINS UCB2CTL1 |= UCSWRST; UCB2CTL0 |= UCCKPH + UCMSB + UCMST + UCSYNC; //3 - PIN, 8 bit, spi master UCB2CTL1 |= UCSSEL_2 ; // SMCLK UCB2CTL1 &= ~(UCSWRST) ; UCB2IE = UCTXIE ; // master setup done // Configuring the Slave P3SEL= BIT0|BIT4|BIT5; UCA0CTL1 |= UCSWRST; //put the SPI bti UCA0CTL0 |= UCCKPH + UCMSB + UCSYNC ; // 3- pin , 8 bit , SPI slave UCA0CTL1 &= ~(UCSWRST) ; //release the pin for sending hte SPI signal UCA0IE = UCRXIE; //Enable RX interrupt // Slave setup done ? __bis_SR_register(GIE); // enable interrupts while(1); } #pragma vector = USCI_B2_VECTOR __interrupt void USCI_B2_ISR (void ) { UCB2TXBUF = 0X0A ; } ? #pragma vector = USCI_A0_VECTOR __interrupt void USCI_A0_ISR ( void ) { if (UCA0RXBUF == 0X0A) { P1OUT &= ~BIT0; } ? } ----------------------------------------------------------------------------------------------------------------------------------------- I am using CCS for IDE
  9. Hello, I am basically new to msp430 and CCS, and I am having a hard time trying to understand code, interrupts and timers. Background info: Goal.- read and interpret a dual 7 segment LED display with 10 pins. So after playing around with this part I found out that the way this works is the driver pins (9, 6) toggle each other really fast ~4khz, 9 is on while 6 is of etc. My idea was to use the MSP430G2553 to read A-G on PORT1 and the 2 drivers (9, 6) on PORT2. I read on interrupts and saw that there is a way to set up an interrupt for when your input signal (in this case 9 or 6 on the diagram) goes from high to low or low to high. SO if I could read all A-G segments when 9 is "on" it would correspond to digit 1, when 9 goes to "off" and 6 turns "on" i would read all A-G segments again and that would correspond to digit 2... I thought it would be easy but apparently there is a lot that I am overlooking. Here is my attempt to code: (worked from an example from TI Resource Explorer) #include <msp430.h> volatile int flag = 0; int main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop Watchdog timer if (CALBC1_1MHZ ==0xFF || CALDCO_1MHZ == 0xFF) { while(1); //trap for the Digitally controlled O. } BCSCTL1 = CALBC1_1MHZ; //set range for the O. DCOCTL = CALDCO_1MHZ; //set DCO step modulation 1MHZ P1DIR = 0; // Set P1.0 - P1.7 as input P2DIR = 0XF9; // set P2.1 AND P2.2 as inputs P2OUT = BIT4; // set P2.4 to start as on P2IE |= BIT2; // P2.2 interrupt enabled P2IES = 1; // Flag is set with a high-to-low transition P2IFG &= ~BIT2; // P2.2 interrupt flag cleared __bis_SR_register(GIE); // Enable all interrupts while(1) //Loop forever { } } #pragma vector=PORT1_VECTOR __interrupt void Port_1(void) { if(P1IN == 0x79) //check if P1IN= 01111001 means, p1.0=1, p1.1=0, p1.2=0, p1.3=1... etc { P2OUT = 0; // turn off bit 4 on port 2 (added to see if i recognize 01111001) } P2IFG &= ~BIT2; // P2.1 interrupt flag cleared } I am attempting to read all inputs in PORT1 and check if they match 01111001 which corresponds to the digit displaying "1" inverted so my zeros mean the segment is "on" so for example if i wanted to display "7" segments a, b, and c should be 0 the rest 1. or (01111000) I am ignoring the DP. The code compiles but my LED at BIT4 never turns off which means the interrupt is never happening? Any feedback is very much appreciated.
  10. DrOldies

    Getting current ulPeriod

    I developed working code for TIMER0 interrupt on my TM4C129. But I would like to also get the current period. I assumed TimerLoadGet would return this but I get zero. I've tried all three of these functions with ROM_ and without. The peripherals manual doesn't help with info like "Returns the load value for the timer" returns 0 for uint32_t TimerLoadGet(TIMER0_BASE, TIMER_TIMA_TIMEOUT) returns 0 for uint32_t TimerValueGet(TIMER0_BASE, TIMER_TIMA_TIMEOUT) returns 65535 for uint32_t ROM_TimerMatchGet(TIMER0_BASE, TIMER_TIMA_TIMEOUT) Can anyone direct me to a better explanation of these three? How can I get the Period? P.S. I new to the Launchpad coming from Arduinos. These forums could use more sample code. Thanks
  11. p2baron

    Check if I am in LPM4

    I am currently working on a battery operated wireless doorsensor. A message is sent whenever a magnetic switch causes an interrupt. I have read some topics on this forum and changed some lines in Winterrupts file and created the following sketch: #include <x10rf.h> #define intpin1 P1_5 #define txpin P1_7 #define txvcc P1_0 #define reps 4 x10rf myx10 = x10rf(txpin,0,reps); void setup() { myx10.begin(); pinMode(intpin1,INPUT_PULLUP); pinMode(txvcc,OUTPUT); digitalWrite(intpin1, HIGH); digitalWrite(txvcc, LOW); attachInterrupt(intpin1, Wake, CHANGE); } void loop() { LPM4; } void Wake() { int state = digitalRead(intpin1); digitalWrite(txvcc, HIGH); switch(state) { case 0: myx10.x10Security(3,0x84); break; case 1: myx10.x10Security(3,0x04); break; } delay(10); digitalWrite(txvcc, LOW); } This is working great but I have some questions. How can I check that MCU is running in LPM4? Do I need CCS to check (debug) this or are there other ways? At some point I want to add sensors to periodically report temperature and light conditions. What is a power efficient way to do this? I know timers don't work in LPM4. Should I switch to LPM3 or use an external circuit to wake the MCU every x minutes?
  12. Hi, I am trying to write a code on the launchpad msp430g2553, which would simulate the output of several simple logic gates. I have connected 2 push buttons as inputs to pins P1.3 and P1.7 and 4 LEDs as outputs to P1.0, P1.4, P1.5, and P1.6. 2 of the LEDs are representing the "truth" and "false" of the truth table and the other 2 are just to indicate that a push button has been pressed (1 for each). At first I did it with polling with 6 diferrent logic gates in switch cases and it is working just fine. logicPolling.c But now I am trying to do it with interrupts and I get problems while pressing both buttons at the same time (simulating 2 inputs of logicTableInterrupts.c
  13. sandbox

    Interrupts on the Energia

    Hi all, I am having some trouble getting interrupts up and running on the energia, i have a couple of questions. 1 ) I have not been able to find a list of pins on the G2553 that are compatible with interrupts. 2) I am using the following code, with a tactile button (pulled up to VCC with a 10k and then pressing it connects it to ground) and it only seems to work with the option "FALLING" in the interrupt declaration "CHANGE" does not work. Any suggestions on what might be going wrong ? void setup() { attachInterrupt(P2_0,blinky,FALLING); Serial.begin(9600); } void loop() { if(flag==1) Serial.println(1); flag=0; } void blinky() { flag=1; } Thanks for your help in advance....
  14. Hello everyone. I am more of a hardware dude, so software always makes me stay up all nights while trying to understand why it doesn't work and why DOES it work. Anyway, below is the code I am using. It works, kind of, but there is a problem. If I decrease delay, resolution goes down pretty bad, with 300ms it is 100RPM. If I Increase, of course it gets slow, and that is not ok in my application. As I am a total noob, I hope someone here might give me advice, what can I possibly do. Regards, Arch. volatile unsigned int rpmcount; float rpm; float timeold; const int carbswitch = P2_2; //switch from carburator, when accelerator is not pushed, switch is connected to GND. When accelerator is getting floored, disconnects. const int outputswitch = P2_4; //enables/disables gas valve, HIGH at >1400 RPM and carbswitch HIGH. const int shiftlight = P2_5; //enabled when RPM > 5000. const int engineok = P2_3; //enabled when RPM > 500. int carbswitchstate = LOW; int valvestate = LOW; int mymilis = 300; String ds; #include <LiquidCrystal.h> LiquidCrystal lcd(P1_2, P1_1, P1_4, P1_5, P1_6, P1_7); void rpm_fun() { rpmcount++; } //INPUT from ignition coil's switching GND is wired to P1_3, with protection from high voltage spikes. void setup() { lcd.begin(16, 2); attachInterrupt(P1_3, rpm_fun, FALLING); rpmcount = 0.0; rpm = 0.0; timeold = 0.0; pinMode (outputswitch, OUTPUT); pinMode (shiftlight, OUTPUT); pinMode (engineok, OUTPUT); pinMode(carbswitch, INPUT_PULLUP); } void loop() { if(millis()-timeold>=mymilis){ detachInterrupt(P1_3); const float freqHz = ((float) rpmcount / (float) (millis() - timeold)) * 1000.0; const float rpm = freqHz * 30.0; rpmcount = 0; carbswitchstate = digitalRead(carbswitch); if (rpm >= 1400.0 && carbswitchstate == HIGH) { digitalWrite(outputswitch, HIGH); } else { digitalWrite(outputswitch, LOW); } valvestate = digitalRead(outputswitch); if (valvestate == HIGH) { ds = ("ON"); } else { ds = ("OFF"); } if (rpm >= 5000.0) { digitalWrite(shiftlight, HIGH); } else { digitalWrite(shiftlight, LOW); } if (rpm >= 500.0) { digitalWrite(engineok, HIGH); } else { digitalWrite(engineok, LOW); } lcd.clear(); lcd.print("RPM="); lcd.print(rpm); lcd.setCursor(0, 1); lcd.print ("ECON="); lcd.print(ds); attachInterrupt(P1_3, rpm_fun, FALLING); timeold = millis(); } }
  15. Hey all. I'm using an msp430g2553 to output an integer to an LCD and let that integer to be modified with a rotating gray code switch. I am attempting to debounce the switch by sampling its value every 1ms for 5ms (5 samples) each time the switch interrupt fires. I am trying to accomplish this with the following code: for(i=0; i<SAMPLE_NUM; i++) { ms=0; while(ms==0) { //do nothing until at least 1 ms has elapsed } gray0_val = P2IN&GRAY0; //latch current port pin values gray1_val = P2IN&GRAY1; The issue is at line 2-3 where I reset a 1ms global variable counter. This gets incremented by my timer 0 A0 interrupt at a rate of 12000Hz. (yes I know thats not exactly 1 ms, but it doesnt matter) After I reset the variable, the idea is to wait until the timer interrupt increments it again and then sample the gray code switch value. However, instead my code is getting stuck here, and it's preventing the timer interrupt from ever firing. I looked up ISR priorities in the user guide, and it appears that the timer interrupt priority is higher than port 2. That means that in theory this SHOULD work, but something is going wrong. If you guys could help me solve it that would be great!! P.S. I know its not usually good practice to interrupt an interrupt, but we are close to a deadline and this is the easiest way we've come up with to debounce effectively.
  16. Hi, I'm trying to build a simple Li ion battery capacity tester using this article. The code compiles fine until line 40, where it comes to interrupt handler. What should I use instead? Here is the code where I get errors: ISR(TIMER1_OVF_vect) { TCNT1=0x0BDC; x=!x; measure(); } void setup() { pinMode(LED, OUTPUT); TIMSK1=0x01; // enabled global and timer overflow interrupt; TCCR1A = 0x00; // normal operation page 148 (mode0); TCNT1=0x0BDC; // set initial value to remove time error (16bit counter register) TCCR1B = 0x04; // start timer/ set clock Serial.begin(256000); }; I saw this topic, but I never used assembler before and I don't understand anything there.
×