Jump to content


  • Content Count

  • Joined

  • Last visited

  • Days Won


Reputation Activity

  1. Like
    jsolarski got a reaction from RobG in PWM from 2 Analog input in MSP430G2231 ?   
    //****************************************************************************** // MSP430F20x2 Demo - ADC10, DTC Sample A1 32x, 1.5V, Repeat Single, DCO // // Description: Use DTC to sample A1 32 times with reference to internal 1.5v. // Vref Software writes to ADC10SC to trigger sample burst. In Mainloop MSP430 // waits in LPM0 to save power until ADC10 conversion complete, ADC10_ISR(DTC) // will force exit from any LPMx in Mainloop on reti. ADC10 internal // oscillator times sample period (16x) and conversion (13x). DTC transfers // conversion code to RAM 200h - 240h. P1.0 set at start of conversion burst, // reset on completion. // // MSP430F20x2 // ----------------- // /|\| XIN|- // | | | // --|RST XOUT|- // | | // >---|P1.1/A1 P1.0|-->LED // // L. Westlund // Texas Instruments Inc. // May 2006 // Built with CCE Version: 3.2.0 and IAR Embedded Workbench Version: 3.41A //****************************************************************************** #include "msp430x20x2.h" void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop WDT ADC10CTL1 = CONSEQ_2+INCH_1; // Repeat single channel ADC10CTL0 = SREF_1 + ADC10SHT_2 + MSC + REFON + ADC10ON + ADC10IE; __enable_interrupt(); // Enable interrupts. TACCR0 = 30; // Delay to allow Ref to settle TACCTL0 |= CCIE; // Compare-mode interrupt. TACTL = TASSEL_2 + MC_1; // TACLK = SMCLK, Up mode. LPM0; // Wait for delay. TACCTL0 &= ~CCIE; // Disable timer Interrupt __disable_interrupt(); ADC10DTC1 = 0x20; // 32 conversions ADC10AE0 |= 0x02; // P1.1 ADC option select P1DIR |= 0x01; // Set P1.0 output for (; { ADC10CTL0 &= ~ENC; while (ADC10CTL1 & BUSY); // Wait if ADC10 core is active ADC10SA = 0x200; // Data buffer start P1OUT |= 0x01; // Set P1.0 LED on ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start __bis_SR_register(CPUOFF + GIE); // LPM0, ADC10_ISR will force exit P1OUT &= ~0x01; // Clear P1.0 LED off } } // ADC10 interrupt service routine #pragma vector=ADC10_VECTOR __interrupt void ADC10_ISR(void) { __bic_SR_register_on_exit(CPUOFF); // Clear CPUOFF bit from 0(SR) } #pragma vector=TIMERA0_VECTOR __interrupt void ta0_isr(void) { TACTL = 0; LPM0_EXIT; // Exit LPM0 on return } straight from the code examples
    you have to wait for the conversion to finish before sending it to the buffer
  2. Like
    jsolarski reacted to bluehash in PWM from 2 Analog input in MSP430G2231 ?   
    Do a step over.
    Also, some example code:

  3. Like
    jsolarski reacted to gatesphere in Peeked in a dumpster, and look what I found...   
    A Heath-Zenith Microcomputer Learning Kit, Model ETW-3400-A.

    EDIT: Just plugged it in, and it works! I just need to find a manual. :D:D
  4. Like
    jsolarski reacted to MochaSatin in Generating random numbers.   
    Here is a small code snippet for the linear congruential generator. Adjust for you needs:
    int main()
    int M = 256;
    int a = 65;
    int c = 27;
    int X = 1;
    int i;
    for(i=0; i<256; i++)
    X=(a * X + c) % M;
    printf("%d ", X);
    return 0;
    92 119 82 237 72 99 62 217 52 79 42 197 32 59 22 177 12 39 2 157 248 19 238 137
    228 255 218 117 208 235 198 97 188 215 178 77 168 195 158 57 148 175 138 37 128
    155 118 17 108 135 98 253 88 115 78 233 68 95 58 213 48 75 38 193 28 55 18 173 8
    35 254 153 244 15 234 133 224 251 214 113 204 231 194 93 184 211 174 73 164 191
    154 53 144 171 134 33 124 151 114 13 104 131 94 249 84 111 74 229 64 91 54 209
    44 71 34 189 24 51 14 169 4 31 250 149 240 11 230 129 220 247 210 109 200 227 19
    0 89 180 207 170 69 160 187 150 49 140 167 130 29 120 147 110 9 100 127 90 245 8
    0 107 70 225 60 87 50 205 40 67 30 185 20 47 10 165 0 27 246 145 236 7 226 125 2
    16 243 206 105 196 223 186 85 176 203 166 65 156 183 146 45 136 163 126 25 116 1
    43 106 5 96 123 86 241 76 103 66 221 56 83 46 201 36 63 26 181 16 43 6 161 252 2
    3 242 141 232 3 222 121 212 239 202 101 192 219 182 81 172 199 162 61 152 179 14
    2 41 132 159 122 21 112 139 102 1
  5. Like
    jsolarski got a reaction from bluehash in Generating random numbers.   
    TI has an application note on the same subject
    it may be able to give a good start, i know using 2 independent clock sources may not be viable but its worth a look
  6. Like
    jsolarski got a reaction from bluehash in Interfacing 3x4 with keypad matrix   
    it looks like your polling the keypad, so my suggestion is add a small delay after a key is press is detected, just something small like a few mS and then continue polling.
  7. Like
    jsolarski reacted to DanAndDusty in power solution for MSP430   
    One other possibility that hadn't occured to me until I read Using power solutions to extend battery life in MSP430 applications is the difference in current used by the MSPs at different voltages. Im not sure that it applies to the value line range as the slope isn't as steep but I haven't looked at it in depth.
    I haven't looked into whether these factors are as important with the valuelines.. but looking at Page 17 of the Spec Sheet for the MSP430G2231 the graph of active mode current vs Vcc.. At 1MHz it looks like the current goes from approx 0.2mA at 1.8V upto approx 0.6ma at 3.6V.. so 3x the current (for the time the device is in Active mode not Low Power)... at 8MHz the graph seems to go from about 1.2mA at 2.2v upto 2.4mA at 3.6v..
    So this is matters less the more time your device spends in Low Power mode (when quiescent current of the LDO matters more) but it is another spice to add into the old melting pot
    Personally I use a 3.3v LDO on breadboard with Vcc<->Vss Cap, RST pullup resistor. I feed that from an adjustable (unregulated) wall wort I run at 4.5V, but I have swapped the wall wort out for a 9v Battery when messing about with LED strings. I have even run the breadboard and a Nokia 3310 LCD screen off 2 Solar panels salvaged from Solar Garden LEDs bought from Poundland (didn't expect that to work but very glad when it did ) So basically I use an LDO so I can throw just about any supply in there without worrying much at all. The LDO is so simple, TO-92 package, and 2 Caps.. steady as a rock. But as I said, I hardly ever run it off batteries for any length of time.
  8. Like
    jsolarski reacted to touch in Dual PWM with TimerA1   
    #include void main(void) { WDTCTL = WDTPW + WDTHOLD; // Kill WDT P2DIR |= BIT2 + BIT5; // P2.2 and P2.5 output P2SEL |= BIT2 + BIT5; // P2.2 and P2.5 options select TA1CCR0 = 128; // PWM period TA1CCTL1 = OUTMOD_6; // CCR2 reset/set TA1CCR1 = 32; // CCR1 25% PWM duty cycle TA1CCTL2 = OUTMOD_6; // CCR2 reset/set TA1CCR2 = 6; // CCR2 5~% PWM duty cycle TA1CTL = TASSEL_2 + MC_1 + TACLR; // SMCLK, up mode, clear TAR __bis_SR_register(LPM0_bits); //LPM 0 while(1){ } }
    Here's some simple code for using TimerA1 to generate 2 PWM signals on the G2553. TimerA0 could also be used, but on the PDIP versions only has two of the three CCR's accessible I believe.
  9. Like
    jsolarski reacted to touch in MSP-EXP430FR5739 Experimenter Board - New DEV board   
    Anyone seen this?
    https://estore.ti.com/MSP-EXP430FR5739- ... x-pr-ek-es
    I'm definitely picking one of these up... I hope that we get some 50% off coupons soon for the TI store .
    Seems interesting they included a 3 axis accelerometer and a temperature sensor.
  10. Like
    jsolarski got a reaction from bluehash in Playing music   
    #include is for interrupts in mspgcc
  11. Like
    jsolarski reacted to nexusone1984 in 6 digit display temperature demo   
    More playing around with the 74hc595 and a 6 digit LED display from a older project.
    Demo shows how to display in decimal and hexadecimal, selecting a digit among a group of digits.

  12. Like
    jsolarski reacted to Rickta59 in Full-duplex software UART for launchpad   
    So this code snippet springs forth from my desire to use a terminal emulator ( I like putty best ) with my launchpad via the built-in COM port. Simple I think, someone must have already done this by now, no? Well, trying to find a working example for the launchpad led me down a lot of dead ends with nothing that worked well. I did find examples that were half-duplex and ones that required more Timer features than you find on the msp430g2231. Unfortunately, none of them fit my requirements.
    My goal was to find something that would allow me to use higher DCO clock speeds such as 16MHZ. I also wanted to be able to run reliably with 115k baud rates, so that I can connect a serial to TCP proxy and make my launchpad web enabled.
    I've implemented something here that meets both of those goals. Well sort of. I discovered that the COM port on the launchpad will only work up to 9600 baud. However, you can disconnect the jumpers and plug your RX/TX lines into an FT232RL device and get higher speeds. It also works well if your goal is to interface to some other device via TTL level RS232, say a GPS device.
    You can find the code here:
    Because everything is better with pictures, I took a snapshot of the RX line receiving the character 'U' at 9600 baud. 'U' is unique in that it forms a perfect clock wave 0 10101010 1 when you add the stop and start bits. The green line is the RX line, the red line is me toggling a debug pin inside of the RX ISR routine. I used a program called Soundcard Oscilloscope that helped me dial in the proper timing so that I was sampling in the center of each data bit. http://www.zeitnitz.de/Christian/scope_en

    In the picture above, you'll notice that the first red crossing takes longer than the other samplings, that is because we just ignore the value of the start bit and start sampling in the center of the first data bit.
    To use and test the code, download it from github and bring it into CCS. Once it is running figure out which COM port your launchpad is using and connect to it with a terminal emulator like putty or minicom using 9600 baud. The default configuration expects you to have soldered a 32.768k crystal to the launchpad board. It uses the crystal to calibrate the DCO for a higher MHZ speed. Don't worry, I don't write it to flash, I just calibrate it and use it. However, you can edit the config.h to modify the baud rate and MCLK speed. You can even run it at the default MCLK speed. See the config.h file comments for more information.
    I think I've commented the code fairly well. However, this is actually my first published project with the MSP430 launchpad so comments are welcome. So enjoy!
  13. Like
    jsolarski got a reaction from SugarAddict in Anyone notice ...   
    I say name it "plaid" lol
  14. Like
    jsolarski reacted to zeke in Anyone notice ...   
    I'm reading through the datasheetright now and I just discovered that this part holds a juicier secret.
    Check out page 50. It is possible to crank up the DCO to 135MHz!
    This means that you can run peripherals at 135MHz ie: SPI bus.
    My samples are ordered.
    Time to make a dev board.
  15. Like
    jsolarski reacted to lpdc in RGB color matching game - MSP430G2231 + Launchpad + ADC   
    Hello everyone,
    2 or 3 months ago, I announced here that, as a first project, I would like to program a color matching game inspired by the Amazing Dr. Boardman's Conundrum.
    I want to thank everyone who answered the post and gave me pointers.
    This is what I have achieved so far :

    Schematics of the circuit :

    The code is pasted below, largely inspired from the tutorials and examples at
    http://www.msp430launchpad.com/2010/09/ ... chpad.html
    As I said, this is my first try ever at programming micro controllers, so the code is probably rather ugly and not as efficient as it should.
    I am looking forward to any comments and suggestions as my goal is to learn and improve this program.
    As a next step, I would like to add a piezzo buzzer on the last available pin (2.6) in order to give some feedback during the game (modulating the sound according to the color difference). I have no clue yet how I will implement this. Any ideas/pointers welcome.
    Thanks again for the help, I would not have gone this far without it.

    /* ****** Color matching game. By Fabrice C. ****** This is my first program with a microcontroller so everything is probably not as pretty as it should... Original inspiration came from : http://www.fangletronics.com/2010/02/amazing-dr-boardmans-colour-conundrum.html A lot of code was inspired by the tutorials/examples from : http://mspsci.blogspot.com/ and http://www.msp430launchpad.com/2010/09/simple-adc-example-on-launchpad.html and http://blog.hodgepig.org/2010/09/30/jam-jar-lamp/ */ #include #include #include #include /****************************************************/ #define P1_LED_BIT (BIT0|BIT1|BIT2|BIT6|BIT7) #define P2_LED_BIT (BIT6) /****************************************************/ static volatile uint8_t led_brightness[6] = {0x00,0x00,0x00,0x00,0x00,0x00}; // This variable stores the brightness of the 2 RGB leds : {R1,G1,B1,R2,G2,B2} static volatile uint32_t sys_ticks = 0; // Used to keep track of PWM static volatile bool ADCDone = false; // Flag to check that the ADC sampling is done static volatile uint16_t ADCValue; // Result of ADC (converted value) static volatile int sampled_channel; // Channel being sampled by ADC static volatile int seed; // seed for random number generation /****************************************************/ static void cpu_init(void) // Initialisation of the micro controller { WDTCTL = WDTPW + WDTHOLD; // Stop Watch dog timer // configure system clock to about 16MHz BCSCTL1 &= ~(BIT0 + BIT1); // set bits 0 and 1 to 0 BCSCTL1 |= BIT2 + BIT3; // set bits 2 and 3 to 1 DCOCTL &= ~(BIT5 + BIT7); // set bits 5 and 7 to 0 DCOCTL |= BIT6; // set bit 6 to 1 // seems like overkill but lower frequencies generated // quite a lot of flickering. PWM algo/usage may need improvement _enable_interrupt(); // to be able to use interrupts // Without this the timer and ADC callback functions would never be called. } bool match(volatile int delta) // function returning true if the 2 RGB values are within // a distance "delta" (euclidian distance) { volatile int Dr; volatile int Dg; volatile int Db; Dr = led_brightness[0]-led_brightness[3]; Dg = led_brightness[1]-led_brightness[4]; Db = led_brightness[2]-led_brightness[5]; volatile unsigned int D;//no sqrt so no need for double D = (unsigned int)((Dr*Dr)+(Dg*Dg)+(Db*Db)); // cannot manage to do a sqrt without getting a compiling error // so I am comparing the 2 squared values instead. if ( D <= (delta*delta)) return true; else return false; } void win (void) // Procedure to show the player he won. Right now it is only blinking the LEDs // To do : add some music there { volatile int R; volatile int G; volatile int B; R= led_brightness[3]; G= led_brightness[4]; B= led_brightness[5]; // saves current RGB values of the target color //LEDs off led_brightness[0] = 0; led_brightness[1] = 0; led_brightness[2] = 0; led_brightness[3] = 0; led_brightness[4] = 0; led_brightness[5] = 0; unsigned int n; unsigned int i; for (i=0; i<10; i++) // blinks the 2 RGB leds 10 times { for (n=0; n<3000; n++); // delay // LEDs on led_brightness[0] = R; led_brightness[1] = G; led_brightness[2] = B; led_brightness[3] = R; led_brightness[4] = G; led_brightness[5] = B; for (n=0; n<3000; n++); //delay //LEDs off led_brightness[0] = 0; led_brightness[1] = 0; led_brightness[2] = 0; led_brightness[3] = 0; led_brightness[4] = 0; led_brightness[5] = 0; } } // Binary Code Modulation static void bcm_tick(uint8_t led_ticks) { uint8_t bcm1 = 0x00; uint8_t bcm2 = 0x00; // This commented code does not work so I used the code from // http://www.msp430launchpad.com/2010/09/simple-adc-example-on-launchpad.html // instead // if (led_brightness[0] <= led_ticks) // bcm1 |= BIT0; // if (led_brightness[1] <= led_ticks) // bcm1 |= BIT1; // if (led_brightness[2] <= led_ticks) // bcm1 |= BIT2; // // if (led_brightness[3] <= led_ticks) // bcm1 |= BIT6; // if (led_brightness[4] <= led_ticks) // bcm1 |= BIT7; //To be fixed : may want the BIT6 on this port to also stay on. // if (led_brightness[5] <= led_ticks) // bcm2 |= BIT7; // // P1OUT = bcm1; // P2OUT = bcm2; // switch(led_ticks) { case 0x1: case 0x2: case 0x4: case 0x8: case 0x10: case 0x20: case 0x40: case 0x80: // led_ticks is a power of 2 if (led_brightness[0] & led_ticks) bcm1 |= BIT0; if (led_brightness[1] & led_ticks) bcm1 |= BIT1; if (led_brightness[2] & led_ticks) bcm1 |= BIT2; if (led_brightness[3] & led_ticks) bcm1 |= BIT6; if (led_brightness[4] & led_ticks) bcm1 |= BIT7; //To be fixed : may want the BIT6 on this port to also stay on. // Especially if we want to put a buzzer on BIT6 if (led_brightness[5] & led_ticks) bcm2 |= BIT7; P1OUT = bcm1; P2OUT = bcm2; } } // Timer0 ISR #pragma vector=TIMERA0_VECTOR __interrupt void Timer_A (void) //Call back function when the timer ticks { bcm_tick(sys_ticks); sys_ticks++; // Following was meant to work with other BCM function but did does not work. // if (sys_ticks > 255 ) // sys_ticks = 0; // This was meant to enter low power mode but interrups stopped for some reason //__bis_SR_register(CPUOFF + GIE); //__bic_SR_register_on_exit(CPUOFF); } void Single_Measure(unsigned int chan) // Frunction starting the ADC sampling { ADC10CTL0 &= ~ENC; // Disable ADC ADC10CTL0 = ADC10SHT_3 + ADC10ON + ADC10IE; // 16 clock ticks, ADC On, enable ADC interrupt ADC10CTL1 = ADC10SSEL_3 + chan; // Set 'chan', SMCLK ADC10CTL0 |= ENC + ADC10SC; // Enable and start conversion } #pragma vector=ADC10_VECTOR __interrupt void ADC10_ISR (void) // Call back function for when the ADC sampling is done { ADCValue = ADC10MEM; //saves measured value from register into ADCValue variable ADCDone = true; // sets the flag acknowledging that the ADC is done //__bic_SR_register_on_exit(CPUOFF); } void Generate_New_Target(void) // Generates a random color for the target of the game { uint32_t T = 0; while (1) { led_brightness[3] = rand(); led_brightness[4] = rand(); led_brightness[5] = rand(); T = led_brightness[3] + led_brightness[4] + led_brightness[5]; // We check the total brightness of the 3 components as we don't want a // color to be too dark or too white if (500 > T < 200) break ; } } int main(void) // Main Program { cpu_init(); // setup LED pins P1DIR |= P1_LED_BIT; // All LED pins as outputs //select i/o function of pins P2SEL &= ~(BIT6|BIT7); // Acitvates the 2 ports on pins 12 and 13 //set them as outputs P2DIR = BIT6 | BIT7; P2OUT &= ~(BIT6|BIT7); P1OUT &= ~P1_LED_BIT; // Turn off LED // TimerA SMCLK in UP mode TACTL = TASSEL_2 | MC_1; // Enable interrupt for TACCR0 match TACCTL0 = CCIE; // Set TACCR0, starts timer. TACCR0 = 110; // This must be short enough to look good and long enough for TIMER0_ISR to complete // but I don't really understand the magic number //Measures the value of Channel 3 (R potentiometer) Single_Measure(INCH_3); while (1) // waits until the measurement is finished { if (ADCDone) break; } ADCDone = false; seed = ((uint32_t)ADCValue*255)/990; // uses the measured value as the seed for random number generation // if a constant seed is used, the order in which the target colors // are asked will always be the same when the micro controller is reset. // This way, provided the R potentiometer was changed since last time, // a new color will be asked first. (crude but it works most of the time) srand(seed); // Sets the R, G, and B brightness of the target color to a random value Generate_New_Target(); Single_Measure(INCH_3); sampled_channel = 1; // Keeps track of the channel being measured while(1) // Endless loop { if (ADCDone) // if we have a measurement result available { ADCDone = false; // my potentiometers are not the best ones, I never // manage to get the sampled value up to 1023 // so I clip everything to 990 in order to make // sure that the player can dial in a maximum // brightness value of FF if (ADCValue > 990) ADCValue = 990; switch(sampled_channel) { // adjust the brightness of a LED to the value // measured on the corresponding potentimeter // and makes ready to sample the next channel case 1: led_brightness[0] = ((uint32_t)ADCValue*255)/990; Single_Measure(INCH_4); sampled_channel = 2; break; case 2: led_brightness[1] = ((uint32_t)ADCValue*255)/990; Single_Measure(INCH_5); sampled_channel = 3; break; case 3: led_brightness[2] = ((uint32_t)ADCValue*255)/990; Single_Measure(INCH_3); sampled_channel = 1; break; } } // tests if the dialed in values are close enough to the target if (match(5) == true) { win(); // display winning animation // Sets a new color as target Generate_New_Target(); } } }
  16. Like
    jsolarski reacted to RobG in How to safely connect a pot to the ADC   
    See the family user guide.
    Simplifying things, during sampling, a switch for the selected channel is closed and charges tiny capacitor (~27pF) and that is the only current flowing through this circuit, we are talking uA here over the period of few us. Once the cap is charged, there is no more current flowing. Then that switch is opened and another closed, one that connects the capacitor to a comparator. Comparator then compares capacitor's voltage to a reference voltage which is connected through resistor network (basically a DAC.)
    When the whole converting cycle is done, SAR's value is written to memory register.
    How SAR works?
    For example you have 15V voltage reference and a 4 bit SAR with a ladder of resistors that can output 0-15V, bit0 1V, bit1 2V, bit2 4V, and bit3 8V. It's output is connected to a comparator. S&H capacitor is also connected to a comparator and is charged during sampling cycle to 7V.
    Converting cycle begins and bit3 is turned on, comparing 8V to 7V, because it's bigger, bit3 stays off, next bit2 is on and 4V is compared to 7V, since 4V is smaller than 7V bit2 stays on, then bit1 is set, comparing 6V to 7V (6V because bit2 is still on 4V + 2V.) 6 is less than 7, bit1 is on. Next bit0, 7V is not more than 7V, bit0 is on. End of converting cycle, SAR register is 0111 and it's written to mem register.
    How many cycles this whole process takes?
    You must have enough cycles to charge the capacitor (sampling time,) the bigger output resistance of the measured circuit, the longer it will take to charge it. This usually takes few us, but sometimes when you have dividers with mega ohm resistors, it may take several tens of us.
    The comes converting, one cycle for each bit of resolution so 10bit ADC will require 10 cycles.
    Figuring out sampling time is important because it will introduce error if it is too short and the capacitor is not charged to the input voltage.
  17. Like
    jsolarski reacted to zeke in e2e website is like a chicken coop   
    I went over to the e2e.ti.com website today just to see what's going on.
    I gotta say, if you could hear it out loud, that place would be like the Grand Central Station of chicken coops!
    There's a zillion people asking questions and few answers coming back to them.
    I don't know if you could call that place "organized" chaos but you could call it chaotic.
    Too bad the TI guys don't hang out here. They'd find this forum like a pleasant trip to the Weekend Cottage at the Lake.
    Ooo! Maybe I shouldn't say anything. It might turn into an episode of The Great Outdoors!
  18. Like
    jsolarski reacted to nexusone1984 in Temperature demo 2, using 2 digit LED display CC   
    A poster asked about using Common cathode display, just happens that is the type I had in hand.
    And had been wanting to use the 74hc595 in driving LED's, so this is what I came up with.
    I used of code I created for my first LED display project as a base.
    I have drawn a schematic in Eagle for this project, which I have posted on my website in PDF format for those without Eagle.
    The code has some interesting bits in it.... Binary to Decimal conversion, Seven segment truth table example, writing to the 74hc595, multiplexing LED's.
  19. Like
    jsolarski reacted to RobG in TLC5940... no lights? - Solved (Code & video) (twice)   
    Have you seen Demystifying TLC5940 book?
    I started going through it after I got my samples, but due to lack of time I was never able to put it into use.
  20. Like
    jsolarski reacted to zeke in Can't flash the MSP430 with Launchpad - stuck at step 0 :(   
    It sounds like the TI drivers for the Launchpad are not installed yet.
    You should verify that your PC can see the LP in the Device Manager as a TI Comm Port.
    Assuming you're using Windows:
    - Press "WindowsKey R",
    - Enter "devmgmt.msc"
    - Expand "Ports (Com & LPT)"
    Do you now see "MSP430 Application UART (COM)" where is some number like "3"?
    If you don't see that then you have to plug in the Launchpad via a USB cable and press the F5 key in the Device Manager. That will cause the DM to refresh its list of devices.
    If the DM can't see the LP then your LP is most likely dead in the USB sense. :x
    If this is the case then this is the first time I have heard of an LP dieing and we're sorry for your loss.
    If you can see the LP then you're in action!
    If you want to use a different method to check out your LP then go get this program from Elpotronics. Install it. Fire it up. See if it can see your LP. If so then you're in business. If not then we weep for the loss of your LP :cry:
    Let's hope for the best.
  21. Like
    jsolarski reacted to NatureTM in Reading the ADC from any pin   
    I'm assuming you don't have an interrupt service routine coded. Since you have the ADC interrupt enabled, when the ADC finishes, the cpu will exit LPM0 and the program will jump to where the ADC10 ISR should be. If there's nothing there, you'll get unexpected behavior. You could either put something in the interrupt vector, or don't enable the interrupt.
    Also, for "k = (ADC10MEM / 1024) * 8;" the ADC1MEM / 1024 is integer division, and the result is rounded down to the nearest whole number. The result of ADC1MEM / 1024 will always be between 0 and 1, but rounded down, so always 0. You can use algebra to change the code so it will work: "k = (ADC10MEM * 8) / 1024;" That answer will still be rounded down, but at least give a result from 0 to 8. "k = (char)((ADC10MEM / (float)1024) * 8 + 0.5);" will round appropriately, but will be slower.
    I've got some example code for the ADC10 I'll just copy over from my blog:

    #include "msp430g2231.h" #define ANALOG_PIN 1 unsigned int analogRead(){ ADC10CTL0 |= ADC10SC; while(ADC10CTL1 & ADC10BUSY); return ADC10MEM; } void analogPinSelect(unsigned int pin){ if(pin < 8){ ADC10CTL0 &= ~ENC; ADC10CTL1 = pin << 12; ADC10CTL0 = ADC10ON + ENC + ADC10SHT_0; } } void main(void){ unsigned int analogValue; DCOCTL = CALDCO_1MHZ; BCSCTL1 = CALBC1_1MHZ; WDTCTL = WDTPW + WDTHOLD; // read adc repeatedly analogPinSelect(ANALOG_PIN); while(1){ analogValue = analogRead(); } }
    You should be able to work off that example and get what you need.
  22. Like
    jsolarski reacted to nexusone1984 in Read from a Analog port on the MSP430   
    First off thanks NatureTM for the help with the code and the others who gave input.
    Just a simple demo of reading a Analog signal and output some type of information.
    I have a CDS photocell connected to a port, and I display the light change on a bar graph display.
    Link below for video and code:
    https://sites.google.com/site/ericstrin ... nalog-port
  23. Like
    jsolarski reacted to RobG in LaunchPad, DC Motor, PWM   
    Here's my little demo of how to use SN754410 with LaunchPad.
    Timer's CCR1 is used to control duty cycle via P1.2
    P1.0 and P1.1 to control direction (setting both to the same level, 0 or 1, will cause dynamic breaking.)
    Vcc1 of SN754410 is connected to LP's Vcc, Vcc2 is connected to a separate power supply (6V in my case.)
    Between outputs and Vcc/Vss I put some Schottky's just in case.
    EDIT: SN754410 logic side (Vcc1) requires 5V, it may not work correctly when powered from LP's Vcc.
    Next week I will add more examples with bigger motor and some MOSFETs.



    #include // DEMO counter unsigned int demoCounter = 0; void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop WDT P1OUT |= BIT1; // Direction control - left P1OUT &= ~BIT0; // Direction control - right // Both 0 or 1 - dynamic break P1DIR |= BIT0 + BIT1 + BIT2; // Bit 2 is connected to enable and will be used for PWM P1SEL |= BIT2; // P1.2 TA1 option select CCTL0 = CCIE; // CCR0 interrupt enabled CCR0 = 1000; // ~8ms CCTL1 = OUTMOD_3; // CCR1 set/reset CCR1 = 950; // CCR1 duty cycle, slow in the beginning TACTL = TASSEL_2 + MC_1 + ID_3; // SMCLK/8, upmode _bis_SR_register(LPM0_bits + GIE); // Enter LPM0 w/ interrupt } // Timer A0 interrupt service routine #pragma vector = TIMERA0_VECTOR __interrupt void Timer_A (void) { // DEMO movement demoCounter++; if(demoCounter == 800) CCR1 = 900; if(demoCounter == 1600) CCR1 = 500; if(demoCounter == 2000) CCR1 = 250; if(demoCounter == 2400) CCR1 = 0; if(demoCounter == 2800) CCR1 = 900; if(demoCounter == 3200) { P1OUT |= BIT0; // switch direction P1OUT &= ~BIT1; } if(demoCounter == 3600) CCR1 = 0; if(demoCounter == 4000) CCR1 = 900; if(demoCounter == 4400) { P1OUT |= BIT1; // switch direction P1OUT &= ~BIT0; } if(demoCounter == 4800) { P1OUT |= BIT0; // switch direction P1OUT &= ~BIT1; } if(demoCounter == 5200) { CCR1 = 500; P1OUT |= BIT1; // switch direction P1OUT &= ~BIT0; demoCounter = 0; } // END DEMO movement }
  24. Like
    jsolarski reacted to JMLB in Possible OS for the MSP430   
    A friend sent me this
    I thought it was cool enough to share.
  25. Like
    jsolarski reacted to wasson65 in Houston Robot Project Underway   
    Hi all,
    I've recently started on my robot project using an old Tamiya RC car for a chassis. Bought a Basic Stamp to tinker with and it's interesting but so limited.
    My name is Tim Wasson, I'm 42 and been playing with digital circuits since I was 11 years old.
    Found the Launchpad because they were handing them out as door-prizes at the local hackerspace, and had to buy a few. Then I read the datasheet and user guide, and got really excited - the 'mixed signal' makes a big difference, and the TI history of DSP comes through when I look at how the peripherals are configured - they look great. I used to write DSP32020 assembly for Zonic Corp in Cincinatti (since defunct) back in 1989, so I've got a soft spot for TI.
    Overall, the robot will consume about 10-30 MSP430 chips, all talking over I2C bus to a Propeller chip, with the 430 chips forming a kind of basic nervous system and brain-stem, and the propeller being the 'conscious' brain. The I2C bus will form a kind of spinal cord, with traffic going from to and from the conscious brain as well as directly between different functional modules at a lower, more reactive level.
    My overall goal is to create a robot that functions at about the level of a dog - able to chase things, sorta obey a few commands, play fetch, and respond to "Bad Dog!" and hopefully show some behavior that will surprise me.
    Anyway, can't wait to get started, and I'll be reading a bunch of stuff out here as we go.
  • Create New...