Jump to content

Search the Community

Showing results for tags 'g2553'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • News
    • Announcements
    • Suggestions
    • New users say Hi!
  • Spotlight!
    • Sponsor Spotlight
    • Sponsor Giveaways
  • Energia
    • Energia - MSP
    • Energia - TivaC/CC3XXX
    • Energia - C2000
    • Energia Libraries
  • MSP Technical Forums
    • General
    • Compilers and IDEs
    • Development Kits
    • Programmers and Debuggers
    • Code vault
    • Projects
    • Booster Packs
    • Energia
  • Tiva-C, Hercules, CCXXXX ARM Technical Forums
    • General
    • SensorTag
    • Tiva-C, Hercules, CC3XXX Launchpad Booster Packs
    • Code Vault
    • Projects
    • Compilers and IDEs
    • Development Kits and Custom Boards
  • Beagle ARM Cortex A8 Technical Forums
    • General
    • Code Snippets and Scripts
    • Cases, Capes and Plugin Boards
    • Projects
  • General Electronics Forum
    • General Electronics
    • Other Microcontrollers
  • Connect
    • Embedded Systems/Test Equipment Deals
    • Buy, Trade and Sell
    • The 43oh Store
    • Community Projects
    • Fireside Chat
  • C2000 Technical Forums
    • General
    • Development Kits
    • Code Vault
    • Projects
    • BoosterPacks


There are no results to display.

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start



Website URL





