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

Peabody

Members
  • Content Count

    26
  • Joined

  • Last visited

  • Days Won

    8

Peabody last won the day on February 4 2018

Peabody had the most liked content!

About Peabody

  • Rank
    Member

Recent Profile Visitors

561 profile views
  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. 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.
  7. 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
  8. 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?
  9. 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.
  10. 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?
  11. 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.
  12. 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
  13. Thanks. That's a really great repo. 🙂 But it's all BSLDEMO , and I need to do the same thing with BSL Scripter.
  14. 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.
  15. I've added a second PDF file describing an efficient polling routine for servicing multiple momentary push-button switches.
×