Jump to content

brainwash

Members
  • Content Count

    32
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by brainwash

  1. I don't know how relevant this is but TI has brought mspgcc support to their IDE: http://www.ti.com/tool/msp430-3p-gcc-mspgcc-tpde While it's still not a clean Eclipse installation it allows usage of GCC code and probably easy Energia integration. Also: http://e2e.ti.com/blogs_/b/msp430blog/archive/2013/12/09/you-beta-believe-it-gcc-and-ccsv6.aspx If an IDE is what you are looking for, GCC is now integrated in the recent BETA release of Code Composer Studio 6 as well. This means that if the size and speed and optimization support offered by the TI compiler are unnecessary for your application, you can choose to compile with GCC and use Code Composer Studio for free, without any code size limitation!
  2. brainwash

    RF bootloader

    I'm trying to build a home automation system and would like to be able to update the firmware on the nodes remotely via the NRF24L (SPI) module. Either that or go with an embedded scripted language but I don't know anything that would fit into an MSP430G (eLua, Python, TinyBasic) that's why I would rather go with the remote bootloader approach. Or are there any other ways to implement a simple scripted language? Something like: if (ADC(P1.4)>20) then (P1.5=1). I could always use a Stellaris and load everything into RAM but I'm trying to go with the lowest-end solution.
  3. See my posts starting with #9: http://forum.43oh.com/topic/3901-energia-framework-on-eclipse/ I want to make it into a standalone project template that can be imported in Eclipse and requires only project properties (env vars) to be set. CCS5 is actually Eclipse, just with some changes and limitations. For all intents and purposes Eclipse CDC is what you want.
  4. I'm in the process of building a dual lab power supply with and the Stellaris should provide monitoring and protection shutdown. I've ported the Adafruit LCD library to Energia LM4F (it should be easy to port to MSP430 as well) so I'm using that to display stuff in graphical format. The code below does a few tricks that might be useful for some of you: a rolling buffer to hold the data, automatic vertical scaling between the minimum and maximum values. As always, any kind of feedback is appreciated, I'm still a beginner. A picture is worth a thousand words. I only have 5 points of resolution in this picture but the vertical scale is actually 20 points.
  5. Since I haven't been able to find a library for the LCD 5110 that supports graphics as well I decided to port the arduino library. It turned out to be take much less time than I thought it would, considering my very limited C/C++ experience. Most of the time was spent rewriting the fast software SPI routine: inline void Adafruit_PCD8544::fastSPIwrite(uint8_t d) { for(uint8_t bit = 0x80; bit; bit >>= 1) { ROM_GPIOPinWrite(mosiport, mosipinmask, d&bit ? mosipinmask : 0); ROM_GPIOPinWrite(clkport, clkpinmask, clkpinmask); ROM_GPIOPinWrite(clkport, clkpinmask, 0); } } I haven't tested everything but the example (also included in the zip) works. There are still avr includes in the GFX libraries but it seems to work. Maybe someone can clean up and package a nice library. Adafruit_PCD8544.zip
  6. Win8 64bit I'm sure this has been discussed before but I cannot find the topic. One board I can program correctly with Energia or CCS, the other one I can only program through LMFlasher or CCS. Energia is saying something about PID:VID not found. I've tried everything that is humanely possible: uninstalling drivers, changing com port (com port works fine though), installing libusb and then changing back to stellaris icdi, using different usb port or hub. I'm sure there must be a way to delete some entry from the registry but otherwise I have absolutely no idea why one board works all the time with the lm4flash included with the arm-gcc and the other one never.
  7. Solved it (not really) by changing the pins. It seems that all the 10 or so configurations I've tried were wrong. With this pinout it works: Enrf24 radio(PE_1, PE_2, PE_3); // CE,PSN,IRQ One of these is the culprit: PB6 is also MISO(2) PD6 is also RX(2) PA3 is also CS(0) Maybe someone can explain to me what's wrong but I'm just glad this is over and when I get over it I will do some more testing to see what pins should not be used.
  8. I cannot get the module to talk reliably to Stellaris: En
  9. Outputting the display[] on serial shows this: " 32x7 . xC" where x is some strange character. Moving the display[] declaration inside the loop solves the problem showing the correct string " 32.5?C".
  10. The display[] array loses somehow the characters that are not updated. Instead of " 32.4*C" I get " 32". Uncommenting the lines at the bottom 'fixes' part of the stuff, but still something is displayed wrong (the comma symbol gets extra junk at the bottom). Setting the backlight variable to true at initialization time changes the display to " 32x4" where 'x' is some random junk character. Either I'm doing something wrong or the compiler has a bug. I suppose since most of this code is in the Energia repository (but only for 430) it should work.
  11. For debugging, you need to start mspdebug in gdb mode. On windows you can do this: mspdebug.exe tilib -j -d USB "gdb" The parameters for a debugging session: GDB Hardware debugging Standard GDB Hardware Debugging Launcher (not DSF) Command set: standard (windows), Protocol: mi That should be just about everything required. I don't know how to sync the source files with the binary, I get messages like "No source available for "analogRead() "" but I can see the stack just fine. Breakpoints also seem to work. Perhaps I'll try the same things using xpg's Eclipse plugin, it should take some tedium off the steps. I just haven't manage to get it working with Energia.
  12. I added the "hex" target to the included Makefile and also some small modifications. The "all" target also compiles the hex file. Added my name and a new version number there to avoid confusion with the original attachment. Window/Preferences search for "File Types" and add .ino as C++ source file. I added another environment variable called ENERGIADOSDIR=c:\Programs\energia-0101E0009. This is because Eclipse cannot recognize MinGW paths, AFAIK. Go to project properties, C/C++ General, Paths and symbols and add the following items: ${ENERGIADOSDIR}\hardware\msp430\variants\launchpad ${ENERGIADOSDIR}\hardware\msp430\cores\msp430\Arduino.h ${ENERGIADOSDIR}\hardware\msp430\cores\msp430\ Make sure your '.ino' files have the following include: #include <Energia.h> After these steps your autocomplete should work in Eclipse. I appended ....\energia-0101E0009\hardware\tools\msp430\mspdebug to the existing PATH variable, perhaps there is some way to do this better. This is needed in order for the "upload" target to work. The Makefile now treats Windows and *unix machines differently because at least on my machine the mspdebug is not listing any USB devices in its default configuration. Anyway it is recommended to use the 'tilib' option. Next stop would be debugging, if I'm able to figure it out. Sorry if I did some stupid things, I have zero programming experience with C++ and makefiles. Edit: I don't know why the stupid uploader won't let me upload almost any file extension. Security through obscurity. Makefile.txt
  13. Just a question, were you able to debug using the Launchpad as is or by a 3rd party tool (FET, ezMSP, ...)?
  14. I've started installing the tools and everything on Eclipse and Win8 and here's the initial guide for beginners like me: - install Eclipse Juno CDT or you can add the CDT/gcc/C++ stuff into your existing Java Eclipse (like I did) - install MingW and add it to the environment path (c:\MinGW\bin\). Required for make - [optional] create a new workspace (I used the existing one) and copy your old energia sketch folder into the workspace - find the energia.mk in a post above, copy it to your project folder, rename it to Makefile - run the eclipse wizard to create a new project from makefile and specify the project/sketch folder The "Problems" tab should show that gcc and g++ are not found. - rightclick on project properties, C/C++ build, Discovery options and rename gcc with msp430-gcc and g++ with msp430-g++ - on the environment tab append the ..energia\hardware\tools\msp430\bin\ folder to PATH; this is msp430, adjust for stellaris The "Problems" tab should not show zero errors now. Right click, project properties, C/C++ build, Environment: add the ENERGIADIR variable !VERY IMPORTANT! replace c:\ with /c/ and backslashes with slashes. It should point to your energia installation folder. Open the Make targets view and add "all", "boards" and "clean" targets while leaving everything in place. Double-click on "boards" and you should have the output in the console. make boards Available values for BOARD: lpmsp430g2231 LaunchPad w/ msp430g2231 (1MHz) lpmsp430g2231f LaunchPad w/ msp430g2231 (16MHz) lpmsp430g2452 LaunchPad w/ msp430g2452 (16MHz) lpmsp430g2553 LaunchPad w/ msp430g2553 (16MHz) lpmsp430fr5739 FraunchPad w/ msp430fr5739 Add the ENERGIABOARD env variable (e.g. lpmsp430g2231f) to the project. Do a clean build and then "all" and the project should compile to an .elf file. It's late and I don't have any more time today but the objcopy command is missing, it should compile to a .hex file. I haven't tried debugging and uploading, maybe someone can continue the 'tutorial'.
  15. I'm a little late to the party but I would venture to say that he did it this way because the article is a comparison on Arduino-style boards with Arduino code (check the sources). For Arduino Due and Maple board the SerialUSB configuration was used, as well as for LM4F120. AFAIK, for the Stellaris the Energia hardware serial implementation does not make use of advanced features. See hardware\lm4f\cores\lm4f\HardwareSerial.cpp. This is why I'm pushing towards Energia since it unifies all these different platforms and allows better collaboration and easy entry. Even though I like TIs toolchain I have the impression that for most hobbyists it's a moving target. If you buy a fairly popular module you can get try a sketch and maybe it will work in 5 minutes with minimal modifications or you might have to spend the time to look into the datasheet for both the uC and the module and write everything from scratch in a day/week. Sorry for ranting but this double effort always annoys me and I come from a PIC background (triple effort then, nothing like AVR or ARM).
  16. Hey, nice project, I was looking for a JTAG-capable project. Not to rain on your parade but it could probably be done as cubeberg mentioned with xmodem and TFTP and FTDI cable. I've yet to met a router that does not have that pins somewhere as they are heavily used even after the C-sample (production) boards are out but the firmware is not yet finished. The only issue is knowing how to exit the autoboot mode right at the beginning. Usually pressing ESC/enter/space/backspace a few times does the trick and puts you into firmware upload mode. This is not even limited to routers, it ranges from TV sets to car stereos and washing machines.
  17. Just thought I posted my long-time pending project - a replacement chip solution for the Senseo coffee pad machine. It's not 'in production' yet, will do so in the following days, just a bit nervous about playing with line voltages. The machine uses/used a capacitive divider instead of a small transformer, which means that most of the stuff is at line potential with reference to earth. Original voltage regulation is done by clamping 220V through a 5V zener. It has been thoroughly tested on the breadboard so it should work once installed. Hardware - mostly stock, I'm just putting in the MSP430 chip and a regulator. I kept the original board and removed the uC and EEPROM chips. - three buttons: power, 1 coffee, 2 coffees - the power button has a small red LED circle around it - heater controlled via an SCR - NTC thermistor inside the heater is sampled through a voltage divider. - water sensor is a hall type sensor that detects the floater position inside the water tank - water pump is controlled via a small transistor Operation: - while line voltage is on but the machine is powered off the user can enter service modes via button combinations - upon powering on the machine starts heating the water, displaying on the LED how hot the water is (PWM) - if the user requests a coffee, the machine changes is blinking pattern and starts making a coffee once the water is heated - if there is no water in the tank there is a faster blinking pattern - if no user input is detected for 30 minutes the machine goes to power off state - a lot of other safety stuff and under the hood stuff that you kind of expect to work Why? The original machine annoyed me (and my work mates) for various reasons: - once plugged in, it stayed off, so if you used a remote outlet you have to physically move yourself to power on the machine, making the remote outlet kind of useless - heating the water takes quite a lot of time (90s) and you cannot request a coffee in advance - that 90s seems like forever because you have no indication how far you are from the target temperature; the led just blinks and then settles to an ON state - if left unused for a while, the boiler temperature goes down quite a lot; this makes the next coffee colder than normal Things to do after real-world testing is complete: - the 2 coffee button is not implemented yet, not sure it is needed. Two presses of the other button achieve exactly the same thing and the water does not cool so much - LPM3/4. Probably not needed, but I will test initially with a separate battery supply. - water quantity calibration via a service mode. You should be able to increase/decrease the pump duration in 1 second increments via a service mode and the value saved in flash. The original chip did this - add a jumper or some kind of configuration mode where you can have the machine prepare a coffee once it's powered on, for remote controlled outlet usage If anyone needs more details I can provide them here; I will eventual make a dedicated blog post with tons of pictures and graphs about this. Strangely enough I cannot attach .ino files and the code tag seems broken. senseopad.ino.txt
  18. Just remember to add the line HWREG(TIMER0_BASE + TIMER_O_TAMR) |= (TIMER_TAMR_TAMRSU | TIMER_TAMR_TAPLO | TIMER_TAMR_TAILD); if you bump into problems. It is in the comments section of that blog post.
  19. Just a suggestion, perhaps Energia should also have a Code Vault. This is because most of the working code samples (like above) get lost in the myriad of questions that is on this sub-forum. Or maybe invent some kind of a rule like prefixing the thread titles with [Q], [ code], ... Edit: now that I think more, a nice code should be commited to Energia.
  20. Just as a suggestion for anyone else trying this, I've done the same project years ago using a 16F PIC, leds as light detectors and L293/SN754410 as motor driver. I think that's the most minimalistic setup you can have and it can mostly be done single-side. It relies on the fact that the LED capacitance decreases(?) with increasing light incidence. I will have to try some day to implement the same using the stellaris, the only hardware required would be the LEDs and of course the motor driver board, but with the power remaining in the board one would be able to do temperature, luminosity and power data logging as well.
  21. Very simple code to get the AD9850 [ebay] module up and running. I will use Energia whenever possible because it results in more portable code. /* Using the AD9850 DDS ebay module with Stellaris Launchpad. Code based on http://nr8o.dhlpilotcentral.com/?p=83 and https://gist.github.com/raivisr/3861473 PA2 - W_CLK PA3 - FQ_UD PA4 - DATA PB6 - RESET VCC - VCC (5V can also be used but will dissipate more heat) GND - GND Serial comms - 9600, NewLine (0x0A) denotes end of input, f 10000 - set frequency s 20 20000 10 1000 - sweep from frequency to frequency using this step size in that many milliseconds o 10 10000 5 3000 - oscillating sweep from frequency to frequency and back using this step size in that many ms */ #define MAXBUF 40 #define W_CLK PA_2 // Pin 8 - connect to AD9850 module word load clock pin (CLK) #define FQ_UD PA_3 // Pin 9 - connect to freq update pin (FQ) #define DATA PA_4 // Pin 10 - connect to serial data load pin (DATA) #define RESET PB_6 // Pin 11 - connect to reset pin (RST). #define pulseHigh(pin) {digitalWrite(pin, HIGH); digitalWrite(pin, LOW); } // transfers a byte, a bit at a time, LSB first to the 9850 via serial DATA line void tfr_byte(byte data) { for (int i=0; i<8; i++, data>>=1) { digitalWrite(DATA, data & 0x01); pulseHigh(W_CLK); //after each bit sent, CLK is pulsed high } } // frequency calc from datasheet page 8 = <sys clock> * <frequency tuning word>/2^32 void sendFrequency(double frequency) { int32_t freq = frequency * 4294967295/125000000; // note 125 MHz clock on 9850 for (int b=0; b<4; b++, freq>>=8) { tfr_byte(freq & 0xFF); } tfr_byte(0x000); // Final control byte, all 0 for 9850 chip pulseHigh(FQ_UD); // Done! Should see output } double freqValue = 0; double freqStart = 0; double freqEnd = 0; double freqStep = 0; int sweepDelay = 0; char freqStr[MAXBUF]; int bufPos = 0; char byteIn = 0; int mode = 0; void setup() { // configure arduino data pins for output pinMode(FQ_UD, OUTPUT); pinMode(W_CLK, OUTPUT); pinMode(DATA, OUTPUT); pinMode(RESET, OUTPUT); pulseHigh(RESET); pulseHigh(W_CLK); pulseHigh(FQ_UD); // this pulse enables serial mode - Datasheet page 12 figure 10 Serial.begin(9600); memset(freqStr,0,sizeof(freqStr)); sendFrequency(1e7); } void loop() { if (mode == 1 || mode == 2) { delay(sweepDelay); if (((freqStep > 0.0) && (freqValue + freqStep <= max(freqStart,freqEnd))) || ((freqStep < 0.0) && (freqValue + freqStep >= min(freqStart,freqEnd)))) freqValue += freqStep; else if (mode == 1) freqValue = freqStart; else { freqStep *= -1; freqValue += freqStep; } sendFrequency(freqValue); } while (Serial.available()) { byteIn = Serial.read(); if (bufPos < sizeof(freqStr)) freqStr[bufPos++] = byteIn; else { bufPos = 0; byteIn = 0; memset(freqStr,0,sizeof(freqStr)); Serial.println("Command too long. Ignored."); } } if (byteIn == 0x0a) { switch (freqStr[0]) { case 'f': mode = 0; freqValue = strtod(freqStr+2,NULL); freqEnd = 0; freqStep = 0; sweepDelay = 0; Serial.print("Frequency "); Serial.println(freqValue); break; case 's': case 'o': char *fEnd1, *fEnd2; freqStart = abs(strtod(freqStr+2,&fEnd1)); freqEnd = abs(strtod(fEnd1,&fEnd2)); freqStep = abs(strtod(fEnd2,&fEnd1)); if (freqStep == 0) { Serial.println("You gotta be kidding me, step can not be 0"); break; } sweepDelay = abs(atoi(fEnd1)); if (freqStr[0] == 's') { mode = 1; Serial.print("Sweep"); } else { mode = 2; Serial.print("Oscillate sweep"); } Serial.print(" start freq. "); Serial.print(freqStart); Serial.print(" end freq. "); Serial.print(freqEnd); Serial.print(" step "); Serial.print(freqStep); Serial.print(" time "); Serial.println(sweepDelay); sweepDelay /= abs(freqEnd - freqStart) / freqStep; if (mode == 2) sweepDelay /= 2; if (freqStart > freqEnd) freqStep *= -1; freqValue = freqStart; break; default: Serial.println("AI blown up - unknown command. Available commands:"); Serial.println(" f 10000 - set frequency"); Serial.println(" s 20 20000 10 1000 - sweep from frequency to frequency using this step size in that many milliseconds"); Serial.println(" o 10 10000 5 3000 - oscillating sweep from frequency to frequency and back using this step size in that many ms"); Serial.println(" frequency can be given in floating point format: 1.23456e7"); } memset(freqStr,0,sizeof(freqStr)); byteIn = 0; bufPos = 0; sendFrequency(freqValue); } }
  22. Just to get back on topic, is there any way to write "Energia" code within CCS? I've used Eclipse for the past 7 years or so and the Energia IDE seems very limited. I expect to be something like: set up the includes for the GCC (or cl430?) to point to the "energia/hardware/cores/msp430", the "variants/launchpad" folder and then setting up some board/cpu defines. I am not at all skilled at c/cpp so I don't know exactly where to look. The end purpose would be to have autocomplete and debugging activated within Eclipse, not just to use it as a basic notepad. I like the dumbed down version of arduino style programming because I don't have to worry about a lot of things and can do more projects quicker.
  23. Thank you. I didn't know it was supposed to be in a .cpp file. Now at least it compiles so if I find any runtime problems with CCS I will report them here. I only know Java well and a tiny bit of C, so this is a bit steep to me, but it's a much better abstraction than having to bit juggling, even if you manage abstract a lot of the math.
  24. Sorry to be such a noob, but I don't know how to get this to work: "C:/ti/ccsv5/tools/compiler/msp430_4.1.4/bin/cl430" -vmsp --abi=eabi -g --include_path="C:/ti/ccsv5/ccs_base/msp430/include" --include_path="C:/ti/ccsv5/tools/compiler/msp430_4.1.4/include" --advice:power=all --define=__MSP430G2553__ --diag_warning=225 --display_error_number --diag_wrap=off --printf_support=minimal --preproc_with_compile --preproc_dependency="blink.pp" "../blink.c" "..\gpio.h", line 80: error #78-D: this declaration has no storage class or type specifier "..\gpio.h", line 80: error #66: expected a ";" Line 80: template<uint8_t PINNUM> struct PORTINFO { static int const BASE_ADDR = PINNUM < 8 ? P1BASEADDR My code: #include <msp430.h> #include <stdint.h> #include "gpio.h" ........ GPIO<5> ASSY_MISPLACED_SW;
  25. I noticed that the function definition in gpio.c has an assert added in front of it, so I decided that for fast IO I needed to call HWREG directly. However, further digging showed up that ASSERT is macro in debug.h that's only enabled if the #DEBUG directive is set. Does anybody know if by default the directive is set? Perhaps when using the default debug build it is set? I cannot find this information anywhere. The reason is that I want to keep the code abstract enough (like stellarisware aims to do) without adding unnecessary hardware references. What's the impact on the IO speed of keeping the asserts on? I assume is the cycles burned for doing the actual assert, but I do not know exactly how it interferes with optimization. Is there any way to selectively disable asserts for certain operations? For example for GPIO and Timer operations I would like them to be OFF, but on for everything else. I do not see any way of doing this except overriding the functions in my code and using a custom debug precompiler statement there.
×
×
  • Create New...