Jump to content

Search the Community

Showing results for tags 'Interrupt'.

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. 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
  2. Hello there, I am doing a project where I have to read in a square wave and determine the frequency of the wave then output that number. I found out that I am using a 1MHz clock, then I set up an interrupt to count the edges for my square wave input. I don't think my interrupt is working though. I even changed it to a push button and tried to get it to turn on led's it didn't work. ps. I'm using energia btw. pps. I'm using msp430 revision 1.5 Hope someone can help me out Thanks a bunch!! if you don't know what energia is energia.nu is where you can find information My code so far //LED PINS int ledPin0 = 3;// select the pin for the LED int ledPin1 = 4; int ledPin2 = 5; int ledPin3 = 6; int ledPin4 = 8; //Inputs volatile int sensorPin = A7; // select the input pin for the potentiometer //Variables volatile int temp=0; //int count=0; volatile int count1=0; volatile int number=0; void setup() { // declare the ledPin as an OUTPUT: pinMode(ledPin0, OUTPUT); pinMode(ledPin1, OUTPUT); pinMode(ledPin2, OUTPUT); pinMode(ledPin3, OUTPUT); pinMode(ledPin4, OUTPUT); pinMode(sensorPin, INPUT_PULLUP); //attachInterrupt(analogRead(sensorPin),inter,CHANGE); } void loop() { if (analogRead(sensorPin == HIGH)){ count1 = count1++; } else{ number = count1; count1 =0; } //Check for Frequency //number = 1000000/count1; //Make temp Variable to change temp = number; //Coverts that number to binary //Checks if it need to turn on light 5 if(temp >= 16){ digitalWrite(ledPin4, HIGH); temp = temp - 16; } else{ digitalWrite(ledPin4, LOW); } //Checks for light 4 if(temp >= 8){ digitalWrite(ledPin3, HIGH); temp = temp-8; } else{ digitalWrite(ledPin3, LOW); } //Checks for light 3 if(temp >= 4){ digitalWrite(ledPin2, HIGH); temp = temp - 4; } else{ digitalWrite(ledPin2, LOW); } //Checks for light 2 if(temp >= 2){ digitalWrite(ledPin1, HIGH); } else{ digitalWrite(ledPin1, LOW); } //Checks for light 1 if(temp >= 1){ digitalWrite(ledPin0, HIGH); } else{ digitalWrite(ledPin0, LOW); } delay(5); //count1 =0; } //Interuppt Routine //void inter() //{ //count1=count1++; //}
  3. Hi, sorry I'm attempting to do an interrupt in Energia IDE. with attachInterrupt() but, still given me an error. if you can help me, i will appreciate you.
  4. Hello, I'm a beginner so I think the answer is simple. I have an HC-SR04 connected to 4 AA batteries at 5.4V. The echo from the ultrasonic sensor goes through a voltage divider with 20k and 10k ohm resistors before going into P1.1. My f2013 is being powered by the usb programming tool and is using P1.2 as the out/trigger pin for the hc-sr04. I beleive the sr04 can take a 3.3V trigger. This is my code below, I just can't figure out why my interrupt isn't triggering. I borrowed some code from the internet. I can't remember his username, but the guy with the wall racer with two hc-sr04's. For quick reference: F2013 Datasheet #define LED0 BIT0 #define ECHO BIT1 #define TRIG BIT2 #include <msp430f2013.h> volatile unsigned distance_in_cm=0; volatile unsigned int start_time; volatile unsigned int total_time; volatile unsigned int up=0; void main(void) { //setup ports, cpu speed, timers //send 2 microseconds of off to p1.1 //send 10 microseconds of on to p1.1 //wait 60 microseconds // listen and count time on p1.0 //distance in cm is counted time/58 WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer BCSCTL1 = CALBC1_1MHZ; DCOCTL = CALDCO_1MHZ; //set speed to 1 megahertz TACTL = 0; //stop the clock P1DIR = (LED0 + TRIG); // set all of P1.0 P1.2 to output and P1.1 to input P1SEL = ECHO; //select echo pin as input for timerA TACCTL0 |= CM_3 + SCS + CAP + CCIE + CCIS_0; //capture rising and falling edge, syncronize(always do this),capture mode, interrupt enabled TACTL = TASSEL_2 + ID_0 + MC_2; // SMCLK,/1, continuous up mode, clear _BIS_SR(GIE); // general interrupt enable while (1) { volatile unsigned int i = 0; up = 1; //Next catch on Timer1A0 should be rising edge - helps with capture timer P1OUT |= TRIG; //turn trig on _delay_cycles(20); //double the required 10 microseconds for good measure //TODO set to 10 again if possible P1OUT &= ~TRIG; //turn trig off _delay_cycles(60000); //wait 60ms before testing again. the interrupt should happen somewhere here } } #pragma vector=TIMERA0_VECTOR __interrupt void timerA0 (){ if (up){ start_time = TACCR0; } else { total_time = TACCR0 - start_time; distance_in_cm = total_time/58; if (distance_in_cm < 20){ P1OUT |= LED0; } else{ P1OUT &= ~LED0; } } up=!up; //if this was the rising edge, the next one will be a falling edge, and vice-versa TA0CTL &= ~TAIFG; //clear timer A interrupt flag, so the chip knows we handled the interrupt TACCTL0 &= ~CCIFG;//clears capture interrupt flag, should already be done automatically though TODO } /* #define MC_0 (0*0x10u) Timer A mode control: 0 - Stop #define MC_1 (1*0x10u) Timer A mode control: 1 - Up to CCR0 #define MC_2 (2*0x10u) Timer A mode control: 2 - Continous up #define MC_3 (3*0x10u) Timer A mode control: 3 - Up/Down #define ID_0 (0*0x40u) Timer A input divider: 0 - /1 #define ID_1 (1*0x40u) Timer A input divider: 1 - /2 #define ID_2 (2*0x40u) Timer A input divider: 2 - /4 #define ID_3 (3*0x40u) Timer A input divider: 3 - /8 #define TASSEL_0 (0*0x100u) Timer A clock source select: 0 - TACLK #define TASSEL_1 (1*0x100u) Timer A clock source select: 1 - ACLK #define TASSEL_2 (2*0x100u) Timer A clock source select: 2 - SMCLK #define TASSEL_3 (3*0x100u) Timer A clock source select: 3 - INCLK #define CCIS_0 (0*0x1000u) Capture input select: 0 - CCIxA #define CCIS_1 (1*0x1000u) Capture input select: 1 - CCIxB #define CCIS_2 (2*0x1000u) Capture input select: 2 - GND #define CCIS_3 (3*0x1000u) Capture input select: 3 - Vcc #define CM_0 (0*0x4000u) Capture mode: 0 - disabled #define CM_1 (1*0x4000u) Capture mode: 1 - pos. edge #define CM_2 (2*0x4000u) Capture mode: 1 - neg. edge #define CM_3 (3*0x4000u) Capture mode: 1 - both edges */
  5. I'm using Energia with a Launchpad (LM4F120XL), and I've found some strange behavior when using a timer interrupt. When the interrupt setup code is compiled in, functions that do string processing (atoi, strtoul, strtok, etc.) do not return the expected value. In the code below, atoi() will return 0 when given the input "12". Note that the timer interrupt hasn't even been set up at the point where atoi() is called. In particular, it's the call to IntRegister() that causes the problem. The same code will work as expected if IntRegister() is commented out. Also note that everything works fine if an infinite loop is placed immediately before the initTimer() call -- in that case, I'm guessing the compiler is optimizing out everything in initTimer() because it's unreachable. strcmp() was also misbehaving (i.e. returning nonzero values for identical strings), but when I moved the const char* comparison string from global scope to function-level scope, the comparison began working as expected. Anyone have any ideas about this? It seems like it might have something to do with the arrangement of symbols in memory. --Colin #include "inc/hw_ints.h" #include "driverlib/sysctl.h" #include "driverlib/interrupt.h" #include "driverlib/timer.h" void timer0_handler(void) { TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT); } void initTimer(unsigned Hz) { SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0); TimerConfigure(TIMER0_BASE, TIMER_CFG_32_BIT_PER); unsigned long ulPeriod = (SysCtlClockGet() / Hz) / 2; TimerLoadSet(TIMER0_BASE, TIMER_A, ulPeriod - 1); IntEnable(INT_TIMER0A); IntRegister(INT_TIMER0A, timer0_handler); TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT); IntMasterEnable(); TimerEnable(TIMER0_BASE, TIMER_A); } void setup() { IntMasterDisable(); Serial.begin(9600); } void loop() { const char *dbuf = "12"; Serial.println(atoi(dbuf)); initTimer(3); while (1); }
  6. Hey all, I'm completely stumped on a bug for my design day project. I've got a rotary encoder that is used to change a value on an LCD screen. The code works perfectly when the encoders state at power up is 00. However if either pin is high, it doesn't work at all. Some transitions will cause the value on the screen to move in the wrong direct, and some transitions don't seem to trigger an interrupt at all. This is the code I'm using and would LOVE some help! Is it possible that the MSP430 is recording the initial values as reference voltages causing subsequent interrupts to not work? #pragma vector=PORT2_VECTOR //Port 2 interrupt triggered by either rotary encoder pin __interrupt void Port_2(void) { //int gray0=P2IN&GRAY0; //int gray1=P2IN&GRAY1; if(P2IFG&GRAY0) { (P2IN&GRAY1)? parameter++ : parameter-- ; if(parameter>999) parameter=0; P2IFG&=~GRAY0; } else if(P2IFG&GRAY1) { (P2IN&GRAY0)? parameter++ : parameter-- ; P2IFG&=~GRAY1; if(parameter<0) parameter=999; } inactivity=0; //interaction has been seen, so reset the inactivity counter }
  7. Hi, I am having trouble getting the ADC interrupt working for the msp430g2452. I am simply trying to turn on a flag when the interrupt goes off but it doesn't seem to be working. Code below.... #include <msp430g2452.h> void initAdc(); volatile char flag = 0; int main(void) { WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer P1DIR |= BIT6; P1OUT &= ~BIT6; initAdc(); __bis_SR_register(GIE); while(1){ if(flag == 1){ P1OUT |= BIT6; }else{ P1OUT &= ~BIT6; } } return 0; } void initAdc(){ ADC10CTL1 = CONSEQ_2 + ADC10DIV_3; //Channel A0 for conversion, ADC10OSC clock used for sampling, repeat single channel ADC10CTL0 = ADC10SHT_2 + MSC + ADC10ON + ADC10IE + ADC10SC + ENC; //sample and hold time every 16 clocks, Multiple sample conversion, turn on ADC, enable interrupts for ADC, every 16 clock cycles take a sample ADC10DTC1 |= 0x01; //Number of transers in each block ADC10AE0 |= 0x01; //Enables the corresponding pins for analog inputs } #pragma vector=ADC10_VECTOR __interrupt void ADC10_ISR(void) { flag = 1; }
  • Create New...