Jump to content


  • Content Count

  • Joined

  • Last visited

About curtis63

  • Rank
    Level 1

Profile Information

  • Gender
  • Location
    Utah, USA

Recent Profile Visitors

748 profile views
  1. curtis63

    MSP430G2553 PWM Accuracy

    Excellent!! Thank you for that.
  2. curtis63

    MSP430G2553 PWM Accuracy

    I need to have a very accurate PWM frequency generated with my MSP430G2553IRHB32R. I'm shooting for 25.1khz. However, when running on different boards, I can see variances of up to 3khz in the frequency. I understand this is due to the slight inaccuracy in the processor's internal clock. So, I would like to attach an external crystal or oscillator to it but don't know how. I've read a couple places that say that this chip doesn't support a crystal, but that I could use an oscillator. The questions I have is how does one connect the oscillator, and what code changes are necessary to take advantage of the oscillator? Thanks.
  3. curtis63

    PWM accuracy on MSP430G2553

    I'm working on a project where I need to oscillate at 25khz. I've been using the PWM built into the MSP430G2553 and it doesn't seem to be accurate enough to give me exactly 25khz. I've been getting anywhere from 23khz to 27khz and cannot figure out why it's off by so much. I might be doing something wrong. Does anybody know what sort of accuracy I should expect from the on board PWM in the MSP430G2553. Is there a way to make it more accurate? I was looking at adding an external crystal, but would rather not add that complication if it isn't necessary.
  4. curtis63

    MSP430G2553 Power Monitoring

    Does Energia have a function call to check the value, or does this involve reading a register somewhere? I'm a windows developer, not a micro-controller developer (that's why I'm using Energia) :-) Thanks for your patience with me.
  5. curtis63

    MSP430G2553 Power Monitoring

    I'd like to monitor power and indicate to the user of my device when power is getting low (via flashing LED). Does MSP430G2553 support power monitoring and does the Energia library have any tools to access this monitoring?
  6. Seems to me that I2C is a fairly commonly used way to communicate between MSP430G2553 and various sensors. However, I cannot seem to find a standard library that implements it. There are many home spun implementations and there doesn't seem to be a standard I2C Library. I'm VERY NEW to the embedded development world, but have been a windows programmer for 20 years. I'm used to having standard reusable libraries that do the grunt work for me so I don't have to re-invent something that has been done by others 100 times already... Am I just missing something or are all embedded developers just masochists?? Surely not.. So, does anybody know where I can find a simple I2C library that works with my MSP430G2553 in Code Composer Studio 7? Any reason why it isn't just built in? Or is it? This is a huge paradigm shift for me, so please be patient. Any help would be appreciated.
  7. I'm writing my own i2c library and need to be able to simultaneously change PinMode on 2 pins. One for SCL and one for SDA. Is there a way to change PinMode on 2 pins simultaneously? I want the behavior of the follwing: PinMode(14,OUTPUT); PinMode(15,INPUT); without the 2.5microsecond delay between the 2 calls above.
  8. Thanks to all who have offered advice and perspective to this discussion. I have attempted my implementation using energia, but I run into bizzare behavior that I cannot figure out. For example. When using i2c, everything seems to be working just fine. I'm talking to a sensor, reading out of its fifo, getting data perfectly, then, after right around 32 seconds (no matter how long I delay between reading out of the fifo) the data gets garbled. There are 5 byte values I need to read and combine to convert it into data and they seem to just get off by some random number of bytes. So the data turns to junk. It happens pretty much at precisely 32 seconds. I can use the very same code on Energia and Arduino. When I use the Arduino code with an arduino nano to talk to my sensor, it's all perfect without any 32 second bug. But, using Energia with an MSP430 launchpad and absolutely no change in my code, it bugs out at 32 seconds. I have no clue why.. Another oddity, is when using bit banging to generate a 25khz frequency on a speaker, I get a wierd hesitation at around 1khz. This causes the side effect of having a harmonic at 1khz which makes a hum noise when the 25khz frequency should be inaudible to human ears. I can see the pattern on my oscilliscope at 1khz and at 25khz.. My code doesn't have a delay, so it's somewhere in the guts of Energia, or the way it talks to the MSP430, or something in the looping or communication. The above two problems make my solution unusable. This is why I attempted to rewrite an i2c implementation. I have trouble with this because there's not an actual way to do a real open collector pin with Energia. You have to fake it by doing a digitalWrite(pin, LOW) and then changing the pinMode(pin,OUTPUT) if you want it low and pinMode(pin,INPUT) if you want it to pull high (with your pullup resisters). The problem is that when you're doing that with both SCL and SDA one after the other, there is about a 2microsecond delay between the two mode changes, which appears to confuse the sensor I'm trying to talk to. Using the Wire library, it appears to change both pinModes simultaniously which is good, but when I use the Wire library, I have that weird 32 second bug. Anyway, looks like I'm going to go directly to CCS and use it to code directly and perhaps remove some of the oddities that I'm seeing. Plus, it will give me a bit more control over the extreme low power mode stuff that I need to use.
  9. Good Morning, This may be the wrong place to ask this question. If so, please let me know where to ask it.. I've been a Windows programmer for 20 years. I've pretty much stuck to User Interface development the whole time. I have been using .net and C# for the past 10 years so I am VERY SPOILED when it comes to letting the language do the grunt work and I finesse the code. I now find myself working on a personal project which requires me to program the MSP430G2553 controller. I started out by using Energia (which if you don't know, is a fork off of Arduino) The advantage of it is you can do a lot with very little code and without needing to know all the guts of the MSP430G2553. The disadvantages are that sometimes it doesn't work right. Sometimes it doesn't give you the control you need, sometimes it's hard to figure out if Energia isn't working, or if your code isn't working... Anyway, I've spent hundreds of hours getting parts of my program to work. I have been trying to get away with not having to learn how to write firmware and have to deal directly with the processor. However, I'm starting to think that I need to bite the bullet and take the time to overcome my learning curve and dive in headfirst to firmware development and the paradigm shift that comes with it. The program I am using needs to have control over changing into and out of the various Low Power Modes on the MSP430. I need to listen for interrupts. I need to use I2C to communicate with various devices that are connected to the MSP430. I need to monitor Power Level/Consumption from time to time. So, basically, I have the following questions: 1. Can Energia robustly and without errors do the above things? 2. Am I wasting my time getting all of the above accomplished using Energia? 3. Should I be using Code Composer Studio? 4. Having NEVER developed ANY controller level code outside of Arduino and Energia, what kind of Learning Curve am I looking at to accomplish the above things? 5. Where is the best place to start learning this? 6. Where is the best place to look for answers to MSP430 development questions? Thank you all in advance for any assistance and advice you might have.
  10. curtis63

    i2c has the SDA line held low

    I'm attempting to get as close to an OpenCollector PIN as I can with the MSP430G2553 Launchpad and a sensor. SCL is P1.6 and SDA is P1.7. I digital write both pins LOW and then set the PinMode on both to INPUT which should allow both pins to float HIGH. I have a 4.7K pullup resistor on each pin connecting it to 3.55v (HIGH). Is my code wrong, or is the sensor that I'm using pulling the line low? The sensor says it operates at a max of 3.7 volts. I'm using the Launchpad which measures 3.55v. Am I overloading the sensor and causing it to pull SDA to low? #define SDA P1_7 #define SCL P1_6 void setup() { Serial.begin(9600); Serial.println("Starting..."); digitalWrite(SDA, LOW); digitalWrite(SCL, LOW); pinMode(SDA, INPUT); pinMode(SCL, INPUT); delay(50); Serial.print("SDA pin - "); Serial.print(SDA); Serial.print(" - "); Serial.println(digitalRead(SDA)); Serial.print("SCL pin - "); Serial.print(SCL); Serial.print(" - "); Serial.println(digitalRead(SCL)); }
  11. So, I googled Wire.setModule() and got just about bupcuss.. IE: Nada... Can somebody explain the different modules and what each of them do? I use setModule(0) so that I can use pins 1.6 and 1.7 for my SCL and SDA respectively. And that's just because somebody recommended it in a posting somewhere. I have no idea what the possible modes are or what the differences are between them...
  12. So I have frustration with Wire.h because I was having weird behavior with one of my sensors. For about 32 seconds, I would get perfect data from it, and then after 32 seconds, my data would turn to crap. It didn't matter if I read the data often, or at 10 second intervals, it still crapped out at 32 seconds. I was reading 5 bytes and doing some math on them to get the actual values. These bytes seemed to be getting 'off' by a byte or two, so the data turned to junk. I wasn't sure why this was happening. Then, I looked closely at the I2C on a scope and discovered that Wire.h was sending double starts... It would send a start, start writing a couple bits, then start over. I think that was confusing the sensor I was using. I couldn't figure out why Wire would do that, so I figured I'd just write my own i2c library since it's really not that complicated. Or that's what it appears to be.. After having attempted to implement it, I'm finding that the following isn't working as expected: digitalWrite(SDA, LOW); digitalWrite(SCL, LOW); pinMode(SDA,INPUT); pinMode(SCL,INPUT); I would expect the above to make it so that SCL and SDA would now read as HIGH, since they're released to allow the pullup resisters to pull them up. However, when I do the following afterwords: Serial.println(digitalRead(SDA)); Serial.println(digitalRead(SCL)); I get a 0 and a 1... I would have expected both lines to be HIGH.. Why is the SDA line still LOW ??? I'm using a MSP430G2553 controller and am using a 4.7k pullup resister on each the SDA and on the SCL pins (one resister per pin). Any suggestions as to why Wire would be sending double starts after 32 seconds, or why the above results in SDA still being LOW would be very helpful. My suspicion is that one of my sensors is pulling the pin low for some reason...
  13. Yes, I do have external pullups on the SCL and SDA lines. I'm using 4.7k resistors. As to Liviu's response, I saw similar response on a different forum and here's the way I now understand it. If i call: digitalWrite(SDA, LOW); that simply sets a value somewhere that will be used on SDA when it is in OUTPUT mode. When I call: pinMode(SDA, INPUT); it sets SDA pin to OpenCollector mode which will allow other sensors to pull it LOW, or release it and allow the pullup resister to pull it up to HIGH. When I call: pinMode(SDA, OUTPUT); it sets SDA pin to whatever I set it to with my last digitalWrite statement. So, to use it as an OpenCollector and be able to pull it LOW and release it to go HIGH, I just need to do the following: Setup() { pinMode(SDA, INPUT); //use the pin as open collector digitalWrite(SDA, LOW); //use this as a placeholder for when I want to actually set the pin to LOW } Loop() { .... .... pinMode(SDA, OUTPUT); //Pull the pin to LOW .... .... .... .... pinMode(SDA, INPUT); //release the pin and allow the pullup resister to pull it to HIGH if I'm writing a HIGH bit to the line, or allowing others to write to the pin .... .... .... int value = digitalRead(SDA); //read whatever was written to the pin by any i2c sensor on the line .... .... .... pinMode(SDA, OUTPUT); //Pull the pin to LOW if I'm writing data out to the line } I think this is going to work. Thanks for all the help !!!
  14. So, I'm using Energia and getting frustrated with Wire.h. I need to do some i2c communications and figured it would be fairly easy to write my own Bit-Bang implementation of i2c. I got started and things seem to be working pretty well. However, I discovered the concept of OpenCollector. It seems that OpenCollector means that the pin is set to High by default with a Pullup Resister and you just set it to LOW and then it goes back to high when you're not setting it to LOW. It also goes to low when a slave i2c device sets it to LOW. Question is how the heck do we do this with Energia?? Does pinMode(INPUT) set a pin to OpenCollector mode? Does pinMode(INPUT_PULLUP) set a pin to OpenCollector mode? If either of these do, what does digitalWrite(LOW) do on that pin? It sets it to LOW, but for how long? Do you have to set it back to HIGH, or does it get pulled back up to HIGH, or does setting it to HIGH, just release the LOW pull-down? This behavior doesn't seem to be documented anywhere that is easy to find. Perhaps it's not intended to be used that way, but I don't know how a person would implement i2c correctly without being able to set the SCL and the SDA to OpenCollector mode and to be able to pulse the clock. Speaking of pulsing the clock, how is that to be accomplished? Seems like you should be able to pull it LOW and then let it go, but I'm not sure how to 'let it go' back to its HIGH state without just calling digitalWrite(HIGH) on that pin.. But then aren't I holding it high? Anyway, if somebody has a good explanation around this, I would LOVE to hear it. I found some hints about it at the following location http://energia.nu/Constants.html But it didn't use the term OpenCollector anywhere...
  15. curtis63

    A pins_energia.h file for MSP430G2553IRHB32R

    /* ************************************************************************ * pins_energia.h * * Energia core files for MSP430 * Copyright