Jump to content

curtis63

Members
  • Content Count

    54
  • Joined

  • Last visited

Everything posted by curtis63

  1. Excellent!! Thank you for that.
  2. 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. 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. 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. 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. 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. /* ************************************************************************ * pins_energia.h * * Energia core files for MSP430 * Copyright
  16. It is times like this when I want to just bang my head against the wall about 3000 times... THANK YOU THANK YOU THANK YOU !!!!!!!!!!!!!!!!!!!!!!!!! THANK YOU THANK YOU THANK YOU !!!!!!!!!!!!!!!!!!!!!!!!! THANK YOU THANK YOU THANK YOU !!!!!!!!!!!!!!!!!!!!!!!!! THANK YOU THANK YOU THANK YOU !!!!!!!!!!!!!!!!!!!!!!!!! THANK YOU THANK YOU THANK YOU !!!!!!!!!!!!!!!!!!!!!!!!! THANK YOU THANK YOU THANK YOU !!!!!!!!!!!!!!!!!!!!!!!!! THANK YOU THANK YOU THANK YOU !!!!!!!!!!!!!!!!!!!!!!!!! THANK YOU THANK YOU THANK YOU !!!!!!!!!!!!!!!!!!!!!!!!! THANK YOU THANK YOU THANK YOU !!!!!!!!!!!!!!!!!!!!!!!!! That solved my problem. I thought that I had corrected all those places, but I apparently missed one. Thanks so much. It's 7:13am and I've been up all night trying everything I could think of. Life is groovy now !!!
  17. So, I've read the threads and have made things work once, but now, without seeming to have changed anything, I'm getting code that goes into never-never land.. In twi.c, around line 607 in Energia version 17, I get a lockup in the first while statement: #if defined(__MSP430_HAS_USCI__) || defined(__MSP430_HAS_USCI_B0__) || defined(__MSP430_HAS_USCI_B1__) /* Ensure stop/start condition got sent before we exit. */ if(sendStop) { while (UCBxCTL1 & UCTXSTP); // end with stop condition } else { while (UCBxCTL1 & UCTXSTT); // end with (re)start condition } #endif I've been trying different recommended suggestions all over the place and had it working about 60 minutes ago, but then I tried and moved some code around and now I can't get it to work anymore... I put all the code back the way it was, and NADA... still not working... Is it just a time of day thing or am I the only one who can't seem to have any consistency in the I2C behavior...? By the way, I'm using an MSP430G2553 chip with 32 pins in the QFN configuration. I really did have this working an hour ago and cannot for the life of me figure out why it stopped working. Any hints would be GREAT.. By the way, the reason I'm not using Energia Version 18 is because it isn't supported in Code Composer Studio yet.. Anybody know when that support will appear? Thanks for any help you might have to offer, Curtis Please see my Pins_energia.h file below: /* ************************************************************************ * pins_energia.h * * Energia core files for MSP430 * Copyright
  18. So, is there some repository somewhere that contains more pins_energia.h files for the various flavors of the MSP430G2553 chip? I'm using the MSP430G2553IRHB32R and am suspicious that my attempt and creating an accurate pins_energia.h file for it have failed miserably.. Just wondering, before I put hours of effort into it, if somebody has already created a pins_energia.h file for the MSP430G2553IRHB32R. Thanks, Curtis
  19. Ok, so I've changed over to an MSP430G2553IRHB32R Controller. This is in the QFN 32 pin package. According to it, P1.6 is for SCL I2C and P1.7 is for SDA I2C. On the 20 pin board, they are pins 14 and 15. On the 28 pin board they are pins 22 and 23. On the 32 pin board they are pins 21 and 22. So, I'm trying to use the simple I2C Scanner and get nothing. I have 2 I2C devices attached, but cannot see either of them. There have been many posts about inserting a Wire.write(1); command and copying updated files into the system. I'm using the latest Energia 18 on a Windows 10 machine. I'm using LaunchPad 430 to program my custom board which has the MSP430G2553IRHB32R controller on it. Seems like any time I attempt to use a different board, I have problems with the Wire library. It seems to hang up during the endTransmission call. I've tried 'SetModule(0)' and that doesn't work either. I've checked the Pins_Energia.h file to make sure the pins were correct. So, all that being said, Should I keep up the battle with Wire.h, use a different I2C library, or just write my own I2C library? As I work with firmware more and more, I have a growing respect for those of you who live in that world. You guys are amazing !!! I appreciate any help you are able to offer to get the I2C working on my custom board. Thanks, Curtis
  20. So, has anybody actually implemented ToneAC for Energia? If so, please share and let me know where I might find it. I'm currently using a BitBang and having some unwanted harmonics appear which are causing me grief. So, let me know if ToneAC exists yet. If not, let me know that too.
  21. Ok, so I figured it out. The problem was C16 !!! For production, you want a 2200 pF capacitor between RST and Ground. This makes it impossible for the chip to be reprogrammed (unless disconnected). So, for development, REMOVE this capacitor. RST on the chip should NOT be connected to ANYTHING except for the programming board. My problem was that I had RST connected to Ground through a 2200pF capacitor. This made it so Energia did not recognize the chip for programming... And it gave me the following output when I attempted to upload to my device: MSP430_GetNumberOfUsbIfs MSP430_GetNameOfUsbIf Found FET: HID0003:COM5 MSP430_Initialize: HID0003:COM5 Firmware version is 20409001 MSP430_VCC: 3000 mV MSP430_OpenDevice tilib: MSP430_OpenDevice: Could not find device (or device not supported) (error = 4) tilib: device initialization failed the selected serial port tilib: device initialization failed does not exist or your board is not connected
  22. //32 pins /* ************************************************************************ * pins_energia.h * * Energia core files for MSP430 * Copyright
  23. //28 Pins /* ************************************************************************ * pins_energia.h * * Energia core files for MSP430 * Copyright
  24. I am using a Launchpad 430 to program a custom board that uses an MSP430G2553IRHB32R chip from TI. I am doing this on a Windows 10 machine. Anyway, I have 2 problems. 1. I cannot upload my program onto the custom board because I get a 'Could not find device (or device not supported) (error=4)' error. 2. The MSP430G2553IRHB32R has 32 pins on it and the Launchpad has 20. I need to use all 32 pins. So, is there a tutorial somewhere that explains how to make alterations to energia to allow it to support custom boards and other chip pinouts? How do I get my new board to appear in the list of boards? The Boards Manager just lets me pick from some predefined packages. How do I add my own package? I've scoured the internet and found little bits and pieces about changing the Boards.txt file and the Pins_Energia.h file. However, these postings say things like "just add the appropriate pins to the pins_energia.h" or "add your board to the boards.txt file".. The problem is that I don't know how to do that. Can somebody please let me know in precise detail (catered to an energia newbie) in a step by step format how to do this? I love the simplicity of Energia, but when you're not coding directly on a Launchpad, it's really hard to figure out how to get things to work on it. Thanks so much for your assistance with this, Curtis
  25. I'm trying to use a Launchpad 430 to program a board that has an MSP430G2553IRHB32R. I am doing this on a Windows 10 machine. I've removed the jumpers on the Launchpad and connected VCC and Ground to the other board. I've also connected RST and TEST pins. I created a simple blinky sketch which runs just fine with a stand alone Launchpad 430. However, when I attempt to program my custom board with the same code, I get the following error. MSP430_GetNumberOfUsbIfs MSP430_GetNameOfUsbIf Found FET: HID0003:COM5 MSP430_Initialize: HID0003:COM5 Firmware version is 20409001 MSP430_VCC: 3000 mV MSP430_OpenDevice tilib: MSP430_OpenDevice: Could not find device (or device not supported) (error = 4) tilib: device initialization failed the selected serial port tilib: device initialization failed does not exist or your board is not connected I have selected the MSP-EXP430G2553LP board and COM5. I cannot seem to get it to program my other board. I've tried several different USB cables. Used 2 different computers and 2 different Launchpads. I even attempted to program a different custom board that I had been able to program before. I'm using the latest version 18 of energia. Can somebody point me in the right direction as to how to solve this problem and be able to program my custom board? After that, does anybody know what I need to do to get the board.txt and pins file set up to work correctly with my 32 pin MSP430G2553... chip? Thanks for the help, Curtis
×
×
  • Create New...