Jump to content

Search the Community

Showing results for tags 'msp430g2553'.



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

  1. Dmaseko

    MSP430G2553 ADC

    Hi, I'm new to MSP430, I'm using a MSP430G2553 in a project and need help with an in depth understanding of programming the ADC10 inputs of the MCU. I'm using a potentiometer in order to light one of 3 LEDs. For example, LED1 lights up when input voltage is 1V or less, LED2 lights up between 1V and 2V and LED3 lights up when the input voltage is greater than or equal to 2V. I have attached my code below but I am not clear on how to read, convert and store a voltage so that I can use the IF statements to light the respective LEDs. #include <msp430g2553.h> void indicator_LED(); int main(void) { unsigned int i; WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer P1DIR = 0x00; P2DIR = 0xff; P1OUT = 0x00; P2OUT = 0x00; while(1) // keep looping { ADC10CTL1 = CONSEQ_2 + INCH_0; // Repeat single channel, A0 ADC10CTL0 = ADC10SHT_2 + MSC + ADC10ON + ADC10IE; // Sample & Hold Time + ADC10 ON + Interrupt Enable ADC10DTC1 = 0x0A; // 10 conversions ADC10AE0 |= 0x01; // P1.0 ADC option select ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start __low_power_mode_0(); //__bis_SR_register (CPUOFF + GIE);// LPM0, ADC10_ISR will force exit if (ADC10MEM <= 0x228 && ADC10MEM > 0x1D6) { P2OUT = P2OUT | BIT1; for(i=0;i<=1;i++); } else if (ADC10MEM <= 0x1D6) { P2OUT = P2OUT | BIT2; for(i=0;i<=1;i++); } else if (ADC10MEM > 0x228) { P2OUT = P2OUT | BIT0; for(i=0;i<=1;i++); } else { P2OUT = ~P2OUT; for(i=0;i<=1;i++); } } }
  2. As a part of my teaching work, I wanted to demonstrate connecting Raspberry Pi-2 (as SPI Master) to MSP430 LP with MSP430G2553 (as SPI Slave), as an alternative to Arduino-Uno as a SPI Slave. It was aimed at utilizing the ADC's of either of these micro-controller boards, as Raspberry Pi-2 does not have ADC modules. The working of Arduino Uno as the SPI Slave device was smooth and painless, but I spent many hours getting the MSP430G2553 working as a SPI SLave. Ultimately, I hit upon a hack (if there was one) and MSP430G2553 started working as SPI Slave! However, I do not understand why this hack works, or, why such a hack is needed at all. I shall appreciate any hints, help, explanations regarding this. I hope to be excused for this long posting. --------------- SPI Master code: helloArdu.c --------------------- /********************************************************** SPI_Hello_Arduino Configures an Raspberry Pi as an SPI master and demonstrates bidirectional communication with an Arduino Slave by repeatedly sending the text "Hello Arduino" and receiving a response ***********************************************************/ #include <sys/ioctl.h> #include <linux/spi/spidev.h> #include <fcntl.h> #include <cstring> #include <iostream> using namespace std; int fd; unsigned char hello[] = {'H','e','l','l','o',' ', 'A','r','d','u','i','n','o'}; unsigned char result; int spiTxRx(unsigned char txDat); int main (void){ fd = open("/dev/spidev0.0", O_RDWR); unsigned int speed = 1000000; ioctl (fd, SPI_IOC_WR_MAX_SPEED_HZ, &speed); while (1){ for (int i = 0; i < sizeof(hello); i++) { result = spiTxRx(hello); cout << result; usleep (10); } } } int spiTxRx(unsigned char txDat){ unsigned char rxDat; struct spi_ioc_transfer spi; memset (&spi, 0, sizeof (spi)); spi.tx_buf = (unsigned long)&txDat; spi.rx_buf = (unsigned long)&rxDat; spi.len = 1; ioctl (fd, SPI_IOC_MESSAGE(1), &spi); return rxDat; } -------------------------------------------------------------------------- The Arduino Uno Slave code is: ---------------------- helloRaspi.ino -------------------------------- /************************************************************* SPI_Hello_Raspi Configures an ATMEGA as an SPI slave and demonstrates bidirectional communication with an Raspberry Pi SPI master by repeatedly sending the text "Hello Raspi" ****************************************************************/ unsigned char hello[] = {'H','e','l','l','o',' ', 'R','a','s','p','i','\n'}; byte marker = 0; void setup (void) { pinMode(MISO, OUTPUT); SPCR |= _BV(SPE); } void loop (void){ if((SPSR & (1 << SPIF)) != 0) { SPDR = hello[marker]; marker++; if(marker > sizeof(hello)){ marker = 0; } } } ------------------------------------------------------------------------- My Slave code for MSP430G2553 is: ------------------------- helloRaspi.c ------------------------------- #include "msp430g2553.h" #include <string.h> unsigned char cmdbuf[20]; char cmd_index=0; unsigned char hello[] = "Hello Raspi \n"; void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer P1DIR |= BIT0 + BIT6; while (!(P1IN & BIT5)); P1SEL = BIT5 + BIT6+ BIT7; P1SEL2 = BIT5 + BIT6 + BIT7; P2SEL = BIT0; P2SEL2 = BIT0; UCB0CTL1 = UCSWRST; // **Put state machine in reset** UCB0CTL0 |= UCCKPL + UCMSB + UCMODE_2 + UCSYNC; // 3-pin, 8-bit SPI master UCB0CTL1 &= ~UCSWRST; // **Initialize USCI state machine* IE2 |= UCB0RXIE; // Enable USCI0 RX interrupt IE2 |= UCB0TXIE; __bis_SR_register(LPM4_bits + GIE); // Enter LPM4, enable interrupts } // end main() int index = 0; __attribute__((interrupt(USCIAB0TX_VECTOR))) void USCI0TX_ISR (void){ UCB0TXBUF = hello[index]<<1; // <---- Note this hack index++; if(index == 13) index = 0; } __attribute__((interrupt(USCIAB0RX_VECTOR))) void USCI0RX_ISR (void){ char value = UCB0RXBUF; if (cmd_index == 13) { if (strncmp(cmdbuf, "Hello Arduino", 13) == 0) { P1OUT |= BIT0; } else { P1OUT &= ~BIT0; } cmd_index = 0; } else { cmdbuf[cmd_index] = value; cmd_index++; } } ------------------------------------------------------------------------- Note the hack indicated by <---, where the character to be transmitted to back to RaspberryPi is shifted to left by one bit. Without this hack, which would be normal way, I found that, e,g, Character 'A' (0x41) sent was received as 0xA0, indicating that the character bits are being rotated to the right one place. With this hack, transmission was fine! Why this is so? Am I missing something or doing something wrong? Digging various discussion lists and forums, unfortunately, have not given any clue. There are plenty of example code for MSP430G2553 working in SPI Master mode, but few for Slave mode.
  3. Is there any liberary TINY GPS lib in arduino for Energia. I tried the code of tiny gps in ENERGIA but IT worked on MSP kits
  4. Good morning everybody, I'm Curtis, Fairly new to the world of MSP430, but VERY HAPPY that this forum exists. Energia has made my life much easier. I was about to make a hole in my wall by repeatedly bashing my head against it, but Energia removed a bunch of the minutia and provides a great abstraction layer and way of programming the MSP4230G2553 controller. See ya 'round, Curtis
  5. There have been a few situations where I've had HardwareSerial::write() lock up on me and end up in an infinite while loop. Could some changes be made to any and all possibly infinite while(); loops? I think it would just take some sort of counter that indicates how many iterations through the while(); loop have happened. Then if some upper limit is reached, exit with a fail. Let's make it bullet proof as possible.
  6. Hi, I am new to the forum, and hope I am doing this right. If this question is in the wrong spot please let me know. I have two MSP430G2 launchpads and a CC110L AIR module booster pack. My goal is to make a simple pushbutton toggle setup. (ie push the button on one board, and toggle a GPIO on the other board.) Eventually, I plan to turn this into a key fob with custom PCBs. Low power consumption would be really good too. I thought this would be a relatively easy project, but I am stuck. I can't get the boards to communicate at all. I got the settings by choosing from the SMARTRF studio. I planned to use an MSP430g2553 with USCI through the UCB0 interface as the SPI communication. However, I keep getting hang-ups in different parts of the code, with some TXFIFO_UNDERFLOWS sometimes, and other times just a hang-up. Currently, I didn't modify any of the boards and am using their built in connections. I am not sure what anyone would want, but if someone would have a suggestion or example I would be very grateful. Let me know if you would like anymore information from me. I haven't even tried using a LPM yet and am already stuck. I have spent hours reading the datasheets and just come away more confused every time. The Launchpad also comes with an MSP430g2452 if the USI interface would be a better option than the USCI, but when I was doing research it seemed like the 2553 with the USCI was more popular.
  7. Hello everyone relative noob here. I'm currently trying to use the Adafruit ADS1015 library with a ads1114. I had the single ended read working a few days ago however its no longer working and readADC_SingleEnded locks the loop(). I'm actually using a msp430g2553 with energia, but that doesnt explain why it worked before and no longer does. Has this ever happened to anyone else before? I also posted this on Arduino forums to see if they knew anything about why this is happening. Here is my code. #include <Wire.h> #include <Adafruit_ADS1015.h> //Adafruit_ADS1115 ads; /* Use this for the 16-bit version */ float voltage = 0.0; void setup(void) { Serial.begin(9600); Serial.println("Hello!"); Serial.println("Getting single-ended readings from AIN0..3"); Serial.println("ADC Range: +/- 6.144V (1 bit = 3mV/ADS1015, 0.1875mV/ADS1115)"); // The ADC input range (or gain) can be changed via the following // functions, but be careful never to exceed VDD +0.3V max, or to // exceed the upper and lower limits if you adjust the input range! // Setting these values incorrectly may destroy your ADC! // ADS1015 ADS1115 // ------- ------- // ads.setGain(GAIN_TWOTHIRDS); // 2/3x gain +/- 6.144V 1 bit = 3mV 0.1875mV (default) // ads.setGain(GAIN_ONE); // 1x gain +/- 4.096V 1 bit = 2mV 0.125mV // ads.setGain(GAIN_TWO); // 2x gain +/- 2.048V 1 bit = 1mV 0.0625mV // ads.setGain(GAIN_FOUR); // 4x gain +/- 1.024V 1 bit = 0.5mV 0.03125mV // ads.setGain(GAIN_EIGHT); // 8x gain +/- 0.512V 1 bit = 0.25mV 0.015625mV // ads.setGain(GAIN_SIXTEEN); // 16x gain +/- 0.256V 1 bit = 0.125mV 0.0078125mV Wire.begin(); } void loop(void) { int16_t adc0; // adc1, adc2, adc3; Serial.print("AIN0: "); Serial.println(adc0); adc0 = readADC_SingleEnded(0); voltage = (adc0 * 0.1875)/1000; Serial.print("AIN0: "); Serial.println(adc0); Serial.print("\tVoltage: "); Serial.println(voltage, 7); Serial.println(" "); delay(200); } uint8_t m_i2cAddress=0x48; uint8_t m_conversionDelay=8; uint8_t m_bitShift=0; adsGain_t m_gain; int16_t readADC_SingleEnded(uint8_t channel) { // Start with default values uint16_t config = ADS1015_REG_CONFIG_CQUE_NONE | // Disable the comparator (default val) ADS1015_REG_CONFIG_CLAT_NONLAT | // Non-latching (default val) ADS1015_REG_CONFIG_CPOL_ACTVLOW | // Alert/Rdy active low (default val) ADS1015_REG_CONFIG_CMODE_TRAD | // Traditional comparator (default val) ADS1015_REG_CONFIG_DR_1600SPS | // 1600 samples per second (default) ADS1015_REG_CONFIG_MODE_SINGLE; // Set PGA/voltage range config |= m_gain; Serial.println("Config is set "); // Set single-ended input channel switch (channel) { case (0): config |= ADS1015_REG_CONFIG_MUX_SINGLE_0; break; case (1): config |= ADS1015_REG_CONFIG_MUX_SINGLE_1; break; case (2): config |= ADS1015_REG_CONFIG_MUX_SINGLE_2; break; case (3): config |= ADS1015_REG_CONFIG_MUX_SINGLE_3; break; } // Set 'start single-conversion' bit config |= 0x8000; Serial.println("Single conversion bit set"); // Write config register to the ADC writeRegister(m_i2cAddress, ADS1015_REG_POINTER_CONFIG, config); Serial.println("register has been written"); // Wait for the conversion to complete delay(m_conversionDelay); Serial.println("conversion delay is over"); // Read the conversion results // Shift 12-bit results right 4 bits for the ADS1015 Serial.println("Returning the registers read"); return readRegister(m_i2cAddress, 0x00) >> m_bitShift; } byte test; static void writeRegister(uint8_t i2cAddress, uint8_t reg, uint16_t value) { Serial.println("Beginning i2c transmission"); Wire.beginTransmission(i2cAddress); Serial.println("Writing to register"); Wire.write((uint8_t)reg); Serial.println("Writting 8 bit shift"); Wire.write((uint8_t)(value>>8)); Serial.println("writing end value"); Wire.write((uint8_t)(value & 0xFF)); Serial.println("End of transmission"); test = Wire.endTransmission(true); Serial.println(test); } int16_t readRegister(uint8_t i2cAddress, uint8_t reg) { Serial.println("Reading from register"); Wire.beginTransmission(i2cAddress); Serial.println("Returning the registers read"); Wire.write((uint8_t)0x00); Wire.endTransmission(); Serial.println("requesting from i2c the registers read"); Wire.requestFrom(i2cAddress, (uint8_t)2); return ((Wire.read() << 8) | Wire.read()); } EDIT: So i figured out it has something to do with register writing Wire.endTransmission(); within the writeRegister call of the ADS1115 library, im not sure why. Thanks.
  8. This is a very simple enc28j60 library created by Renato Aloi for atmega modifed by me for MSP430G2553 and MSP430F5529 Please, check my latest master fork from Renato Aloi newMods branch or download directly v0.4.2: EtherEncLib-0.4.2.zip fix CS, fix examples, disable debug from tcpstack EtherEncLib-0.4.zip only harware SPI version (MSP430G2553 and MSP430F5529 tested) EtherEncLib_v03.zip - hard/soft spi version EtherEncLib_v2.zip - hardware spi version EtherEncLib_v01.zip - softspi version v03: selectable hardware/software spi all definitions moved to EtherEncLib.h lines 17,18 -> select between hard/soft spi lines 21,23-25 -> SPI pins definition for MSP430 lines 28,30-32,34 -> SPI pins definition for Stellaris & Tiva(?) v02: hardware spi version enctypes.h file contains CS pins definition (lines 247, 250) v01: init version At this moment, after my quick mod, spi communication work on softspi (shiftOut/shiftIn) and replace strange arduino access via registers like SPDR etc... So...shiftOut/shiftIn are not so fast enctypes.h file contains pins definition (lines 247-259) description from EtherEncLib.cpp file:
  9. I'm trying to understand the comparator A+ and Timer capture mode for using honeywell SM351LT sensor. Can't quite seem to bind it together. Sensor is currenlty hooked up with permanent power supply. Comparator output on P1.7 is tied to an led and works pretty much as expected. Furthermore hardware pwm is running on P1.6 with ACLK at 32.768Khz crystal to stay in LPM3. If I put an led on this pin it light up briefly as expected. If I understand correctly the sensor should be powered on CCR0; Read Comparator at CCR1 after minimum 10us. printf reveals indeed 50 cycles between CCR0 and CCR1. If I use P1.6 to power sensor, it's not giving any reading at CCR1. Are the timer(s) (TIMER0_A0/TIMER0_A1) misconfigured perhaps? Then there are some options/settings to bind comparator to compare timer. TA0CCTL1 |= CCIS_1; //Capture CCI1B TA0CCTL1 |= SCS; //Capture sychronize TA0CCTL1 |= CAP; //Capture mode Cannot seem to figure out how to implement these? Wondering if this is the right approach at all? Any help/hints appreciated. There's some links in the attached file I found on the subject. main.c
  10. I am trying to write a simple button interrupt debounce routine without much success. I am seeing unexpected interrupts occurring. The logic I am using is to disable the button interrupt when first pressed and then re-enabling it when the watch dog timer expires. I have tried increasing the wdt interval but the momentary switch button is still bouncing and simply fires the button interrupt unexpectedly. I know I can write other debounce routines but I would like to stay out of polling or looping for low power reasons if at all possible. I am not sure if the issue is something with the wdt so I am also looking at using timerA instead of the wdt. Thanks for any guidance/suggestions. #include <msp430g2553.h> #define BUTTON BIT3 //0x08 int main(void) { WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer P1REN |= BUTTON; // enable pull up resistor on P1.3 button P1DIR |= 0x01; // Set P1.0 to output direction P1IE |= BUTTON; // P1.3 interrupt enabled P1IES |= BUTTON; // P1.3 Hi/lo edge P1IFG &= ~BUTTON; // P1.3 IFG cleared - set to correct state first time __enable_interrupt(); // enable all interrupts while(1) { //check flags set by interrupts here, do something, clear flag } //return 0; } // Port 1 interrupt service routine #pragma vector=PORT1_VECTOR __interrupt void Port_1(void) { //__bic_SR_register_on_exit(LPM4_bits); // clear original LPM4 Bit to wake up clocks and cpu P1IFG &= ~BUTTON; // Clear the interrupt flag for the button P1IE &= ~BUTTON; // Disable Button interrupt //WDTCTL = WDT_MDLY_32; // Set watchdog timer (WDT) to trigger every 32ms WDTCTL = WDT_ADLY_1000; IE1 |= WDTIE; // enable WDT interrupt P1OUT ^= 0x01; // P1.0 = toggle (toggle led) } // WDT Interrupt Service Routine used to de-bounce button press #pragma vector=WDT_VECTOR __interrupt void WDT_ISR(void) { IE1 &= ~WDTIE; // disable Watchdog timer (WDT) interrupt IFG1 &= ~WDTIFG; // clear WDT interrupt flag WDTCTL = WDTPW + WDTHOLD; // put WDT back in hold state P1IE |= BUTTON; // Reenable interrupts for the button }
  11. Hi All, Somehow I've made a stupid mistake with this weather thingie I put together and I can't figure out what's wrong. I need your help! Project description: Weather thingie - Reports temperature, humidity and light readings via bluetooth. Operation is simple, connect to the device and it will report something like "27 C 57 H 96 L\r\n" ~ every second. The LED on board will alternate state every second. I set this up on a breadboard before making the PCB as I was not familiar with the DHT11 or and quirky requirements it might have. The project worked fine on the breadboard. I suspect I have either a PCB design fault or defective components? Perhaps? I dunno. TIA 0xFFFF main.c
  12. Hello all together, I need a very accurate timer for a midi clock. For that reason I need a timer, that is giving me for every beat 24 beats back. At hte same time, I need a serial connection with 31250baud. My question is now, how do I get a very, very accurate timer. The timer quarz is normaly 32768, and this is maybe a little bit to slow, becaus I want my bpm with one digit after the point like 121,1bpm. I have a MSP430G2553. Can I connect a 1MHz or even a 4MHz cristal to the
  13. A Short introduction on Programming ADC10 of MSP430 Launchpad and Displaying the ADC10 values on a LED Bar graph type Display. Full Tutorial can be found here
  14. Hi everyone! I am trying to get a PAC1710 chip as a slave working with the MSP430G2553. I am having a ton of trouble doing so and can't seem to even get the address of the slave for the msp. I am going off of the master_reader code as an example. My first question is I know that you need to give the slave an address but I am not sure how to do so. On the data sheet of the pac1710, the address is as follows - 0011000. Thanks!
  15. This project is a submission for the 2015 Project of the Month Halloween contest. It came about as a request from my four year old grandson after he had seen the Blue Angels fly over during Seafair in Seattle. The basic air frame was constructed from two cardboard boxes as shown in the photograph below. . The boxes are attached to each other with brads and hot glue. Edges are reinforced where I felt necessary by folding extra cardboard over or gluing in reinforcement cardboard. Also shown in the photograph above are the following: wings, tail, and fins constructed from a corrugated plastic storage box and hot glued in place reflector on the nose constructed from a coffee can bottom which will eventually become the "search light". There is a similar reflector on the tail which will become the jet exhaust. control panel with various switches and a potentiometer I had in my junk box installed on a wooden paint stirring stick The visible surfaces were then covered with wrapping paper using Outdoor Mod Podge - a waterbased sealer, glue and finish available in craft stores in the United States. A second coat was then put on to make it a bit more waterproof. This is the schematic for the avionics. A little custom MSP430G2553 board with two AA batteries beside it in the tail controls an Adafruit neopixel ring "jet exhaust" with a toggle switch on the panel to turn it on and off. Everything else runs off of three AA batteries with the wiring in the front of the aircraft between a cardboard firewall and the nose. Two latching buttons turn colored LEDs on the panel on and off while a third turns a 3W LED (searchlight) on and off. There is a potentiometer to control the brightness of the searchlight. Finally I repurposed the sound board and speaker from an old greeting card that was originally powered by a coin cell. The WS2812 Adafruit Neopixel ring is controlled by the MSP430G2553. I used the library posted by ILAMtitan at 43oh - so full credit to those who had a hand in developing it. The library example worked well as is for my purposes and about the only thing I changed was the output pin and the number of pixels being controlled in the code. Here is a picture of my grandson trying it out. We glued plastic cups over the headlight and jet exhaust and stuck Energia stickers on it. I may touch it up a bit more if I have time and post a final picture. Improvement Ideas: I also made a "candy counter" out of an old scale for his entertainment (and mine). His immediate reaction was that we should somehow attach the candy counter to the airplane. Clever, but not practical due to the need for the scale to be level and not banged around by a four year old. Using a counter where candy is funneled past a beam, like Chicken did with his counter might work though. My idea is that we add GPS along with thumbs up/down buttons. Then he could rate offerings and either store the data as a reminder for next year or send it out over the IOT with location so that his buddies know where the good candy is.
  16. The MCP3008 is an easily used 10bit, 8 channel, Serial Peripheral Interface (SPI) Analog to Digital Converter. I created an Energia library that can be found here and used to read any of the eight pins with a single call. Conversion is done for voltages between 0 and 3.3 V, including on the CC3200, and results in a integer reading between 0 and 1023. This library is for single ended operation only and uses hardware SPI. An example is included that demonstrates reading from all 8 channels. Tested with Energia 0101E0016 on the following LaunchPads * CC3200-LAUNCHXL Rev 4.1 (80 MHz) EMT * CC3200-LAUNCHXL Rev 4.1 (80 MHz) * MSP-EXP432P401R (48 MHz) EMT * MSP430F5529 Rev 1.5 (25 MHz) * MSP-EXP430FR5969 Rev 2.0 (16 MHz) * MSP-EXP430G2553 Rev 1.5 (16 MHz)
  17. Hi all, I am facing problem while reading DHT values in timer ISR function. I am able to get the data if use i dht.readHumidity() (using dht library) in loop function but not able to get when i use in timer ISR function. Can anyone please help me out. Thanks in Advance.
  18. Hi all I am new to energia and need some help in writing a code into msp430G2553 by using timer interrupt Here what i am trying is taking the analog input from a sensor but using external interrupt and i want this using timer interrupt but i don't know how to do.. Please need ur help. Thank u.
  19. Last updated: May 07, 2015 May 07: added SBM-20 background CPM value vs 1kg potassium salt and python code to log the data. April 26: added deadtime image. April 23: updated to 75
  20. Hey forum! I always wanted to make a synthesizer , so i chose the msp430 launchpad, because it's one of the most inappropriate chip i can use for it :grin: When i started to make it i didn't have real goal, i just wanted to make a sound, so this project is kind if all over the place but i have learned a lot doing it so it was totally worth it. The DAC used is a TI TLC5615, it's not the best choice, but i only had this in my parts bin. Probably any other SPI DAC could be used with minimal modification, or even PWM. (I don't sound good with PWM IMO.) The TLC5615 needs 5 volts, but it seem to run good with 3.6 volt from the launchpad,or you could use TP3 (the USB 5V) but that can be noisy, I used a separate 5V supply. The crystal is required, because it tunes the DCO on every start up to a pre-defined value ( i ran it at 19Mhz without any problems) If you change the frequency , you only need to change the bit rate divider for the USCI UART. There are a lot to optimize/rewrite but i kind of grew tired of playing with variables to get a few more bytes of free ram. Maybe i'll rewrite it on an F5510 as it would be a much better choice because it has 8 x Ram as much ram and a hardware multiplier. This is a synth with 16 voice of polyphony. It accepts midi massages from 1-8 and 10 (for the drum sounds). Each midi channel has it's own different settings for: -MIDI program -LFO width and speed (CC01 for combined mod wheel control, CC02 for width,CC03 for speed -Oscillator type (simple with any waveform or with ADSR square or sine wave) -Pitch bend -Portamento on/of (CC65) -Portamento speed (CC05) -Channel volume (CC07) It plays 8 sine/square with ADSR, 4 with any waveform (now only Saw and triangle), and 4 drum sounds simultaneously. Here are two songs i recorded with it: Soundcloud. I have attached the CCS Project with the source codes in a ZIP, the schematics, and a picture of how it look on my breadboard. mSpYNTH.zip mysy
  21. Hi, I am trying to operate a 3V relay (from OMRON) using MSP430G2553. The relay is a SPDT one, with 6 PINs. I am not quite sure how to wire a6 PIN relay (I have some experience with 5 PIN SPDT relay), and I cannot find much information in the internet. I was also told that, for driving a 3V relay, I would not require transistor + diode combination. For your information, the relay has a rated coil current of 50 mA. Can anyone help me on understanding the wiring structure of the relay? How to interface it with MSP430? Also, is it true that, I can operate the 3V relay without separate transistor + diode combination? I do not have much experience in microcontroller, particularly in MSP430 platform. Any suggestion is welcome. Thank you in advance for your support.
  22. Hello, I bought a Sparkfun ML8511 UV sensor breakout and set it up according to this. It kind of works / I have a weird problem: No matter the voltage (3V or 3.3V), the sensor output values change periodically very strongly: Closer to UV-AB source: ~1.5 to ~10.5 to ~1.5 and so on (with more steps in between) (distance of course doesn't change). More away from the UV source: ~0.2 to ~1.5 to ~0.2 and so on. When I attach a 1.5V battery constant voltage source as a test, the displayed value is indeed rather constant ranging from 4.39 to 4.59, so it must be the sensor's problem? Google-ing this problem didn't reveal any results. I tried using A0 and (A1-A5) because of possible noise? but this unfortunately didn't help. I'm using a MSP430G2553 and its ADC10, on a breadboard. Is this a known problem of such a setup?
  23. Dear Sir/Madam, I am trying to use MSP430 to talk with a wifi module using UART, technically, the msp430G2553 does not need to know the ip address for the wifi module, so the wifi module can be considered as another mcu. I have done the hardware and the calculation of voltage received and also converted to a string value. I can also read the values using hardware UART on serial monitor, but I now wants to send the results to the wifi module and check if the wifi module receives it on socket tools. My code are as below: #include <SoftwareSerial.h> // to the pins used: const int analogInPin = P1_4; //Analog input pin that the output from the current sensor is attached to const int txPin = P1_1;// TXD const int rxPin = P1_2;//RXD SoftwareSerial mySerial(P1_2,P1_1); // I defined a new serial using .....//some definitions here cut that for your easier to read and hopefully help !! void setup() { //initialize serial communications at 9600bps: Serial.begin(9600); mySerial.begin(57600); pinMode(analogInPin,INPUT); } void loop() { // put your main code here, to run repeatedly: //read the analog in value: ............... something here to read and calculate //convert to String //char str[5]; //sprintf(str, "%.2d", current); char curr[6]; itoa(int((current*10+5)/10),curr,10); //int dec = (current - (int)current)*100; //itoa(abs (dec) , buffer, 10); char pow[6]; itoa((power*10+5)/10,pow,10); Serial.println(curr); if (Serial.available()) { mySerial.write(Serial.read()); } } Thank you so much if you can help!
  24. Hi, I'm trying to read analog values from a SHARP IR sensor GP2Y0A41SK0F using the MSP430F5529 launchpad. There was not any error when I verified and uploaded the codes in Energia. However, when I clicked on the Serial Monitor, nothing showed up. But when I chose the MSP430G2452 from the "Tools" menu, the monitor successfully showed the analog values. I connect Vcc (red wire) to 5 V pin, the ground (black wire) to GND pin, and the analog output (white wire) to P6.4 pin/A4 pin. The same thing also happened to the MSP430G2553 launchpad. It only works when MSP430G2452 is selected. I looked at the codes very thoroughly but I couldn't see any mistakes: const int IR = A4; void setup() { Serial.begin(9600); } void loop() { int maxVal = 0, minVal = 1024, n=200; float x_i, total=0, mean; for (int i=1; i <= n; i++) { x_i = analogRead(IR); total += x_i; Serial.println(x_i); if (x_i < minVal) { minVal = x_i; } if (x_i > maxVal) { maxVal = x_i; } } mean = total / n; Serial.print("minimum = "); Serial.print(minVal); Serial.print(", maximum = "); Serial.print(maxVal); Serial.print(", total = "); Serial.print(total); Serial.print(", mean = "); Serial.println(mean); delay(100); }
  25. Someone can helpme, i'm taking incorrect readings of a magnetometer I believe with the problem are in my i2c code implementation. /* * Print all printable characters on usb channel using UART mode of USCI module * the print is based in busy wait to transfer characters */ #include "msp/msp430g2553.h" void configureDCO(); void configureUART(); void putc(char); void print (const char[]); void print (short); void printStatus(); main() { configureDCO(); configureUART(); UCB0CTL1 = UCSWRST; //Reset USCI UCB0CTL0 = // USCI_B0 control register UCMST // set master mode | UCMODE_3 // I2C mode select | UCSYNC; // synchronous UCB0CTL1 = // UCSI_B0 control register UCSSEL_2 //select clock source, SMCLK | UCSWRST; UCB0I2CSA = 0x1e; // write desired slave address to the UCBxI2CSA, magnetometer address // prescaler to generate 75 Hz (1MHz of SMCLK / 13981 of prescaler) UCB0BR0 = 0x9D; UCB0BR1 = 0x36; //configure ports P1SEL |= BIT6 | BIT7; P1SEL2|= BIT6 | BIT7; UCB0CTL1 &= ~UCSWRST; // Initializate USCI print("[system] I2C configured\r\n"); // send start to transmit UCB0CTL1 |= UCTR // setting UCTR for transmitter mode | UCTXSTT; // setting UCTXSTT to generate START condition // point to register A ( address 0x00 ) while ( !(IFG2 & UCB0TXIFG) ); // wait UCBxTXIFG are set, when set the buffer are empty UCB0TXBUF = 0x00; // load data to be trasmitted on UCBxTXBUF // write 0x78 in register A, mean of eight measurements, 75 Hz sample rate while ( !(IFG2 & UCB0TXIFG) ); // wait UCBxTXIFG are set, when set the buffer are empty UCB0TXBUF = 0x78; // load data to be trasmitted on UCBxTXBUF // point to register B ( address 0x01 ) while ( !(IFG2 & UCB0TXIFG) ); // wait UCBxTXIFG are set, when set the buffer are empty UCB0TXBUF = 0x01; // load data to be trasmitted on UCBxTXBUF // write 0xa0 in register B, gain five while ( !(IFG2 & UCB0TXIFG) ); // wait UCBxTXIFG are set, when set the buffer are empty UCB0TXBUF = 0xa0; // load data to be trasmitted on UCBxTXBUF // point to mode register ( address 0x02 ) while ( !(IFG2 & UCB0TXIFG) ); // wait UCBxTXIFG are set, when set the buffer are empty UCB0TXBUF = 0x02; // load data to be trasmitted on UCBxTXBUF // write 0x00 in mode register, continuous operation while ( !(IFG2 & UCB0TXIFG) ); // wait UCBxTXIFG are set, when set the buffer are empty UCB0TXBUF = 0x00; // load data to be trasmitted on UCBxTXBUF // send stop UCB0CTL1 |= UCTXSTP; // send stop while (UCB0CTL1 & UCTXSTP); // wait STOP condition is ack __delay_cycles(6000); // wait 6ms, until change the settings of magnetometer // send start to receive UCB0CTL1 &= ~UCTR; // setting UCTR for receiver mode UCB0CTL1 |= UCTXSTT; // setting UCTXSTT to generate START condition while (UCB0CTL1 & UCTXSTT); // infinit loop, show continually the measuread values while (true) { // allocate space to the measured values, (x,y,z) coordinates, high byte (h prefix), low byte (l prefix) char hx, lx, hz, lz, hy, ly; // receive data output X MSB register while (!(IFG2 & UCB0RXIFG) ); // wait UCBxRXIFG are set, when set read buffer are full hx = UCB0RXBUF; // load data from buffer to local memory // receive data output X LSB register while (!(IFG2 & UCB0RXIFG) ); // wait UCBxRXIFG are set, when set read buffer are full lx = UCB0RXBUF; // load data from buffer to local memory // receive data output Z MSB register while (!(IFG2 & UCB0RXIFG) ); // wait UCBxRXIFG are set, when set read buffer are full hz = UCB0RXBUF; // load data from buffer to local memory // receive data output Z LSB register while (!(IFG2 & UCB0RXIFG) ); // wait UCBxRXIFG are set, when set read buffer are full lz = UCB0RXBUF; // load data from buffer to local memory // receive data output Y MSB register while (!(IFG2 & UCB0RXIFG) ); // wait UCBxRXIFG are set, when set read buffer are full hy = UCB0RXBUF; // load data from buffer to local memory // receive data output Y LSB register while (!(IFG2 & UCB0RXIFG) ); // wait UCBxRXIFG are set, when set read buffer are full ly = UCB0RXBUF; // load data from buffer to local memory // compose (x, y, z) values short x, y, z; x = (static_cast<short>(hx) << 8) | lx; // compose x MSB and LSB z = (static_cast<short>(hz) << 8) | lz; // compose z MSB and LSB y = (static_cast<short>(hy) << 8) | ly; // compose y MSB and LSB //print (x, y, z) measured values print("( "); print(x); print(", "); print(y); print(", "); print(z); print(" )"); print("\r\n"); } } void configureDCO() { WDTCTL = WDTPW + WDTHOLD; // Stop WDT // Set DCO to 1MHz BCSCTL1 = CALBC1_1MHZ; DCOCTL = CALDCO_1MHZ; __delay_cycles(1000000); } void configureUART() { UCA0CTL1 |= UCSWRST; // put USCI in reset mode // P1.1 = RXD, P1.2=TXD P1SEL |= BIT1 | BIT2; P1SEL2 |= BIT1 | BIT2; UCA0CTL1 |= UCSSEL_3; // Use SMCLK // Set baud rate to 9600 with 1MHz clock (Data Sheet 15.3.13) 1MHz / 104 UCA0BR0 = 104; UCA0BR1 = 0; UCA0MCTL = UCBRS0; // Modulation UCBRSx = 1, correction for the fractional part ( the rest, 9600 - 1MHz / 104) UCA0CTL1 &= ~UCSWRST; // put USCI in operad mode (removing reset mode) /*End configuration hardware UART */ print("[system] uart configured\r\n"); }; void putc(char ch) { while(!(IFG2 & UCA0TXIFG)); UCA0TXBUF = ch; } void print (const char msg[]) { for (int i = 0; msg[i] != '\0'; ++i) putc(msg[i]); } void print (short value) { if (value == 0) { putc('0'); return; } if (value < 0) { putc('-'); value *= -1; } unsigned int size; char buffer[20]; for (size = 0; value; ++size, value /= 10) buffer[size] = value % 10; while (size) putc(buffer[--size] + '0'); } void printStatus() { print("Status:\n\r"); #define __PRINT_STATUS(X, MSG) if (UCB0STAT & X) print(#MSG "! "); __PRINT_STATUS(UCNACKIFG, nack); __PRINT_STATUS(UCALIFG, arbitration lost); __PRINT_STATUS(UCGC, receive general call); __PRINT_STATUS(UCBBUSY, bus busy); __PRINT_STATUS(UCSCLLOW, SCL low); __PRINT_STATUS(UCSTPIFG, stop received); __PRINT_STATUS(UCSTTIFG, start received); print("done\n\r"); } Please this is a old problem, someone can helpme? David Kennedy S. Araujo Computer Engineering Student (PUC GO)
×
×
  • Create New...