Jump to content
43oh

gatesphere

Members
  • Content Count

    430
  • Joined

  • Last visited

  • Days Won

    6

Reputation Activity

  1. Like
    gatesphere got a reaction from larsie in LaunchPad library-TLV5620, w/ example waveform generator   
    Hi all. I've written a quick library to support the TLV5620 8-bit, quad-channel DAC from TI. This is a relatively powerful chip, and available in TI's magnificent sample program, in quantities of up to five in two temperature ranges (C and I).
     
    Anyways, as I'm lazy and don't want to rewrite my blog post here, and as I'd also like to attract more traffic to my blog, I'll just post the link here.
     
    If you have any questions or comments, feel free to leave them here or on my blog. I'll try to answer everything to the best of my knowledge
     
    Blog post:
    http://blog.suspended-chord.info/?c=9
  2. Like
    gatesphere got a reaction from Dimiric in Launchpad as external programmer   
    I haven't done this myself, but it seems to me that you have to connect Vcc and GND, and also at least RST and TEST. I'm not sure about TXD (P1.1) and RXD (P1.2), as I think they're only used for UART comm with the host PC. But, it couldn't hurt to attach them, unless you're using them in your circuit.
     
    The easiest way to program a chip in your breadboard from the launchpad would be to simply leave all the jumpers on at the top of the board, and connect to the proper pins of the chip on the breadboard by using jumper wires into the socket on the LaunchPad. The holes might be a bit tough to get jumpers in initially, but they'll eventually go in.
     
    Hope this helps!
  3. Like
    gatesphere got a reaction from jayachar88 in Is the MSPhere project work stopped completely ?   
    Hi Jay,
     
    Sorry to have let this lament for so long, but as far as I'm concerned, the MSPhere project is dead. I had some unfortunate life events pull me away from mcu work, and I've since lost interest in this project. Not to mention, there have been several other projects that attempt the same thing and pull it off much better than MSPhere... friendly_launchpad and EasyMSP come to mind, as does a neat little project porting the Arduino IDE to a LaunchPad compatible form: Energia. Hope this helps!
     
    -->Jake
  4. Like
    gatesphere got a reaction from gatImmusepete in The Gaming Thread!   
    I loved the HoN beta, when I was in it. But I can't really justify spending money on that game because I was terrible at it and don't have a headset.
  5. Like
    gatesphere got a reaction from boseji in Launchpad as external programmer   
    I haven't done this myself, but it seems to me that you have to connect Vcc and GND, and also at least RST and TEST. I'm not sure about TXD (P1.1) and RXD (P1.2), as I think they're only used for UART comm with the host PC. But, it couldn't hurt to attach them, unless you're using them in your circuit.
     
    The easiest way to program a chip in your breadboard from the launchpad would be to simply leave all the jumpers on at the top of the board, and connect to the proper pins of the chip on the breadboard by using jumper wires into the socket on the LaunchPad. The holes might be a bit tough to get jumpers in initially, but they'll eventually go in.
     
    Hope this helps!
  6. Like
    gatesphere reacted to NatureTM in Need Cooking Help !   
    Maybe you shouldn't lie to your friends.
     
    Try combining different types of meat. Wrap everything in bacon. Deep fry in oil whenever possible, especially with twinkies and oreos. The goal is to make everything as unhealthy as possible. When making burgers, substitute doughnuts for buns, a very popular dish. Frozen pizza is also very popular. Buy an extra bag of shredded cheese and add that to the frozen pizza. The trick is to cook the pizza half-way and then add the cheese. The secret to flavor is calories. I'm serious about that!
     
    You're welcome.
  7. Like
    gatesphere reacted to MattTheGeek in EasyMSP 0.8.2 Beta2 Released   
    I have just released the second beta of EasyMSP 0.8.2. Grab it while it's hot http://code.google.com/p/easymsp/downloads/detail?name=EasyMSP%200.8.2%20Beta2.zip
     
    Change Log:
     
    Added hardware SPI Functions:

    hspiConfig()
    hspiOut()
    hspiIn()

     
    Added Watchdog Functions:

    enableWD()
    disableWD()
    clearWD()
    enableTimer()
    disableTimer()

     
    Improved:

    Commenting
    Formatting

     
    I have also changed how you include EasyMSP, Please see the wiki for more information.
     
    Next on my list is Hardware I2C and software UART. One thing i do know is I2C WILL be included in EasyMSP 0.8.3, but i'm not sure about UART yet....
  8. Like
    gatesphere reacted to greeeg in Arrow flight logger   
    Hello fellow MSP430ers (is that the correct term),
     
    I've been using MSP430 chips for a couple months now, but this is my first time on this forum.
     
    Formalities aside, I have been working on a project to log flight pattens of arrows.
    I call it the arrowLog, it consists of 3 ICs : MSP430f2013, MMA7455, and a 25DF041a. As of right now I haven't written much software for it (made it blink some leds ) My hope is that I'll be able to use the MSP430 to read Acceleration data from the MMA7455 and store it in the dataflash IC. then later read out the results to a computer via a timer based UART.
     
    I included buttons and leds onto the design if I wanted to add fancy features, like starting/stopping datalogging.
     
    Here is some pictures of the prototype I have built.

     
    As of now I wont release the schematics unless anyone really wants them, once I've finished some more code I'll make a complete source/schematic package. along with a video.
  9. Like
    gatesphere reacted to bluehash in Quick and dirty 74HC595 shift register demo   
    Bumped to 5 quotes. First time someone has had a need for it.
  10. Like
    gatesphere reacted to MarkoeZ in A Noobs Introduction to MSP430 - Serial RC Car Video Blog   
    Hello people.
    I've been experimenting with the msp430, and working toward a goal. But thought i'd document every step. That way creating a complete video blog of the project, from the first steps, to hopefully something unique.
     
    So for now this is mainly for people new to microcontrollers and are interested in the Launchpad, or just bought one and don't know what to do with it. 43oh veterans: Probably not for you, but if you see errors in the video's please tell me so i can insert notes about them for future viewers
     
    Enjoy!:
     
    MarkoeZ MSP430 Launchpad Video's Part 1: Audio Intro
     
    MarkoeZ MSP430 Launchpad Video's Part 2: First part of the package contents
     
    MarkoeZ MSP430 Launchpad Video's Part 4: The Standard Temperature Sensing Program(with pc serial connection)
     
    MarkoeZ MSP430 Launchpad Video's Part 5: Leds and Buttons
     
    MarkoeZ MSP430 Launchpad Video's Part 6: Leds controlled through PC Serial Connection
     
    MarkoeZ MSP430 Launchpad Video's Part 7: Soldering, connections, and more
     
    MarkoeZ MSP430 Launchpad Video's Part 8: Created my LaunchPad Plugon Test Board
     
    MarkoeZ MSP430 Launchpad Video's Part 9: PC Soundcard Oscilloscope for testing:
     
    MarkoeZ MSP430 Launchpad Video's Part 10: Introducing a Porsche (rc car) Loud Noise Warning!!
     
    MarkoeZ MSP430 Launchpad Video's Part 11:RC Car controlled through PC Serial. Loud Noise Warning!!
     
    MarkoeZ MSP430 Launchpad Video's Part 12: Serial RC car, added connectors and first drive test!
     
    MarkoeZ MSP430 Launchpad Video's Part 13: The first Sensor, Cheap, but working, IR LED Collision Detection

     
    MarkoeZ MSP430 Launchpad Video's Part 14: Started work on the Car Drive Program *Noise Warning!*

     
    MarkoeZ MSP430 Launchpad Video's Part 15: Introducing an OpenPandora and an FT232RL usb to serial chip

     
    MarkoeZ MSP430 Launchpad Video's Part 16A: Created plugin sensors

     
    MarkoeZ MSP430 Launchpad Video's Part 16B: Plugin IR sensor test, and tools overview

     
    MarkoeZ MSP430 Launchpad Video's Part 17: Porsche with USB! Hardware building and status overview

     
    MarkoeZ MSP430 Launchpad Video's Part 18: Standalone G2252 First Tests, serial communication too

     
    MarkoeZ MSP430 Launchpad Video's Part 19: MSP on batteries, Main Board for the car updated with IR, power led and more

     
    MSP430 Launchpad Video 20: Porsche Nightrider Shiftregister

     
    MSP430 Launchpad Video 21: PWM On Board Leds, controlled by launchpad Serial

     
    MSP430 Launchpad Video 22: Added a button to the car and cut up the board

     
    MSP430 Intermediate 23: First Drive Test of the RC Porsche standalone!

     
    EDIT March-2-2012: Just noticed i never added the final thing. So, here it goes!
     
    My Contest Entry:
     
    A Porsche Model Car with an MSP430G2252, movement, speed and (just for fun) shiftregister LEDs controlled over usb Serial by a Pandora Console.
    With custom written Gui, And Touchscreen, D-Pad and ActionButton drive/program select.
    And yes, wireless is next, but still deciding what hardware i want.
     
    But the Video's show it pretty well, Enjoy!
     
    Drive Tests:


     
    Software overview and Final tests before drive:


     
    Some other video's i kept private till now:
     
    Very first Pandora gui test:

     
    First PC serial test with all modules connected, also nice overview of the individual modules:


     
     
    From the pandora you have basic drive control obviously, but also the PWM can be adjusted by single values, or 6 pre set steps, starting at 0 and increasing 20% with each step, and slider/buttons for quick selection.
    Also, just for fun, i added some commands to change the led blinking mode
     
    Components:
     
    MSP430 Main Car Control and Interface Board - Contains all the connections for the individual modules, as well as the Controller
    Parts:
    * 1 MSP430G2252
    * 1 20 pin DIP Chipsocket
    * 4 NPN Transistors
    * 4 2.2kohm Resistors
    * 1 33kohm Resistor
    * 1 470ohm Resistor
    * 1 470nF Capacitor
    * 1 Orange T1 LED
    * About a row of male Pin Headers
    * lots of connection cables (i use old hard drive IDE cables for everything)
     
     
    Shift Register Led Control Board - A shift Register built onto a small module containing all resistors for led drive
    Parts:
    * 1 74HC595 Shift Register
    * Chipsocket optional, i just soldered onto the board
    * 6 1kohm resistors (for the slightly dimmed knightrider leds, and one for the board power led)
    * 1 Orange T1 LED
    * about 1/4 of a row of male Pin Headers
    * connection cable (i use old hard drive IDE cables for everything)
    * min 5 port female Pin Header
     
    FT232R BreakoutBoard by Sparkfun
    Simply soldered male Pin Headers to it, and glued female headers with a cable inside the car. Instant usb module.
     
    Built into the car:
    * 5x T1 LED for the knightrider effect
    * 1 pushbutton
    * 5 pin female header with connection cables for the usb->serial module glued in.
     
    An OpenPandora - Gui is only functional for pandora atm. But any device capable of USB serial can drive it, using a terminal, or a Gui. It's only sending out to the car atm, so a simple "echo blabla" is enough.
     
    First rough schematics, Mind that these are the first schematics i have ever drawn in my life. I would like some constructive critics, but be gentle
     
    [attachment=0]PandoraPorschechematics.png[/attachment]
     
    And the code, again, might be rough at the edges:

    #include #include "stdbool.h" #include //add for interrupt #define PERIOD 200 //defines frequency volatile int timer = 0; //counts how many interrupts have been called //resets when it counts to PERIOD volatile int duty_cycle = 90;// max = PERIOD - 1 and min = 1 #define TXD BIT1 // TXD on P1.1 #define RXD BIT2 // RXD on P1.2 #define Bit_time 104 // 9600 Baud, SMCLK=1MHz (1MHz/9600)=104 #define Bit_time_5 52 // Time for half a bit. // Code for the ShiftRegister driving the LED's #define SHIFTDATA BIT7 // Shiftregister Data on P1.7 #define SHIFTCLOCK BIT7 // Shiftregister Clock Pulse on P2.7 #define SHIFTLATCH BIT6 // Shiftregister Latch Pulse on P2.6 #define STEERLEFT BIT4 // Left steering on P2.4 #define STEERRIGHT BIT5 // right steering on P2.5 bool shiftbit[8]; // array used to contain the shiftregister serial bits int activeled = 0; // used for led animation bool ledup = 1; int ledcounter = 0; int shifttimer = 0; // Timer to control shiftregister output speeds int blinkmode = 0; // 0 is knightrider, 1 is up and down bar, 2 is blinketyblink int steeringmode = 0; // 0 is neutral, 1 is left, 2 is right (right broken here though) void pulseShiftClock ( void ); void pulseShiftLatch ( void ); void setShiftReg ( void ); // ASCII values for the commands #define MODE0 0x30 // serial 1 #define MODE1 0x31 // serial 1 #define MODE2 0x32 // serial 2 #define MODE3 0x33 // serial 3 #define MODE4 0x34 // serial 4 #define MODE5 0x35 // serial 5 #define MODE6 0x36 // serial 6 #define MODE7 0x37 // serial 7 #define MODE8 0x38 // serial 8 #define PWMMODE0 0x61 // serial a #define PWMMODE1 0x62 // serial b #define PWMMODE2 0x63 // serial c #define PWMMODE3 0x64 // serial d #define PWMMODE4 0x65 // serial e #define PWMMODE5 0x66 // serial f #define BLINKMODE0 0x69 // serial i #define BLINKMODE1 0x6A // serial j #define BLINKMODE2 0x6B // serial k #define LED_SENSE INCH_6 // Photodiode connected to P1.6 unsigned int adcval = 0; // used for light sensing, nor really used in this case unsigned int timerCount = 0;// tomer for the sensing unsigned char BitCnt; // Bit count, used when transmitting byte unsigned int TXByte; // Value sent over UART when Transmit() is called unsigned int RXByte; // Value recieved once hasRecieved is set unsigned int drivestate = 0;// Dive neutral, forward or backward unsigned int i; // for loop variable bool isReceiving; // Status for when the device is receiving bool hasReceived; // Lets the program know when a byte is received void Transmit(void); void Receive(void); unsigned int analogRead(unsigned int pin) { // analog reading code, not really used in this case ADC10CTL0 = ADC10ON + ADC10SHT_2 + SREF_1 + REFON + REF2_5V; ADC10CTL1 = ADC10SSEL_0 + pin; ADC10CTL0 |= ENC + ADC10SC; while (1) { if ((ADC10CTL1 ^ ADC10BUSY) & ((ADC10CTL0 & ADC10IFG)==ADC10IFG)) { ADC10CTL0 &= ~(ADC10IFG +ENC); break; } } return ADC10MEM; } void main(void) { unsigned int i, delay; WDTCTL = WDT_MDLY_0_064; // Watchdog Timer interval setting if (CALBC1_1MHZ ==0xFF || CALDCO_1MHZ == 0xFF) { while(1); // If cal constants erased, trap CPU!! } BCSCTL1 = CALBC1_1MHZ; // Set range DCOCTL = CALDCO_1MHZ; // Set DCO step + modulation P1SEL |= TXD; // Connected TXD to timer P1DIR |= TXD; P1IES |= RXD; // RXD Hi/lo edge interrupt P1IFG &= ~RXD; // Clear RXD (flag) before enabling interrupt P1IE |= RXD; //P1DIR = 0X41; // set both leds to output // and set them off initially P2DIR |= 0X0A; //set P2 Drive pins P2DIR |= STEERLEFT; P2DIR |= STEERRIGHT; P1DIR |= SHIFTDATA; // set shiftregister data pin output P2DIR |= SHIFTCLOCK; // set shiftregister clock and latch pins to output P2DIR |= SHIFTLATCH; P2SEL = 0x00; // allow 2.6-2.7 to output P1OUT = 0; // Set both ports outputs to zero initially P2OUT = 0; isReceiving = false; // Set initial values hasReceived = false; IE1 |= WDTIE; __enable_interrupt(); // Enable interrupts __bis_SR_register(GIE); // interrupts enabled\ while(1) { shifttimer++; if (shifttimer == 2000) // The led animation and shiftregister main loop code { shifttimer = 0; if (blinkmode == 0 ) { if (ledup == 1) { activeled++; if(activeled == 4){ledup = 0;} } else { activeled--; if(activeled == 0){ledup = 1;} } for (i = 0; i < 8;i++) { if (i == activeled) { shiftbit[i] = 1; } else { shiftbit[i] = 0; } } } else if (blinkmode == 1) { if (ledup == 1) { activeled++; if(activeled == 4){ledup = 0;} } else { activeled--; if(activeled == 0){ledup = 1;} } for (i = 0; i < 8;i++) { if (i <= activeled) { shiftbit[i] = 1; } else { shiftbit[i] = 0; } } } else if (blinkmode == 2) { for (i = 0; i < 8;i++) { if (shiftbit[i] == 0) { shiftbit[i] = 1; } else {shiftbit[i] = 0;} } } setShiftReg(); } if (hasReceived) // If the device has recieved a value { Receive(); } if (drivestate == 9) // the sensing mode, not really used in this case { adcval = 0; for ( i=0; i < 8; i++ ) { adcval += analogRead(LED_SENSE ); // Read the analog input. delay = 1000; while (--delay); } if (adcval < 800 ){ drivestate = 1; duty_cycle = 110; delay = 1000000000; while (--delay); delay = 1000000000; while (--delay); delay = 1000000000; while (--delay); duty_cycle = 90; drivestate = 0; } } } } /** * Handles the received byte and calls the needed functions.\ **/ void Receive() { hasReceived = false; // Clear the flag switch(RXByte) // Switch depending on command value received { case MODE0: // don't drive drivestate = 0; break; case MODE1: // slow down if(duty_cycle >= 2) { duty_cycle--; } break; case MODE2: // drive backward drivestate = 2; break; case MODE3: // switch drive direction if (drivestate == 0){drivestate = 1;} else {drivestate = 0;} break; case MODE4: // steer left P2OUT &= ~STEERRIGHT; P2OUT |= STEERLEFT; steeringmode = 1; break; case MODE5: // center steering P2OUT &= ~STEERLEFT; P2OUT &= ~STEERRIGHT; steeringmode = 0; break; case MODE6: // steer right P2OUT &= ~STEERLEFT; P2OUT |= STEERRIGHT; steeringmode = 2; break; case MODE7: // speed up if(duty_cycle <= 198) { duty_cycle++; } break; case MODE8: // drive forward drivestate = 1; break; case PWMMODE0: duty_cycle = 1; break; case PWMMODE1: duty_cycle = 40; break; case PWMMODE2: duty_cycle = 80; break; case PWMMODE3: duty_cycle = 120; break; case PWMMODE4: duty_cycle = 160; break; case PWMMODE5: duty_cycle = 199; break; case BLINKMODE0: blinkmode = 0; break; case BLINKMODE1: blinkmode = 1; break; case BLINKMODE2: blinkmode = 2; break; default:; } } /** * Transmits the value currently in TXByte. The function waits till it is * finished transmiting before it returns. **/ void Transmit() { while(isReceiving); // Wait for RX completion TXByte |= 0x100; // Add stop bit to TXByte (which is logical 1) TXByte = TXByte << 1; // Add start bit (which is logical 0) BitCnt = 0xA; // Load Bit counter, 8 bits + ST/SP CCTL0 = OUT; // TXD Idle as Mark TACTL = TASSEL_2 + MC_2; // SMCLK, continuous mode CCR0 = TAR; // Initialize compare register CCR0 += Bit_time; // Set time till first bit CCTL0 = CCIS0 + OUTMOD0 + CCIE; // Set signal, intial value, enable interrupts while ( CCTL0 & CCIE ); // Wait for previous TX completion } #pragma vector=PORT1_VECTOR __interrupt void Port_1(void) { isReceiving = true; P1IE &= ~RXD; // Disable RXD interrupt P1IFG &= ~RXD; // Clear RXD IFG (interrupt flag) TACTL = TASSEL_2 + MC_2; // SMCLK, continuous mode CCR0 = TAR; // Initialize compare register CCR0 += Bit_time_5; // Set time till first bit CCTL0 = OUTMOD1 + CCIE; // Dissable TX and enable interrupts RXByte = 0; // Initialize RXByte BitCnt = 0x9; // Load Bit counter, 8 bits + ST } /** * Timer interrupt routine. This handles transmiting and receiving bytes. **/ #pragma vector=TIMER0_A0_VECTOR __interrupt void Timer_A (void) { if(!isReceiving) { CCR0 += Bit_time; // Add Offset to CCR0 if ( BitCnt == 0) // If all bits TXed { TACTL = TASSEL_2; // SMCLK, timer off (for power consumption) CCTL0 &= ~ CCIE ; // Disable interrupt } else { CCTL0 |= OUTMOD2; // Set TX bit to 0 if (TXByte & 0x01) CCTL0 &= ~ OUTMOD2; // If it should be 1, set it to 1 TXByte = TXByte >> 1; BitCnt --; } } else { CCR0 += Bit_time; // Add Offset to CCR0 if ( BitCnt == 0) { TACTL = TASSEL_2; // SMCLK, timer off (for power consumption) CCTL0 &= ~ CCIE ; // Disable interrupt isReceiving = false; P1IFG &= ~RXD; // clear RXD IFG (interrupt flag) P1IE |= RXD; // enabled RXD interrupt if ( (RXByte & 0x201) == 0x200) // Validate the start and stop bits are correct { RXByte = RXByte >> 1; // Remove start bit RXByte &= 0xFF; // Remove stop bit hasReceived = true; } __bic_SR_register_on_exit(CPUOFF); // Enable CPU so the main while loop continues } else { if ( (P1IN & RXD) == RXD) // If bit is set? RXByte |= 0x400; // Set the value in the RXByte RXByte = RXByte >> 1; // Shift the bits down BitCnt --; } } } #pragma vector=WDT_VECTOR __interrupt void watchdog_timer(void) { ++timer; if (timer == PERIOD) { timer = 0; if (drivestate == 1) // forward drive pwm { P2OUT |= BIT1; } else if (drivestate == 2) // backward drive pwm { P2OUT |= BIT3; } } if (timer == duty_cycle ) { P2OUT &= ~BIT1; P2OUT &= ~BIT3;} //end interrupt } void setShiftReg() // Sends the values of shiftbit[i] to the shiftregister { for (i = 0; i < 8; i++) { if (shiftbit[i] == 1) { P1OUT |= SHIFTDATA; } else { P1OUT &= ~SHIFTDATA; } pulseShiftClock(); P1OUT &= ~SHIFTDATA; } pulseShiftLatch(); } void pulseShiftClock() // pulse shiftregister clock pin { P2OUT |= SHIFTCLOCK; P2OUT &= ~SHIFTCLOCK; } void pulseShiftLatch() // pulse shiftregister latch pin { P2OUT |= SHIFTLATCH; P2OUT &= ~SHIFTLATCH; }
     
    Hope that was helpful
     
    Cheers!
     
    MarkoeZ
  11. Like
    gatesphere got a reaction from jsolarski in Trick for exposing female leads from male pin headers   
    Hi all, I just came up with a neat trick for getting female leads from a male-populated board. My MSP-EXP430FR5739 (which was so graciously gifted to me by a member of this forum ) came with male headers prepopulated. I don't really have much use for male headers, but I didn't want to unsolder the male pins because I'm sloppy and tend to lift traces when I do that... so I came up with this solution, involving two pin jumpers I had pulled from an old motherboard ages ago, and female headers that came packaged with the board. Check it out.
     

     
    Thought this might help someone out there
  12. Like
    gatesphere reacted to zeke in State Machine Example Code   
    Hi Guys,
     
    I've been thinking about the topic of state machines lately and I thought I'd try to whip up a posting on my approach to state machines.
     
    I've written a state machine for my client but I can't post that without a lot of changes. So I'm going to convert it into a traffic light state machine example.
     
    Hmmm... I just realized that I should talk about what a state machine is but I haven't got anything prepared yet. So, for now, I'll assume you know what it is.
     
    Here's my definitions and declarations:
     

    #include // add header file for MSP430G2231 device. #include #define VERSION(id, rev, tag) const char id##_version[] = "@(#)Id:" #id " Ver:" rev " Released by:" tag " Built:" __DATE__ " " __TIME__ #define INPUT 0 #define OUTPUT 1 #define TRUE 1 #define FALSE 0 #define HIGH 1 #define LOW 0 #define TOGGLE 2 #define nothing1 BIT0 // P1.0, 0x01, 0b0000 0001 #define onGREENLED BIT1 // P1.1, 0x02, 0b0000 1000 #define onREDLED BIT2 // P1.2, 0x04, 0b0001 0000 #define nothing2 BIT3 // P1.3, 0x08, 0b0000 0010 #define nothing3 BIT4 // P1.4, 0x10, 0b0000 0100 #define onYELLOWLED BIT5 // P1.5, 0x20, 0b0010 0000 #define nothing4 BIT6 // P1.6, 0x40, 0b0100 0000 #define nothing5 BIT7 // P1.7, 0x80, 0b1000 0000 #define TIMEBASE 16384 // This is selected ACLK/2, Production value = 16384 #define STARTTIMEOUT 5 // 5 seconds #define OVERALLTIMEOUT 43200 // 12hr*60min*60sec = 43200 seconds /******************************************************************************* * Global Variables * ******************************************************************************/ unsigned char TimerTick;
     
     
     
    So, here's my main function and interrupt routine. This will configure the msp430 to interrupt every TIMEBASE counts. In this case, the result is an interrupt every 0.25 seconds.
     

    void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer BCSCTL1 = CALBC1_1MHZ; DCOCTL = CALDCO_1MHZ; BCSCTL3 |= XCAP_3; // Launchpad watch crystals need ~12.5 pF // Configure all IO's and their default states on the MSP430 InitMSP430(); InitIOs(); // Initialize the system tick count TimerTick = 0; // Initialize all state machines InitTimerStateMachine(); InitTrafficLightStateMachine(); VERSION(TrafficLightStateMachineExample, "Alpha1", "Zeke"); _BIS_SR( GIE ); // Sooner or later, you're gonna have to Enter LPM3 w/ interrupt while(1) { // May have to add some servicing routines in here that aren't controlled by the 1 second timer // This is a place holder. // Decide on whether you're going to use an infinite loop or send the micro into LPM3 mode w/ Interrupts enabled. } } // Period of this interrupt is set in InitMSP430 #pragma vector=TIMERA0_VECTOR __interrupt void Timer_A(void) { // Update the system tick count every interrupt TimerTick++; // Update these state machines every 1 second if( TimerTick % 2 ) { UpdateTimerStateMachine(); UpdateTrafficLightStateMachine(); } // Update the output state of each control line every 0.5 seconds UpdateIOs(); }
     
     
    And here's my InitMSP430() function:

    /******************************************************************************* * InitMSP430() * * Initializes the resources of the MSP430 for this program. * ******************************************************************************/ void InitMSP430( void ) { // Configure these I/O pins to outputs pinModeP1( onGREENLED, OUTPUT ); pinModeP1( onREDLED, OUTPUT ); pinModeP1( onYELLOWLED, OUTPUT ); // Set these Outputs to default states digitalWriteP1( onGREENLED, HIGH ); digitalWriteP1( onREDLED, HIGH ); digitalWriteP1( onYELLOWLED , HIGH ); // Configure the TimerA to run at a 1 second rate CCTL0 = CCIE; // CCR0 interrupt enabled CCR0 = TIMEBASE-1; // 0.25 second timer operation TACTL = TASSEL_1 + MC_1; // ACLK, upmode }
     
    So, these are the files that will lay the foundation for a well balanced state machine. In this example, I'm going to simulate a traffic light state machine. It seems to me that it is the example that every prof uses in control systems lab class.
     
    I haven't posted up the routines that really matter yet. Namely, the UpdateStateMachine() functions. They are the gears in this transmission.
     
    So, stay tuned for more. I hope you will like this.
  13. Like
    gatesphere got a reaction from bluehash in Trick for exposing female leads from male pin headers   
    Hi all, I just came up with a neat trick for getting female leads from a male-populated board. My MSP-EXP430FR5739 (which was so graciously gifted to me by a member of this forum ) came with male headers prepopulated. I don't really have much use for male headers, but I didn't want to unsolder the male pins because I'm sloppy and tend to lift traces when I do that... so I came up with this solution, involving two pin jumpers I had pulled from an old motherboard ages ago, and female headers that came packaged with the board. Check it out.
     

     
    Thought this might help someone out there
  14. Like
    gatesphere got a reaction from oPossum in Trick for exposing female leads from male pin headers   
    Hi all, I just came up with a neat trick for getting female leads from a male-populated board. My MSP-EXP430FR5739 (which was so graciously gifted to me by a member of this forum ) came with male headers prepopulated. I don't really have much use for male headers, but I didn't want to unsolder the male pins because I'm sloppy and tend to lift traces when I do that... so I came up with this solution, involving two pin jumpers I had pulled from an old motherboard ages ago, and female headers that came packaged with the board. Check it out.
     

     
    Thought this might help someone out there
  15. Like
    gatesphere reacted to gordon in The portable LaunchPad   
    No, really. The portable LaunchPad .
     
    Some time back I inherited a big pile of used, impractical-to-reuse DAT tapes. They've been lying around not doing much useful, but the arrival of the LaunchPad triggered an idea: their cases are ideal containers for small stuff.
     
    I keep an LP and a separate box of assorted random junk in my backpack all the time; they are safe (the cases are quite sturdy and close well), and are always at hand, should some time for a hacking session be found.
     

    Add a third one with one of these tiny breadboards and a couple of flexible jumper wires, and you have a full-fledged lab-on-the-go in space less than two packs of cigarettes .
     
    The cases also make nice storage for components in general -- a bit hard to fish things out of them (definitely harder than these storage units with drawers), on the plus side it's also much harder to spill half a million stingy beasts on the carpet.
  16. Like
    gatesphere reacted to bluehash in Private message spam   
    You may have noticed a PM from a spammer. We apologize for that. Private messaging has been now limited to 3 recipients(at a time) only and a 1 minute wait time between messages.
  17. Like
    gatesphere reacted to fj604 in Disconnect LED2 to use I2C on Launchpad   
    The SCK line for on MSP430G2231 is the same as P1.6, which is connected to LED2 on the Launchpad. SCK is supposed to be pulled up for I2C to work, therefore you will have to disconnect the jumper J5 - 1.
     
    If you do not, LED2 will glow a faint green as it is would be connected to VCC through a pullup, and I2C will not work at all.
     
    This took me a while to figure - I thought I'd share.
  18. Like
    gatesphere got a reaction from jsolarski in Writing a roguelike game, just thought I'd share...   
    Chapter two: http://blog.suspended-chord.info/?c=37
     
    Also, new colors.
  19. Like
    gatesphere reacted to jsolarski in Chicago land events   
    2 upcoming events in the Chicago Area
     
    First - June 4th http://lizrevision.com/6-4-2011-4th-ann ... -sale.html

     
    second is another meetup for workshop88 Date to be decided probably a Thursday night in June/
    http://www.meetup.com/workshop88/events/20216231/
  20. Like
    gatesphere reacted to rockets4kids in how to optimize code?   
    In an equation like this, the time-killer is the division. One divide will take far more cycles than all the rest combined, no matter how well optimized. If you are diving by a constant, look into a "fast divide" routine.
     
    Here is an example:
     
    http://www.hackersdelight.org/divcMore.pdf
  21. Like
    gatesphere reacted to bluehash in Ideas to share more code   
    Posting here as some members miss out on reading the Announcements/Suggestion Posts.
     
    We were thinking about introducing a program where members were given an incentive to write and share code. Lets say member NatureTM is interested in using an accelerometer for his project, but would like some ready to use code. But he doesn't. On top of that, he'll have to invest in an accelerometer breakout. This is where 43oh and the community come in.
     
    Let's call this program "The Code Pot" or "The Community Pot", where you suggest what you need, and we'll try to get the hardware to you. We have been having advertising for a couple of months and we sure can spare some amount to this. There will also be a donate button, if anyone wishes to contribute to the post.
     
    So NatureTM selected a breakout for an accelerometer from Sparkfun. Once there is enough money in the Pot, we'll ship the the hardware to him, directly from the vendor. NatureTM will now be able to write code and share it. He's free to keep the hardware or share it. Be aware that all transactions and member assignments and will be public.
     
    Things to take care of.
    - Following proper code structure.
    - Abuse. Suggesting a hardware, but do not write software for it.
    - Shipping costs. Reasonable(
    - Still thinking...
     
    So how do you guys like it? Would you welcome this? We think it is a great learning and sharing opportunity.Looking forward to your views.
  22. Like
    gatesphere got a reaction from zeke in The Party Thread!   
    *orders a shirley temple*
    *gets stared at* Whaaat? They're tasty.
  23. Like
    gatesphere reacted to RobG in Disassembly in C/C++ perspective   
    You can enable .asm output file.
    Right click on the project folder -> Build Properties -> C/C++ Build -> Tool Settings -> Assembler Options (under MSP430 Compiler)
    There, check "Keep the generated assembly...," "Generate listing file," and select Generate C source interlisted..." in "Source interlist" drop down.
    The only option that would be useful and looks like it's missing is "--absolute_listing"
  24. Like
    gatesphere reacted to gordon in Guidelines for the Use of the C Language   
    If you program (or plan to program) in C, MISRA (Wikipedia) sells a document titled Guidelines for the Use of the C Language in Critical Systems (Wikipedia).
     
    I found that to be a well-though-out source of information for general secure coding techniques. It focuses on embedded usage, but most of the principles apply generally. The document includes the guidelines themselves, rationale and example code as well.
     
    What included are really things that should be natural and evident for all C programmers (embedded or not), but (in my experience) sadly courses or books dealing with security stuff are either few and far between or are too focused on one particular system/environment (certainly not embedded). This is a very condensed representation of the whys and hows of the pitfalls and the way to avoid them all of us should have been taught in school (or should be in a new edition of K&R at the very least). It will not make you an expert overnight, but it will be eye-opening.
     
    If you are a C beginner, some of the items may be overwhelming (or outright scary); if you are a seasoned veteran, there still might be angles you have not thought of before. Some of it is definitely an overkill for a hobbyist, but following the general principle might help one not burning the barn or irrigating a new Lake Victoria in the back yard .
     
    The current version (MISRA C2) deals with C89 only; MISRA C3 (which will include C99 constructs as well) is said to come later this year, so blackmailing Santa might be a good idea .
     
    I am not a frequent standards buyer, but I figure that GBP10 (+tax, if applies), for which you get a 100+ page PDF document (watermarked to your name) borders on impulse buying for a document of this kind.
     
    (Apart from having bought it, not affiliated with them.)
  25. Like
    gatesphere reacted to MattTheGeek in EasyMSP 0.8.2 Beta released   
    I've released a beta that fixes some timing issues and adds hardware and software SPI. software SPI is tested but hardware SPI isn't.
     
    Please check it out: http://code.google.com/p/easymsp/downloads/detail?name=EasyMSP%200.8.2%20Beta.zip&can=2&q=#makechanges
×
×
  • Create New...