Jump to content

Search the Community

Showing results for tags 'while'.



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

  1. I'm having an issue with Energia where it isnt allowing me to put a while loops within another while loops or any loop for that matter. I need my program to run a loop for as long as the source is correct but run another loop inside of it a specific number of times. It always gives me an error asking for a ";" before a numeric value. Here is my code. const int voltPin = P1_5; const int voltoutPin = P1_7; const int voltoutPin2 = P1_6; float voltage1; float voltage2; float voltage3; int fadeValue; int fadeValue2; void setup() { pinMode(voltoutPin, OUTPUT); pinMode(voltoutPin2, OUTPUT); pinMode(voltPin, INPUT); analogFrequency(10000); } void loop() { while(voltage3 >= 12){ while(fadeValue < 255){ fadeValue ++10; analogWrite(voltoutPin, fadeValue); } analogWrite(voltoutPin, fadeValue); while(fadeValue2 > 0){ fadeValue2 --10; analogWrite(voltoutPin2, fadeValue2); } } while(voltage3 < 12){ while(fadeValue2 < 255) { fadeValue2 ++10; analogWrite(voltoutPin2, fadeValue2); } analogWrite(voltoutPin2, fadeValue2); while(fadeValue > 0){ fadeValue --10; analogWrite(voltoutPin, fadeValue); } } float voltage; voltage1 = analogRead(voltPin); voltage2 = (voltage1 / 1024) * 3.3; voltage3 = voltage2 * 5.65; } // void loop close Let me know how that I can imbed a loop within another loop or just a better way to do this function. Essentially I'm reading a voltage then when the voltage reaches a certain limit I start to cutoff the voltage source by cutting off the PWM. When I cut it off instantly it shut down the whole system, probably from a voltage surge. So I want it now to ramp it down to avoid that.
  2. 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; }
×
×
  • Create New...