Jump to content
Forum sending old emails Read more... ×


  • Content Count

  • Joined

  • Last visited

  • Days Won


Everything posted by Peabody

  1. In case it might be of use to someone, I've posted a Youtube video and created a Github repo dealing with an alternate way of multiplexing 7-segment displays that has a greatly reduced parts count. It's multiplexing by segment instead of by digit. The video shows this method implemented with an MSP430G2553. The Github repo has demonstration Arduino Nano sketches, but they should work as-is with Energia except for the pin assignments. The video is on my local OSH group's channel, and I can't respond to comments there, but will answer questions here if there are any. https://www.youtube.com/watch?v=8w09Zy8MQrc https://github.com/gbhug5a/7-Segment-Displays-Multiplex-by-Segment
  2. Peabody

    Multiplexing 7-segment displays by segment

    OK, so you don't use a timer-based PWM output, but vary the ON time in your code (NOPs or whatever) based on the number of segments being lit. And I assume the "worst case" is displaying an 8. Well that's pretty cool. And assembler is good for this kind of thing. I did all of my version in MSP430 assembler first, then moved it to Energia/Arduino to make it more accessible. What LVC part did you use?
  3. Peabody

    Multiplexing 7-segment displays by segment

    That's very interesting. Do you vary the PWM rate depending on the number of segments being lit up? And no resistors on the common cathodes?
  4. I've written a 7-segment refresh routine that runs every 2 millis at the beginning of loop(). It starts this way: void loop() { CURmillis = millis(); if ((CURmillis - PREVmillis) > 1) { // 2ms refresh period = 71 Hz per segment digitalWrite(18,HIGH); PREVmillis = CURmillis; // Turn the current segment OFF while making changes - prevents ghosting digitalWrite(SEGARRAY[SEGCOUNT], SEGOFF); The digitalWrite to pin 18 has been added so I can measure how long the refresh routine takes to run. Pin 18 is turned off as the last instruction in loop(). So the idea is to put my scope on pin 18, and see how much time the routine takes to run, and make sure there's no chance of an overrun. The good news is that the routine runs in about 25 uSec, so it will never overrun the next milli. But the bad news is that the scope shows that millis do not occur regularly. Pin 18 generally triggers the scope at 2 ms intervals, but there are occasional triggers at other points. I can't tell if the extra triggers are early or late, but they never go away. When I did this test on the assembler version of this code, with the Watchdog timer in interval mode, and the clock running at 1 MHz, the pin 18 triggers are absolutely regular. So Energia is doing something in the background that's causing this behavior. Of course it has to execute whatever is done to update the millis value, but I can't iimagine that this would take much time. But I guess there could be some "beat" in the interaction of the background millis interrupt and the loop() execution frequency. Is there any way to get rid of this millis flutter? Is it possible to hook into the interrupt that Energia uses for millis? If so, I could put my routine into the ISR, and loop() would be empty.
  5. Peabody

    Millis not regular on oscilloscope

    I just wanted to say that I think I found the answer to the non-regular millis, at least in the Arduino IDE, and I suspect it's the same in Energia. The interrupt that updates millis is actually a bit slower than 1ms. So periodically, the millis value is incremented by 2 so as to keep the average rate at exactly 1ms. Since my IF statement executes every other milli, it will execute after only 1ms when the millis count increments by 2. And that's why the scope showed the irregular trigger.
  6. Peabody

    Places we buy things...

    I'm in the US, and I've generally had good results with Banggood. Their products are pretty much the same as you would find on Ebay, but they appear to care about customer service, at least in my experience. The biggest issue for me has been shipping. On two occasions I've paid a higher price to get something from the US warehouse, thinking that shipping would be much faster. But that hasn't worked. The last time I ordered, the items from China arrived before the US items, which took 18 days via DHL. I've become a real non-fan of US domestic DHL. They are much slower than anyone else. I mean, 18 days. There's no excuse for that. I don't know what shipping and customs problems you will have in Canada. Maybe someone else can advise you on that. But with regard to the products, I would generally feel comfortable with Banggood. Of course it depends on how much you're going to spend.
  7. I'm working on a reflow controller with a G2553 driving a solid state relay to control power. It also includes a rotary encoder with push button and two 7-segment displays to adjust and display the duty cycle. I've written it in assembler, and all of the activity takes place within the interrupt service routine triggered every 2ms by the watchdog timer in interval timer mode. Between interrupts, the processor sleeps. In assembler, the service routine does its magic in about 0.1ms, or 1/20th of the total time, so there's no danger of an overrun into the next trigger. There are no pin interrupts because the encoder and push button are serviced by polling. I'm thinking about converting the software to Energia to make it more accessible to others, and possibly also to Arduino for the same reason. But I'm having trouble finding Energia or Arduino examples of setting up timer-based interrupts other than fiddling directly with the registers. If anyone can point me to information on any higher-level commands that implement timer interrupts, I would appreciate it. One other general question I have concerns pin interrupts. My understanding is that MSP430 parts can do rising or falling edge interrupts, but I've seen examples of people using "change" interrupts as are available on Atmel parts. Can someone explain how an on-change interrupt is actually implemented for MSP430 parts? Thanks very much.
  8. Peabody

    Converting MPS430 assembler code to Energia

    I have everything done that I need at this point. As the original post described, the assembler code did everything inside the interrupt service routine. I was looking for a way to do that in Energia, but using millis and the IF statement accomplishes the same thing. The only difference is that in assembler I was able to turn the processor off between interrupts, which saves some power, but probably not all that much since the oscillator is still running.
  9. This is my first attempt with Energia. Sorry to ask so many questions. I need to know what state the G2553 is left in after whatever Energia does to it automatically so I know what I need to do, such as: Does it set the top of the stack? Does it set the clock to 1 MHz? 8 MHz? Does it disable the watchdog function? Does it return P2.6 and P2.7 to GPIO use? Does it leave all port pins as inputs with PU resistors? Does it set up a timer to generate interrupts for millis()? Also, where can I find this kind of information? I didn't have any luck searching for it here, or on the .nu site. Thanks
  10. Peabody

    How does Energia intialize a G2553?

    What I've found is that it turns off Watchdog, sets the stack pointer to the top of ram, sets the clock to 16 MHz, and restores P2.6 and P2.7 to GPIO use if there's no crystal on those pins. Couldn't find anything else on the ports beyond their normal boot state. Also couldn't find the timer thing, but it must set that up to be able to do millis.
  11. It appears that the Arduino IDE can be run as a portable app by downloading the ZIP version, extracting it, then adding a folder called "Portable". Then it appears it will leave the registry alone. Is it the same for Energia?
  12. Peabody

    Is Energia a portable installation on Windows?

    It turns out that the portable "installation" is implemented in Energia as it is in Arduino, at least on Windows. You download the ZIP file, extract it, add the "Portable" folder, and then it stores all your ino's there and pretty much leaves the registry alone.
  13. Peabody

    Converting MPS430 assembler code to Energia

    Aside from the interrupt on change issue, I haven't found any way to set up a timer interrupt in Energia other than fiddling with the registers. But as it turned out, all I had to do was put the entire loop() code in an IF statement that tests whether the required number of millis had passed. So basically it just does that test over and over, but only executes the code every 2ms. In assembler, I put the processor to sleep between interrupts, but haven't found a way to do that in Energia. Anyway, I've finished porting the assembler code into an Energia .ino, and it works fine. The hex file is about twice as large as the assembler version, which is actually less than I expected.
  14. Peabody

    Converting MPS430 assembler code to Energia

    Thanks for the code, but I'm not any good at C, and have no idea what that does. Anyway, I think I will not attempt to use an interrupt on CHANGE.
  15. Peabody

    Converting MPS430 assembler code to Energia

    I wouldn't know how to find it. In any case, your code compiled ok, and ran ok, with the on CHANGE interrupt? Well, it's a mystery.
  16. Peabody

    Converting MPS430 assembler code to Energia

    I found this code for a rotary encoder providing fine and coarse adjusment: https://forum.43oh.com/topic/9306-energia-library-rotary-encoder-with-coarse-fine-adustment/?tab=comments#comment-70635 Included in the .ino file on Github is the following: ---------------------------------------------------------- void setup() { Serial.begin (115200); pinMode(buttonPin, INPUT_PULLUP); pinMode(encoderPin1, INPUT_PULLUP); pinMode(encoderPin2, INPUT_PULLUP); attachInterrupt(encoderPin1, ISR_Encoder1, CHANGE); // interrupt for encoderPin1 attachInterrupt(encoderPin2, ISR_Encoder2, CHANGE); // interrupt for encoderPin2 attachInterrupt(buttonPin, ISR_Button, FALLING); // interrupt for encoder button ------------------------------------ And I'm having trouble understanding the "CHANGE" interrupts. My understanding is that MSP430 I/O pins don't have a "change" interrrupt. What am I missing here?
  17. I don't know if this has any application for Energia, but might be of use to someone at some point. I've been working on a way to embed a generic USB-to-UART adapter like the CP2102, FT232 or CH340 in an MSP340 project so firmware can be updated without having to buy a Launchpad. The newer MSP430 parts presented a problem because BSL-Scripter, TI's software for BSL flashing for those parts, doesn't transmit the special invoke pattern on /Reset and Test. Instead, it just brings both lines low, which messes things up. I gave up on trying to recompile Scripter, but I've written a Windows program that generates the pattern, and developed methods to disconnect DTR from /Reset after the pattern has invoked BSL, but before BSL-Scripter is run, which allows flashing to proceed with /Reset high. A full explanation, source code, executable, and schematic are in my Github repo. It all seems to work, at least with an FR2311 under Windows 7. https://github.com/gbhug5a/CP2102-with-BSL-Scripter-for-MSP430
  18. Thanks. That's a really great repo. 🙂 But it's all BSLDEMO , and I need to do the same thing with BSL Scripter.
  19. I'm on a mission from God to permit updating firmware on F5xx, F6xx, FRxx, etc. using TI's BSL-Scripter software and a generic USB-to-Serial adapter like the CP2102, which could be embedded in a project. As things stand, Scripter requires either a "Rocket" programming device or an MSP-FET because it is those devices which actually generate the pattern on /Reset and TEST that invokes BSL on the target device. I've written a short program that produces the special pattern on DTR and RTS of a CP2102, but when I run Scripter immediately thereafter, it brings both of those lines low and keeps them there. Of course that puts the target device into /Reset, so not much is gonna get flashed that way. I need to modify Scripter to add a MODE line or command line option called "INVOKE", which if present would cause Scripter to generate the required pattern on DTR and RTS itself, and leave them in the correct state. before doing whatever else it's going to do. The source code is available, but it's way over my head. It requires the Microsoft 2013 Visual C++ complier, and a bunch of third party stuff, including something called Boost. I have none of that, and don't know how I would modify the code. I did it for BSLDEMO, but that was plain C, with no third party stuff. So I wondered if anyone here had ever gotten Scripter to compile from the TI source, and if so, if he would like to compile a version for me (assuming I can figure out what to change). The only code I can find that deals with DTR and RTS in the source is in TestReset.h, but I don't understand it.
  20. I've added a second PDF file describing an efficient polling routine for servicing multiple momentary push-button switches.
  21. I worked on a new servicing routine for my kit oscilloscope's quadrature rotary encoder, and decided to write it all up and post it on Github. Included are routines for periodic polling and for pin-interrupt servicing. Hardware switch debouncing is not needed. The routines are for general use, but I wrote testing code for the MSP430G2231 installed on the Launchpad. The scope guys have used the "lookup table" state transition routine that most people use today, but it doesn't work very well on the scope, and I haven't found it to work very well generally. My routines are designed to avoid all effects of switch bouncing, and seem to work very well and efficiently. Everything is explained in the PDF file in the repo. All the testing code is also included, both source code and executable hex files, and I'm afraid it's all in assembler. But I hope it wouldn't be too difficult to create Energia versions if anyone is interested. I've provided hex files for both types of encoders - those with the same number of pulses as detents per revolution, and those with half as many pulses as detents. The code produces one "tick" per detent in both cases. https://github.com/gbhug5a/Rotary-Encoder-Servicing-Routines
  22. Peabody

    simple asm code example in energia?

    Can I ask a related question? Recently I posted here about an alternate G2553 BSL entry mechanism that I had developed and posted on Github. This involves a very short code segment buried in INFOA in between the calibration data blocks. There are two requirements for it to work. The first is that the Reset vector at 0xFFFE must point to 0x10C0, which is where the boot entry code resides at the beginning of INFOA. The second is that the firmware which will be running on the chip after flashing must begin at 0xC000, which is the beginning of MAIN memory. The code in INFOA tests whether USB is connected, and if not it BRanches to 0xC000. So the application must begin there, and it must be an instruction, not .dw stuff. This is easy in assembler, but it has occurred to me that the two requirements might not be easy, or even possible, to satisfy in plain C or in Energia, about which I know very little. What do you think?
  23. I originally posted about this in October, but wanted to report that I've updated the G2553 special BSL entry code to fix a bug. Everything is included in my Github repository: https://github.com/gbhug5a/MSP430-BSL To review, this project deals with the MSP430G Value Line processors, and was prompted by the idea of embedding a CP2102 USB-to-Serial adapter in a project's circuit rather than hooking one up through a pin header, or using the Launchpad for JTAG flashing. So all you would need to flash new firmware is a USB cable and the right software. A detailed description of what's involved is in the long-winded PDF file. The PDF deals with the much-despised BSL password in the G2553 ROM-based BSL, and offers a couple ways around it, including special boot code that fits entirely in the INFOA segment along with the existing calibration data, and lets you run BSL with INFOA protected from erasure, which means you can flash new firmware without knowing the password, and without erasing the calibration data. There's also a complete custom BSL system for the lowly G2231, which has no built-in BSL. Included are installers for the chip and the PC software to drive the process. And there's a discussion of circuit design for using embedded adapters or modules containing them. The installers for the chips use the Naken assembler, and the PC software uses the LCC compiler. But the repo includes both the source code and the executables for everything, so assembler-phobes can just flash the hex files. There are two small bonuses - a VBScript for Windows that converts an IntelHex file to TI-TXT format, and as part of the BSL installation for the G2231, the calibration values for 8, 12 and 16 MHz are derived from the existing 1 MHz calibration value, with no crystal required, and saved in the usual places in INFOA (based on original work by Steve Gibson). I did the original work on this for a project, and decided I might as well write it up in case it might be useful to others at some point. The Value Line processors are kinda old school now, but are still available in DIP, and are still pretty popular. And the circuit design portion may be more generally useful. Of course I'd like to know about any bugs or errors anyone may find. Hope this will be useful.
  24. Last summer I worked on the idea of embedding a USB-to-Serial adapter in Value Line projects so firmware revisions could be done with only a USB cable and the right software, without needing a Launchpad. The adapter chips and modules containing them are now so inexpensive that this makes sense. On the chance that it might be useful to someone, I've written it all up and posted it to Github: https://github.com/gbhug5a/MSP430-BSL The project is summarized in the README, and explained in detail, with needed software and hardware, in the PDF.
  25. Peabody

    GPS logger for a local Beagle club

    Greeeg, I think that chip has a BSL built in. I'm curious whether you considered using that. Of course the built in BSL would need a PC master (the Scripter program?) to drive it, and I understand your bootloader only needs an SD card plugged in. But the built in version has the big advantage of having everything already done for you. Anyway, your version looks very interesting.