Found 27 results

  1. Hi there, my current project is to build a controller for a sensorless BLDC motor using a MSP430G2553. I want to realize trapezoidal control with Back-EMF/zero-crossing detection. I plan to detect zero-crossing with the Comparator(CA2/3/4 vs. CA1) and generate PWM using Timer1. Timer0 will be used for things like 30 BLMC_.zip
  2. fabytm

    G2553 UART issues

    Hey guys, I'm having some problems with my G2553 Launchpad. For some time now, the UART functionality has not functioned. I'm now sending the character "a" through the HW UART (Jumpers are positioned correctly) and what I get on my computer is completely different. I tried this in Windows 10, W7, macOS Mojave, even through the physical P1.1 and P1.2 ports to a Raspberry Pi and the result is the same. https://imgur.com/a/yd90MIw I also tried receiving data from a GPS module via UART and the data I received was unusable (the length of data was as expected, but the characters were gibberish). Has anyone had something similar happen to them?
  3. Assuming the MSP430 is powered by 3.3V, can I apply a 3.7V signal on a digital pin? Can I apply a 2.5V input? Will it still read rising and falling edges on the pin if the voltage on the pin is more or less than the supply voltage?
  4. Hello All, I'm an electronics engineering student and I know little about programming.I was using arduino and I want to use TI MCU's. So for that reason I'm recreating my arduino projects on energia (tried code composer studio but it is too complicated for me). Some of my projects worked well on energia and i didn't make any changes of my codes it was wonderful but my end term project didn't compiled because of the library that i'm using so I'm trying to port a library from arduino to energia. The library that i'm trying to port is based on the SoftwareSerial library (formerly NewSoftSerial), authored by: ladyada (http://ladyada.net),Mikal Hart (http://www.arduiniana.org),Paul Stoffregen (http://www.pjrc.com),Garrett Mace (http://www.macetech.com), Brett Hagman (http://www.roguerobotics.com/) and it uses pin change interrupts. the library that i'm trying to port energia uses digitalPinToPCMSK and digitalPinToPCICR macros from the pins_arduino.h I was successful running this library on arduino but i cannot get it to work on energia. The error I'm gettin when i try to compile the code is; error: 'digitalPinToPCICR' was not declared in this scope 'error: digitalPinToPCMSK' was not declared in this scope it is going like this. The library i want to port from arduino is Arduino-SDI-12 created by Kevin M. Smith, S. Hicks and their team members the library is located at github (link: https://github.com/EnviroDIY/Arduino-SDI-12 ). What should I do to make it work? Any help will be appreciated. Thanks in advance, I'm using LaunchPad MSP-EXP430G2 v1.5 MCU MSP430G2553 Windows 10 PC and Energia 1.6 10E18 IDE
  5. I don't know why but my energia is running very slow. All the other apps are running at good speed. I am using windows 10 64-bit version. I am using Energia V17. Pictures from my task manager are attached here, please take a look at it. Thax and peace.
  6. Dear developers, I am simply using Serial.println(); command, but I get some weird characters in the serial port display window. Code : #include <Wire.h> // HIH6130 I2C address is 0x27(39) #define Addr 0x27 int tzero = 196; int tspan = 17; int hzero = 196; int hspan = 17; void setup() { Wire.setModule(1); Wire.begin(); pinMode(P1_3,OUTPUT); pinMode(P1_2,OUTPUT); pinMode(P1_6,OUTPUT); Serial.begin(9600); Serial.println("OK"); delay(300); } void loop() { unsigned int data[4]; // Start I2C Transmission Wire.beginTransmission(Addr); // Select data register Wire.write(0x00); // Stop I2C Transmission Wire.endTransmission(); // Request 4 bytes of data Wire.requestFrom(Addr, 4); // Read 4 bytes of data // humidity msb, humidity lsb, temp msb, temp lsb if (Wire.available() == 4) { data[0] = Wire.read(); data[1] = Wire.read(); data[2] = Wire.read(); data[3] = Wire.read(); } // Convert the data to 14-bits float humidity = ((((data[0] & 0x3F) * 256) + data[1]) * 100.0) / 16383.0; float temp = ((data[2] * 256) + (data[3] & 0xFC)) / 4; float cTemp = (temp / 16384.0) * 165.0 - 40.0; // Output data to serial monitor Serial.print("Relative Humidity :"); Serial.println(humidity); Serial.println(" %RH"); Serial.print("Temperature in Celsius :"); Serial.println(cTemp); Serial.println(" C"); Serial.println("=============================================================== "); int VcTemp = map(cTemp, -5, 125, tzero, tspan ); int vhumidity = map (humidity, 0, 100, hzero, hspan); analogWrite(P1_2, VcTemp); analogWrite(P1_6, vhumidity); delay(1000); } Serial Output : (in one single line, means it keeps printing these characters in just one line on and on.picture : Thax.
  7. An output power display for my solar system. G2553 Launchpad, Blue 4-digit LED display, RS485 Transceiver SN65HVD12P (a low power, 3.3V version of the standard SN75176), this is all there is. All pins are used, 4 + 7 for the multiplexed LEDs (no resistors: Blue LED, 3.6V supply, output resistance of the pins limit the LED current) 3 pins for UART and send/receive for the SN65. 2 pins for 32768Hz xtal (I had this one soldered in on the LP, so why not use it) The MSP asks the inverter over RS485/Modbus "what is your current output power". After less than half a sec, the inverter aswers with the required value. This repeats every 2 seconds. The inverter is a Fronius Symo, with Datamanager 2 (which I guess is an embedded linux machine, covering LAN, Wifi, Modbus.....). The communication protocol can be downloaded from the Fronius website (after signing in), so no reverse engineering was required. Instead of only power, I could also display line voltage, frequency, total delivered energy.... This is just a working prototype on Launchpad, I will do a PCB later, I also plan to power this directly from the inverter (which has a 12V solar powered output for such things). See the picture, almost 7.5kW :-)
  8. I have a G2553 set up on a breadboard, and am using a USB-to-UART adapter for BSL flashing. TI provides BSLDEMO2.exe on the Windows side to do the flashing, but I've been unable to get it to work. If I use the special signalling pattern on /RST and Test, I get a "synchromization failed" error, and if I boot directly into the cold start vector of BSL, I get a "communications error". So I just wondered if anyone here has actually done this successfully? The two ends talk to each other, but it always errors out.
  9. Hi, my name is Fabian an im recently working on an MSP430 project with the Launchpad MSP-EXP430G2 and Energia 0101E0017. I have an TEG Harvester and want to run the MSP that sends data via a NRF24l01 module. Everything works great, current is really low in working and in sleeping mode. But now the problem: When i apply power to the chip (3,3V) it draws significant current for about 2 seconds. Then it starts working normal and the current drops and stays low as long as you don't remove the supply and start again. This is really bad for energy harvesting applications, because you need a much bigger harvester just because of that power up current that just happens sometimes. Is there a setting for the startup time? Please see my attached code. Thank you so much, Fabian PPEH.ino
  10. Hi, I'm trying to drive 15 ws2812b leds using a g2553 sitting on a Launchpad I'm finding the following behaviour a bit confusing and am wondering if anyone can provide an explanation... The code below is borrowed from RobG's post (http://forum.43oh.com/topic/2680-group-buy-10-o-rgb-smd-led-with-built-in-controller/page-4#entry23841 ) If I try to run at 16MHz the strip does not behave/work as expected BCSCTL1 = CALBC1_16MHZ; DCOCTL = CALDCO_16MHZ; However, if I set DCOCTL to CALDCO_1MHZ and keep BCSCTL1 at CALBC1_16MHZ (see code below) , the strip works fine... Is the clock calibration on my G2553 shot? How would one reset this? #include <msp430g2553.h> typedef unsigned char u_char; typedef unsigned int u_int; typedef struct { u_char r; u_char g; u_char b; } RGBLED; #define DATA_OUT_PIN BIT7 void sendRGB(u_char numberOfLEDs); RGBLED data[15] = { 0, }; // 0.5m strip void main(void) { WDTCTL = WDTPW + WDTHOLD; BCSCTL1 = CALBC1_16MHZ; DCOCTL = CALDCO_1MHZ; // setup USIB P1SEL |= DATA_OUT_PIN; P1SEL2 |= DATA_OUT_PIN; UCB0CTL0 |= UCCKPH + UCMSB + UCMST + UCSYNC; // 3-pin, 8-bit SPI master UCB0CTL1 |= UCSSEL_2; // SMCLK UCB0BR0 |= 0x03; // 1:3 - 16MHz/3 = 0.1875us UCB0BR1 = 0; UCB0CTL1 &= ~UCSWRST; u_char x = 0; u_char dir = 1; while (1) { u_char c = 0; while (c < 14) { data[c].r = x; //x << 3; data[c].b = x; //127 - (x << 3); data[c].g = x; //255 - (x << 3); data[c+1].r = 255 - x; data[c+1].b =255 - x ; data[c+1].g =255 - x; c+=2; } sendRGB(15); __delay_cycles(100000); if (dir) { x++; if (x == 0xFF) dir = 0; } else { x--; if (x == 0) dir = 1; } } } void sendRGB(u_char numberOfLEDs) { u_int c = 0; u_char led = 0; u_char leds[3]; u_char d; while (c < numberOfLEDs) { leds[0] = data[c].g; leds[1] = data[c].r; leds[2] = data[c].b; while (led < 3) { u_char b = 0; d = leds[led]; while (b < 8) { while (!(IFG2 & UCB0TXIFG)) ; (d & 0x80) ? (UCB0TXBUF = 0xF0) : (UCB0TXBUF = 0xC0); d <<= 1; b++; } led++; } led = 0; c++; } __delay_cycles(800); // delay 50us to latch data, may not be necessary } Thanks for any pointers Naren
  11. 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
  12. Hey all, I have attempted to take this project, http://forum.43oh.com/topic/1999-sd-media-player-with-fat16/, which was written for a G2353, and port it to a G2553. The main differences being: 1. USI on the G2353 vs. USCI on the G2553 2. Timer0_A3 on the G2353 has 3 control/compare registers, I needed to change the timer to Timer1_A3 on the G2553 since thats where it has 3 control/compare registers. 3. I also changed the pin defines to match the G2553. 4. Also the original project uses an SD card, while i am attempting to use a MicroSD card breakout board (should work the same as both can be formatted in FAT16, also the breakout board from sparkfun makes changing the files on the card super easy, plus it looks clean ) 5. I think thats about it... Overall, I am not quite sure about the .wav file format and how it needs to be placed on the the MicroSD card, ive seen people write raw data to the card in other projects, but that seems to defeat the point of the file system implementation... My current .wav file a mono, 24Khz sampled, 8 Bit .wav file (seems to be the kind of file the original project was using) I've attached the code I've been working on and a few pictures of the project itself. Also here is the pinout i am working with: P1.3- Chip Select (Attached to CS pin on microSD breakout board) P1.4- Card Detect(Attached to CD pin on microSD breakout board) P1.5- SCLK (Attached to SCK pin on microSD breakout board) P1.6- SOMI (Attached to DO pin on microSD breakout board) P1.7- SIMO (Attached to DI pin on microSD breakout board) P2.2- Left Channel Speaker output (Using TA1.1) P2.4- Right Channel Speaker output (Using TA1.2) The other pins i have connected in the picture are for UART console stuff and can be ignored. Any help would be greatly appreciated. Thanks again for taking the time to read this post. Cheers. Project_4_FAT.zip
  13. Hi everyone! This is my second time on the forum. The first time i was here it was to ask for help with interrupts and an LED display. 43oh was very helpful and I accomplished my goal. Today I am here to ask for help again. Goal: Implement the code previously written into the chip only and drive it without the development board. (breadboard mode) I did some research and most post/websites told me that all i need is 3.3V and a 47k resistor going from VCC to the RST pin on the chip and that my program would start working... I tried this and it did not. reference:http://crossplatform.net/running-msp430-launchpad-on-a-breadboard/ My question is, since I am working with interrupts and my code is a bit complicated, would i need an external clock/crystal? What do i need to move away from the development board and onto the breadboard? Thanks in advanced, everyone here is so helpful!!
  14. I am working on the MSP430G2553 using I2C and Serial libraries. I am playing right now to try to understand the usage of the libraries. I have an I2C slave that I am trying to control how much data gets returned when a read is executed. Using the serial interface I can increase the size that is sent over the I2C but I can't reduce the size even though the variable passed to Wire.write shows it has reduced. Slave code: #include <Wire.h> #define MY_ADDR 2 #define ERR_RQST_MSB 0xF0 ///< First byte sent when request hasn't been preceded by a value #define ERR_RQST_LSB 0x00 ///< Second byte sent when request hasn't been preceded by a value #define EXPECT_RQST_SIZE 2 ///< Expected size for any data request #define RSPNS_SIZE 2 ///< How many to send back for any request #define MONITOR_BAUD 38400 ///< Baud rate for monitor interface #define MIN_CMD 0 ///< Minimum valid command #define MAX_CMD 4 ///< Maximum valid command #define RESET_CMD 128 ///< Command to "reset" processor byte sendMSB = ERR_RQST_MSB; byte sendLSB = ERR_RQST_LSB; // Definition of the available one character commands typedef enum CommandList{ clEmpty = '\0', clWrtLen = 'w', clAdr = 'a', clBaud = 'b', }clist; const byte Term1 = (byte)'\r'; const byte Term2 = (byte)'\n'; byte cmd = 0; byte rx = 0; byte tx = 0; byte rxCmdBuf[16] = ""; byte *rxPtr = &rxCmdBuf[0]; bool processingCommand = false; bool newCommand = false; const uint8_t sendBuf[] = "0123456789012345678"; #define MAX_WRT_LEN 16 uint16_t curBaud = MONITOR_BAUD; uint8_t curAdrs = MY_ADDR; volatile uint8_t writeLen = 1; void setup() { Serial.begin(curBaud); // start serial for output Wire.begin(curAdrs); // join i2c bus with MY_ADDR Wire.onRequest(requestEvent); // register event Wire.onReceive(receiveEvent); // register event } void loop() { delay(100); if(tx > 0){ tx = 0; Serial.println("Tx"); } if(rx > 0){ rx = 0; Serial.println("Rx"); } receiveCommand(); processCommand(); } // Bring one command at a time into the buffer void receiveCommand(void) { // If they are processing a command then let new chars sit if(!processingCommand){ // Update the buffer if there is more data while(Serial.available() && !newCommand){ *rxPtr = Serial.read(); //Serial.write((char *)rxPtr); // If any terminating character came in then the command // is complete, mark it as such, otherwise add it to the buffer if((*rxPtr == Term1)||(*rxPtr == Term2)){ *rxPtr++ = 0; newCommand = true; }else{ *rxPtr = (byte)tolower(*rxPtr); rxPtr++; } } } } // Change this to do any special processing of the command void processCommand(void) { static uint16_t lastParm = 0; static byte lastCmd; // If there is anything to do then do it if(newCommand || processingCommand){ if(newCommand){ newCommand = false; lastCmd = rxCmdBuf[0]; lastParm = (uint16_t)strtoul((char *)&rxCmdBuf[1], NULL, 10); } // First character is always the command switch((clist)lastCmd){ case clWrtLen: processingCommand = false; if(lastParm < MAX_WRT_LEN){ writeLen = lastParm; } Serial.println("Write length"); Serial.println(writeLen); break; case clAdr: processingCommand = false; break; case clBaud: processingCommand = false; break; case clEmpty: processingCommand = false; break; default: Serial.println((char *)rxCmdBuf); Serial.println("Please enter a valid command"); processingCommand = false; break; } // Reset the buffer if we are done if(!processingCommand){ rxCmdBuf[0] = 0; rxPtr = &rxCmdBuf[0]; } } } // function that executes whenever data is requested by master // this function is registered as an event, see setup() void requestEvent() { byte len = writeLen; if(len > 15) writeLen = 2; Wire.write(sendBuf, len);//"slave says send something"); // respond with message of 6 bytes tx++; // as expected by master writeLen = 1; } // function that executes whenever data is received from master // this function is registered as an event, see setup() void receiveEvent(int howMany) { while(1 < Wire.available()) // loop through all but the last { char c = Wire.read(); // receive byte as a character Serial.print(c); // print the character } int x = Wire.read(); // receive byte as an integer Serial.println(x); // print the integer rx++; }
  15. What I want to do is: - toggle a GPIO at a rate variable from 1Hz to 5.5Hz; - toggle a GPIO at a rate that is 32 times faster than the other. The rate will be controlled by an external potentiometer. Possible with a G2553?
  16. Hello, I'm very new to uCs, so please bear with me and my inevitable incorrect use of terminology (corrections appreciated!). I've been doing a lot of reading, and wrote a little program to TX/RX characters from PuTTY over UART. I think maybe I have some inappropriate UART settings, because the very first TX always prints garbage, even on reset. Would someone mind please taking a look for me? I'll just post the UART setup routine, and the print routine unless posting the whole code would be more useful. I've also attached a PuTTY screenshot as an example of the "garbage" I mean, and my PuTTY config. (9600 baud, 8 data bits, 1 stop bit, no parity, no flow) I'm using the launchpad MSP-EXP430G2 v1.5 and the g2553. Windows 7, Code Composer V5.5 Thank you so much for any help! void uart_init() { /*Setup TX/RX for MSP430G2553*/ BCSCTL1 = CALBC1_1MHZ; // Set Basic Clock System (msp430g2553.h - 1MHz bitmask) DCOCTL = CALDCO_1MHZ; // Digitally Controlled Oscillator (msp430g2553.h - 1MHz bitmask) P1SEL |= BIT1 + BIT2; //Set for UART functionality P1SEL2 |= BIT1 + BIT2; //Set for UART functionality // Configure UCA0 control register UCA0CTL0 = 0; // Async, UART, One Stop, 8-bit data, LSB, Odd Parity, Parity Disabled UCA0CTL1 |= UCSSEL_2; // Use SMCLK as USCI clock source UCA0CTL1 &= ~UCSWRST; // Software Reset disabled - USCI reset released for operation /* 16-bit value (UCA0BR0 + UCA0BR1 x 256) = prescaler */ UCA0BR1 = 0; // 0 for prescaler maths? UCA0BR0 = 104; //1MHz (DCO?) So 1MHz/9600 = ~104 UCA0MCTL = UCBRS0; //Modulation Control Register (bitclk timing for bit value sampling?) IE2 |= UCA0RXIE; // Enable USCI_A0 RX interrupt } /*Transmit String byte-by-byte*/ void sendstring(char * str) { char *ptr; unsigned char len = 0; for (ptr = str; *ptr; ++ptr) ++len; //calculate string length int i; for (i=0; i<len; i++) { while (!(IFG2&UCA0TXIFG)); // USCI_A0 TX buffer ready? UCA0TXBUF = str[i]; } } an example, the first sendstring is: sendstring("garbage\n\r");
  17. Hi everyone! I stumbled on to this forum whilst searching for information about the msp430 micro controller, a component which i was tasked to use in building this project, the WASPS (wireless automatic slim pressure sensor) system. Basically the way it works is that Ive attached pressure sensors around a boxing head hear which is then attached to an msp430g2553 (no crystals) which is then connected via wires to an XBee 2mW PCB Antenna transmitter module. The Receiver, which is connected to the computer will print out text on the screen (terminal), i.e. '1 punch detected' everytime a signal is detected from the pressure sensors. so far: the ADC code is working fine for the msp430 from the sensors (UART) and the wireless modules are able to communicate with each other (i.e whatever gets sent from the transmitter is received by receiver and prints the output on terminal) Now my hurdle and my final piece of the puzzle is the msp430 sending the text 'punch detected' to the XBee module everytime it gets a signal from its ADC. I was wondering if anyone would be kind enough to help a noob out and suggest ways on how i could code the msp430 to do this? The logic im assuming would be something along the lines of: 1)signal detected in ADC, 2)print 'punch detected' 3)transmit? pls let me know if i am in the wrong thread. Much thanks.
  18. Hello everyone. I am more of a hardware dude, so software always makes me stay up all nights while trying to understand why it doesn't work and why DOES it work. Anyway, below is the code I am using. It works, kind of, but there is a problem. If I decrease delay, resolution goes down pretty bad, with 300ms it is 100RPM. If I Increase, of course it gets slow, and that is not ok in my application. As I am a total noob, I hope someone here might give me advice, what can I possibly do. Regards, Arch. volatile unsigned int rpmcount; float rpm; float timeold; const int carbswitch = P2_2; //switch from carburator, when accelerator is not pushed, switch is connected to GND. When accelerator is getting floored, disconnects. const int outputswitch = P2_4; //enables/disables gas valve, HIGH at >1400 RPM and carbswitch HIGH. const int shiftlight = P2_5; //enabled when RPM > 5000. const int engineok = P2_3; //enabled when RPM > 500. int carbswitchstate = LOW; int valvestate = LOW; int mymilis = 300; String ds; #include <LiquidCrystal.h> LiquidCrystal lcd(P1_2, P1_1, P1_4, P1_5, P1_6, P1_7); void rpm_fun() { rpmcount++; } //INPUT from ignition coil's switching GND is wired to P1_3, with protection from high voltage spikes. void setup() { lcd.begin(16, 2); attachInterrupt(P1_3, rpm_fun, FALLING); rpmcount = 0.0; rpm = 0.0; timeold = 0.0; pinMode (outputswitch, OUTPUT); pinMode (shiftlight, OUTPUT); pinMode (engineok, OUTPUT); pinMode(carbswitch, INPUT_PULLUP); } void loop() { if(millis()-timeold>=mymilis){ detachInterrupt(P1_3); const float freqHz = ((float) rpmcount / (float) (millis() - timeold)) * 1000.0; const float rpm = freqHz * 30.0; rpmcount = 0; carbswitchstate = digitalRead(carbswitch); if (rpm >= 1400.0 && carbswitchstate == HIGH) { digitalWrite(outputswitch, HIGH); } else { digitalWrite(outputswitch, LOW); } valvestate = digitalRead(outputswitch); if (valvestate == HIGH) { ds = ("ON"); } else { ds = ("OFF"); } if (rpm >= 5000.0) { digitalWrite(shiftlight, HIGH); } else { digitalWrite(shiftlight, LOW); } if (rpm >= 500.0) { digitalWrite(engineok, HIGH); } else { digitalWrite(engineok, LOW); } lcd.clear(); lcd.print("RPM="); lcd.print(rpm); lcd.setCursor(0, 1); lcd.print ("ECON="); lcd.print(ds); attachInterrupt(P1_3, rpm_fun, FALLING); timeold = millis(); } }
  19. Hi When trying to run following code, I can send the first integer "1" but if I continue after that, it just doesnt send anything back. However, with an Arduino UNO this code works 100%. How can I fix that? I hope somebody can try that for me, so I can confirm that it's the hardware/library and not the code. void setup() { Serial.begin(9600); } void loop() { if( Serial.available() > 0 ) { int inc = Serial.parseInt(); if(inc == 1) { int temp = analogRead(0); int pressure = analogRead(1); String t_str = String(temp); String p_str = String(pressure); String string = t_str + "#" + p_str + "."; Serial.println(string); } } } Thanks in advance.
  20. When programming recently, I found that I had some trouble controlling a motor at the same time as several servo. The servos would go all crazy, and the motor wouldn't work. I guessed that this was because the timers were interfering, or not enough timers, or similar. Digging into the servo library, and the analogWrite function, I found that they're both trying to use Timer A. Thus, I modified the analogWrite function. In file energia/hardware/msp430/cores/msp430/wiring_analog.c , I commented out lines 110 to 123 (inclusive). Below is the code commented out. case T0A1: // TimerA0 / CCR1 TA0CCR0 = PWM_PERIOD; // PWM Period TA0CCTL1 = OUTMOD_7; // reset/set TA0CCR1 = PWM_DUTY(val); // PWM duty cycle TA0CTL = TASSEL_2 + MC_1 + analog_div; // SMCLK, up mode break; #if defined(__MSP430_HAS_TA3__) || defined(__MSP430_HAS_T0A3__) case T0A2: // TimerA0 / CCR2 TA0CCR0 = PWM_PERIOD; // PWM Period TA0CCTL2 = OUTMOD_7; // reset/set TA0CCR2 = PWM_DUTY(val); // PWM duty cycle TA0CTL = TASSEL_2 + MC_1+ analog_div; // SMCLK, up mode break; #endif This may only work using the G2553, but if you're stuck with a G2231 from a rev 1.4 board, just sample a new chip
  21. Hi, I am new to the whole world of microprocessors and just playing around with my Launchpad v1.5 with the MSP430G2553 for a while. I got the UW UART up and running so far, using putty and the virtual "MSP430 Application UART" com port. The jumpers on J3 are set to HW UART. But I need some help understanding how the HW UART and the UART on P1.1 and P1.2 belong together or don't. I don't know if they are the same or something different. I am confused: What exactly changes when setting the jumpers on J3 to SW UART (virtual com port is still there, but why does my software not work anymore)? Does jumpering to SW UART affect P1.1/P1.2? Can I use the HW UART (like I am doing right now) together/independent from P1.1/P1.2? What is happening with P1.1/P1.2 right now, while using HW UART on virtual com port? I want to connect another IC's UART to P1.1/P1.2 to communicate with my MSP430. Is it important how jumpers @ J3 are set? Can I use HW UART for that? Is it possible to have this communication while still using the virtual com port with HW UART? You see, many questions, but just one basic problem in understanding. It would be nice if you could sum things up and make it clear to me. Thanks a lot!
  22. Hi everybody, Hopefully someone will be able to help. The aim of this project is to send an image from my laptop over a serial port to the MSP430G2553 where the data will be processed and then the image will be shown on my RGB LED display. At present I'm looking at methods of converting an image into an RGB array. I found that using GIMP, a file can be exported as a ".c" source code file which converts the image into an array. - Although the syntax is unlike any I have seen before. Anyways, i am using a program I found on the web to do the sending of the data over the serial port (http://batchloaf.wordpress.com/2013/02/13/writing-bytes-to-a-serial-port-in-c/) then I am simply changing the "bytes_to_send" array to the image array. On the receiving end of the transmission, I am unsure how to process the data - should I do it in the "USCI0RX_ISR" ? Here's the code from which I am working: #include <msp430g2553.h> #include <msp430.h> // TLC inputs #define VPRG_PIN BIT0 // TIE TO GND? #define RX_PIN BIT1 #define TX_PIN BIT2 #define GSCLK_PIN BIT4 #define SCLK_PIN BIT5 #define DATA BIT6 // DS -> 1.6 | 595 DATA PIN #define MOSI_PIN BIT7 #define DCPRG_PIN BIT0 // TIE IT TO GND? #define XLAT_PIN BIT1 #define BLANK_PIN BIT2 #define CLOCK BIT3 // SH 11 -> 2.3 // 595 OUTPUTS #define LATCH BIT4 // ST 12 -> 2.4t typedef unsigned char u_char; typedef unsigned int u_int; typedef unsigned short u_short; typedef unsigned long u_long; // ================================// // Prototypes // // ================================// void init( void ); void SPI( void ); void UART(void); void updateTLC( void ); void shiftOut( u_long ); void HSV2RGB( u_short*, u_short*, u_short*, short,u_char); void set_row_char_hue (u_char, u_long, short,u_char); void row_refresh(u_char,short,short,short,short,short,short,short,short,short,short,short,short,short,short,short,short); void clearArray(void); void serialSnake(void); void extractRGB(); // ===================================================================================== #define UPDATE {P2OUT |= (BLANK_PIN);P2OUT |= (XLAT_PIN);P2OUT &= ~(XLAT_PIN);P2OUT &= ~(BLANK_PIN);updateTLC();} #define NUMBER_OF_OUTS 48 // TLC OUTPUTS #define NUMBER_OF_ROWS 16 #define NUMBER_OF_COLUMNS 16 #define max_COLUMN NUMBER_OF_COLUMNS-1 #define max_ROW NUMBER_OF_ROWS-1 #define OFF 0 u_short leds[NUMBER_OF_OUTS]; // 0 - 15 Red Rows, 16 - 31 Blue Rows, 32 - 47 Green Rows {0, } short columnArray[16] = {0x8000,0x4000,0x2000,0x1000,0x0800,0x0400,0x0200,0x0100,0x0080,0x0040,0x0020,0x0010,0x0008,0x0004,0x0002,0x0001}; u_char rowArray[16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; u_char cnt = 0; u_char SAT = 255; // full colour // ========== SERIAL GLOBAL VARIABLES =================================== u_char rxRow = 0; u_char rxCol = 0; u_char image[16][16]; u_char colour[3]; u_char Count = 0; u_char cCount = 0; u_char rCount = 0; // ====================================================================== void init(void) { WDTCTL = WDTPW + WDTHOLD; // disable WDT BCSCTL1 = CALBC1_16MHZ; // 16MHz clock DCOCTL = CALDCO_16MHZ; BCSCTL2 |= DIVS_0; // divide clock by 1 // Setup TLC and 595 outputs P1DIR |= (VPRG_PIN + GSCLK_PIN + DATA); P1SEL |= GSCLK_PIN; // port 1.4 configured as SMCLK out P2DIR |= (BLANK_PIN + XLAT_PIN + CLOCK + LATCH + DCPRG_PIN); P1OUT &= ~(VPRG_PIN); P2OUT &= ~(BLANK_PIN + XLAT_PIN); P2OUT &= ~DCPRG_PIN; // setup timer TA0CCR0 = 0xFFF; TA0CTL = TASSEL_2 + MC_1 + ID_0; // SMCLK, up mode, 1:1 TA0CCTL0 = CCIE; // CCR0 interrupt enabled // // setup FrameBuffer Timer // TA1CCR0 = 0xFFF; // TA1CTL = TASSEL_2 + MC_1 + ID_0; // SMCLK, up mode, 1:1 // TA1CCTL0 = CCIE; // CCR0 interrupt enabled } void SPI(void) { // SPI setup UCB0 P1SEL |= SCLK_PIN + MOSI_PIN; // pins 5 + 7 P1SEL2 |= SCLK_PIN + MOSI_PIN; // UCB0CLK + UCB0SIMO UCB0CTL0 = UCCKPH + UCMSB + UCMST + UCSYNC; // data captured on 1st UCLK edge/changed on follwing edge, MSB first, master, 3-pin SPI,synchronous UCB0CTL1 |= UCSSEL_2; // SMCLK UCB0BR0 |= 0x01; // 1:1 UCB0BR1 = 0; UCB0CTL1 &= ~UCSWRST; // clear SW } void UART(void) { // UART Setup UCA0 P1SEL |= RX_PIN + TX_PIN; //Set P1.1 and P1.2 to RX and TX P1SEL2 |= RX_PIN + TX_PIN; UCA0CTL1 |= UCSSEL_2; //SMCLK UCA0BR0 = 138; //115200 @[member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""] 16MHz UCA0BR1 = 0; //115200 UCA0MCTL = UCBRS_1; //Modulation UCA0CTL1 &= ~UCSWRST; //Start USCI IE2 |= UCA0RXIE; //Enable RX interrupt } void main(void) { u_char z; init(); SPI(); UART(); updateTLC(); P2OUT |= (XLAT_PIN); P2OUT &= ~(XLAT_PIN); _bis_SR_register(GIE); for(; { // extractRGB(); while (!(IFG2 & UCA0RXIFG)); for(z = 0; z < 16; z++) { leds[z] = colour[0] * 16; //r leds[z+32] = colour[1] * 16; // g leds[z+16] = colour[2] * 16; // b shiftOut(columnArray[rxCol]); } _bis_SR_register(LPM0_bits); } } void updateTLC(void) // RobG's code { u_char ledCounter = NUMBER_OF_OUTS >> 1; while (ledCounter-- > 0) { u_char i = ledCounter << 1; UCB0TXBUF = leds[i + 1] >> 4; while (!(IFG2 & UCB0TXIFG)); // TX buffer ready? u_char unib = leds[i + 1] << 4; u_char lnib = (leds[i] >> 8) & 0x0F; UCB0TXBUF = unib | lnib; while (!(IFG2 & UCB0TXIFG)); // TX buffer ready? UCB0TXBUF = leds[i]; while (!(IFG2 & UCB0TXIFG)); // TX buffer ready? } } //void extractRGB(void) //{ // u_char i; // for(i=0;i<16;i++) // { // leds[i] = image[3*i][rxCol]; // leds[i+16] = image[(3*i)+1][rxCol]; // leds[i+32] = image[(3*i)+2][rxCol]; // shiftOut(columnArray[rxCol]); // } //} void shiftOut(u_long val) { P2OUT &= ~LATCH; int i; for (i = 0; i < 32; i++) // iterate over each bit 16 { if(val & (1 << i)) { P1OUT |= DATA; } else { P1OUT &= ~DATA; } P2OUT |= CLOCK; // PULSE CLOCK P2OUT ^= CLOCK; } P2OUT |= LATCH; // PULSE LATCH P2OUT &= ~LATCH; } #pragma vector=USCIAB0RX_VECTOR __interrupt void USCI0RX_ISR(void) { while(UCA0RXBUF) { if(Count < 3) { colour[Count] = UCA0RXBUF; Count++; } else { Count = 0; } if( rCount == 48 ) { rxRow++; rCount = 0; } else { rCount++; } if( cCount == 16 ) { cCount = 0; } else { rxCol++; cCount = 0; } } } #pragma vector = TIMER0_A0_VECTOR __interrupt void Timer_A0(void) { _bic_SR_register_on_exit(LPM0_bits); // wake up main loop so that it can prepare data for the next frame } #pragma vector = TIMER0_A1_VECTOR __interrupt void Timer_A1(void) {} I've taken out a bunch of functions which won't be used for this part of the project, so there are some variables etc. which arent used. Below is the modified version of the TX code I am using with the GIMP image array included: // serial.c / serial.cpp // A simple serial port writing example // Written by Ted Burke - last updated 13-2-2013 // // To compile with MinGW: // // gcc -o serial.exe serial.c // // To compile with cl, the Microsoft compiler: // // cl serial.cpp // // To run: // // serial.exe // #include <windows.h> #include <stdio.h> /* GIMP RGB C-Source image dump (TEST.c) */ // export opacity 68 #define GIMP_IMAGE_WIDTH (16) #define GIMP_IMAGE_HEIGHT (16) #define GIMP_IMAGE_BYTES_PER_PIXEL (3) /* 3:RGB, 4:RGBA */ #define GIMP_IMAGE_PIXEL_DATA ((unsigned char*) GIMP_IMAGE_pixel_data) static const unsigned char bytes_to_send[16 * 16 * 3 + 1] = ("\255\0\0\0\255\255\255\255\255\255\255\255\255\255\255\255\255\255\0\255\255" "\255\0\0\255\0\0\0\255\255\255\255\255\255\255\255\255\255\255\255\255\255" "\0\255\255\255\0\0\0\255\255\255\255\255\255\255\255\255\255\255\255\255\255" "\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255" "\255\255\255\255\255\255\255\255\255\255\255\0\255\255\255\255\255\255\255" "\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255" "\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255" "\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\0\255\255" "\0\255\255\255\255\255\255\0\255\0\0\255\0\255\255\255\255\255\255\255\255" "\0\255\255\0\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255" "\255\255\255\255\0\255\255\0\255\255\255\255\255\255\0\255\0\0\255\0\255\255" "\255\255\255\255\255\255\0\255\255\0\255\255\255\255\255\255\255\255\255\255" "\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255" "\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255" "\255\255\255\255\255\255\255\255\255\0\255\255\255\255\255\255\255\255\255" "\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255" "\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\0\255\255" "\255\0\0\255\255\255\255\255\255\0\255\0\0\255\0\255\255\255\255\255\255\0" "\0\255\0\0\255\255\255\255\255\255\255\0\255\0\0\255\0\255\255\255\255\255" "\255\255\0\0\255\0\0\255\255\255\255\255\255\0\255\0\0\255\0\255\255\255\255" "\255\255\0\0\255\0\0\255\255\255\255\255\255\255\0\255\0\0\255\0\255\255\255" "\255\255\255\255\0\0\0\255\255\255\255\255\255\255\255\255\255\255\255\255" "\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255" "\255\255\255\255\255\255\255\255\255\255\255\255\0\255\255\255\255\255\255" "\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255" "\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255" "\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\0\255" "\255\0\255\255\255\255\255\255\0\255\0\0\255\0\255\255\255\255\255\255\255" "\255\0\255\255\0\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255" "\255\255\255\255\255\0\255\255\0\255\255\255\255\255\255\0\255\0\0\255\0\255" "\255\255\255\255\255\255\255\0\255\255\0\255\255\255\255\255\255\255\255\255" "\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255" "\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255" "\255\255\255\255\255\255\255\255\255\255\0\255\255\255\255\255\255\255\255" "\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255" "\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\0\255" "\255\255\0\0\0\255\255\255\255\255\255\255\255\255\255\255\255\255\255\0\255" "\255\255\0\0\255\0\0\0\255\255\255\255\255\255\255\255\255\255\255\255\255" "\255\0\255\255\255\0\0"); int main() { // Define the five bytes to send ("hello") // char bytes_to_send[5]; // bytes_to_send[0] = 104; // bytes_to_send[1] = 101; // bytes_to_send[2] = 108; // bytes_to_send[3] = 108; // bytes_to_send[4] = 111; // Declare variables and structures HANDLE hSerial; DCB dcbSerialParams = {0}; COMMTIMEOUTS timeouts = {0}; // Open the highest available serial port number fprintf(stderr, "Opening serial port..."); hSerial = CreateFile( "\\\\.\\COM5", GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL ); if (hSerial == INVALID_HANDLE_VALUE) { fprintf(stderr, "Error\n"); return 1; } else fprintf(stderr, "OK\n"); // Set device parameters (115200 baud, 1 start bit, // 1 stop bit, no parity) dcbSerialParams.DCBlength = sizeof(dcbSerialParams); if (GetCommState(hSerial, &dcbSerialParams) == 0) { fprintf(stderr, "Error getting device state\n"); CloseHandle(hSerial); return 1; } dcbSerialParams.BaudRate = CBR_115200; dcbSerialParams.ByteSize = 8; dcbSerialParams.StopBits = ONESTOPBIT; dcbSerialParams.Parity = NOPARITY; if(SetCommState(hSerial, &dcbSerialParams) == 0) { fprintf(stderr, "Error setting device parameters\n"); CloseHandle(hSerial); return 1; } // Set COM port timeout settings timeouts.ReadIntervalTimeout = 50; timeouts.ReadTotalTimeoutConstant = 50; timeouts.ReadTotalTimeoutMultiplier = 10; timeouts.WriteTotalTimeoutConstant = 50; timeouts.WriteTotalTimeoutMultiplier = 10; if(SetCommTimeouts(hSerial, &timeouts) == 0) { fprintf(stderr, "Error setting timeouts\n"); CloseHandle(hSerial); return 1; } // Send specified text (remaining command line arguments) DWORD bytes_written, total_bytes_written = 0; fprintf(stderr, "Sending bytes..."); if(!WriteFile(hSerial, bytes_to_send, 769, &bytes_written, NULL)) { fprintf(stderr, "Error\n"); CloseHandle(hSerial); return 1; } fprintf(stderr, "%d bytes written\n", bytes_written); // Close serial port fprintf(stderr, "Closing serial port..."); if (CloseHandle(hSerial) == 0) { fprintf(stderr, "Error\n"); return 1; } fprintf(stderr, "OK\n"); // exit normally return 0; } If anyone could help that would be much appreciated since this is the last part of my project! Cheers
  23. I finally have an LCD display to connect to my MSP430 Launchpad but I'm not sure which pins to connect. I decided to use a serial inteface because it will leave more pins open on my Launchpad for other inputs and outputs. Here is the pin description but it doesn't really tell me what CS, SDO, SDI, and SCL mean. As far as the pins on the Launchpad http://www.ti.com/lit/ds/symlink/msp430g2553.pdf (Pages 6-8) I'm not really sure which ones to use for CS, SDO, SDI, and SCL. Could it just be any pins with digital read and digital write functionality? If so, I assume it would be best to use the ones that don't have other available functions in case I need to use those.
  24. Hi people! Basically I'm writing a function to control a 16x16 RGB LED matrix with serial communication. The function I'm writing requires an array of size 16x16 ( hueBuffer[16][16] ) and of type 'short' since the max value of hue is 359. However, I keep getting an error: "program will not fit into available memory. run placement with alignment fails for section "DATA_GROUP" size 0x23d" but there is plenty of memory on the G2553. I need the values of hue to go up to 360 so i cant use unsigned chars. Anyone know of a solution to this problem? I'll post the code if you want. Cheers!
  25. Hello all, This is my project for my design class at the university I am currently attending. It is the first circuit/PCB I have made that is not just a simple circuit on a breadboard. I'm happy to say it worked on the first try and thanks to Username and his reflow oven I was able to solder all of the surface mount components. I'm sure I'll be saying this again in the future, but thank you RobG for the inspiration for this project! :thumbup: Parts: MSP430G2553 TLC5971 Piranha RGB LEDs
  • Create New...