Jump to content


  • Content Count

  • Joined

  • Last visited

  • Days Won


Posts posted by mgh

  1. Does anyone know if MSP432 (black) can be added to the standard Arduino setup?

    The reason: I've got an Adafruit Feather M0+ board working with Arduino, so the ARM Cortex-M compiler is "already there". I'm hoping maybe I could remove Energia (since I don't need the '430 support). If I add the JSON board file for the black MSP432 launch-pad, will the Arduino IDE get everything it needs to play with the MSP432?     https://energia.nu/packages/package_msp432_black_index.json

    Also, is there a JSON file for the Tiva TM4C123 launch-pad?  (same reason, have a Tiva, want to move everything over to one IDE).


  2. I just installed Energia 1.8.7E21 on macos 10.12.6.

    From the Finder, the Energia version number is a little goofy.
    It shows "${version}" instead of the actual text.

    This is seen in the "Info.plist" file, and can be fixed there.





  3. I don't know that any of these ideas will help, it's just what I looked at when I tried to see what the problem might be.

    When you first start the Boards Manager, do you see the message "Downloading platforms index..."?  It gets the small file http://www.energia.nu/pacakges/package_index.json .  If you can see that, then it's talking to the package server OK. I've got a slow dial-up connection, so it sits there long enough for me to read it (and wait a little, too!). If you have a fast connection then it might blip past in an instant.

    It's interesting that it wants to get a 1.0.2 release, when there's a 1.0.3 release up on the site.

    Have you made any changes in Preferences / Network? If so, could they be blocking something?

  4. Quote

    So now I am wondering, what is your data backup process? How do you ensure your data is not lost in the worst case scenario?

    Mac OS X: TimeMachine and SuperDuper!.

    Every few days I plug in the external USB drive, and TimeMachine does its thing (backing up the files that changed). When that's done, I use SuperDuper! to make an image backup to a different partition on that same external drive. Once a month I plug in a different external drive (a WD My Passport Ultra) and clone the main drive to one of three partitions on the external - it's round-robin so I've got three monthly snapshots, plus TimeMachine, plus the other backup. I also have an old FireWire drive that gets an occasional copy of the main drive.

    I should store them in different locations, but they're all in the same room.

    For your case, I think TimeMachine could have helped, especially if, unlike my setup, you let it backup to a drive that's always connected - you would have had all the versions at your fingertips.

    One more tip: always, always verify that the backups are good -- boot from them if they're supposed to be bootable. This is something that I'm lazy at, and I know one of these days it's going to bite me.

  5. I have TivaWare SW-EK-TM4C123GXL- unpacked on my system.

    I know there are more recent versions.
    It includes a 'doc' directory with many PDFs, like SW-TM4C-EXAMPLES-UG-
    which is the TivaWare Examples User Guide.
    The examples themselves are under "examples/peripherals/"
    There are many sample projects under the "examples/boards/ek-tm4c123gxl" directory, too.
    It takes awhile to get used to where everything is and how it works, but it's not difficult.
  6. It shouldn't be too hard to tweak the TivaWare isqrt.c to use a 'word' instead of a 'long' - change the types to uint16_t, run the loop 8 times instead of 16, shift by 14 instead of 30 (I think that's right). As always, write a test program on the host to prove the algorithm before it goes onto the micro.

    Also, the third C example on this page might help: http://www.codecodex.com/wiki/Calculate_an_integer_square_root
    You'll pick the uint16 settings.
    Finally, a google search of "Integer Square Roots Jack Crenshaw" turns up lots of pages... some of which suggest that converting to float, using the FP, and converting back can be faster than the loops in these approximations. I haven't measured with the Tiva, so I don't know if this is true. Seems like it might... three instructions + the FP sqrt time? (you mentioned Stellaris, so I'm guessing Cortex M4F processor).
    Well, here's my attempt at my first comment - the TivaWare isqrt for 16bits instead of 32.
     *	16-bit integer square root
     *	derived from TivaWare isqrt.c
    unsigned short isqrt(unsigned short value)
        int i;
        unsigned short rem, root;
        rem  = 0;
        root = 0;
        // loop over the eight bits in the root
        for ( i = 0; i < 8; i++ ) {
            // shift the root up by one bit
            root <<= 1;
            // move next two bits from the input into the remainder
            rem = ((rem << 2) + (value >> 14));
            value <<= 2;
            // test root is (2n + 1)
            if ( root <= rem ) {
                // root not more than the remainder, so the new bit is one
                rem -= root;
            } else {
                // root is greater than the remainder, so the new bit is zero
        return (root >> 1);
    #ifdef TEST
    #include <stdio.h>
    #include <stdlib.h>
    int main(int ac, char *av[])
    	int i;
    	unsigned short n, r;
    	for ( i = 1; i < ac; i++ ) {
    		n = strtoul(av[i], NULL, 0);
    		r = isqrt(n);
    		printf("%-8s %8d %8d\n", av[i], n, r);
    	return 0;

    And the output of a test run:

    $ ./iq 10 20 30 40 50 60 70 80 90 100 1024 2048 4096 8192 16384 32768
    10             10        3
    20             20        4
    30             30        5
    40             40        6
    50             50        7
    60             60        7
    70             70        8
    80             80        8
    90             90        9
    100           100       10
    1024         1024       32
    2048         2048       45
    4096         4096       64
    8192         8192       90
    16384       16384      128
    32768       32768      181

    Have fun!


    [Edit 1/1/2017 to fix incorrect comment in the code. Tsk!]

  7. You have separate routines:

      void tfr_bfobyte(byte data) 
      void tfr_byte(byte data) 

    And sendFrequency() calls tfr_byte(), but sendBfo() also calls tfr_byte() at one place.

    I don't know if that's a problem or not.  My apologies for the noise if I'm off-base.
    (Sometimes I have to print the code out on paper and spread it out in front of me, to see what's actually going on.)
  8. I'm late to this party, but here's two other suggestions:


    Ika-logic has a 4-channel semi-kit for 39 euros:

    Mattair-Tech has a multi-tool for 23USD:
     No affiliation with either company, but I do have a very nice ATxmega128a3u board from MattairTech, and I wish I had the ScanaLogic device.
  9. I'd be tempted to call the Energia Serial.setup() (or whatever), and then adjust the hardware registers for stop-bits and parity behind its back.  Dirty, I know.


    There is an option to enable logging of the full build process ("Show verbose output during..."), so you should be able to find the Makefile and library locations from that.


    All the compilers and tools you need are included with Energia - that build log will show you the paths. 


    Hmmm, interesting.  LM4F has "HardwareSerial" files, but MSP432 has nothing.


    Edit: 05jul2016 - 

    Arduino has "Serial.begin(speed, config)" where config is like SERIAL_8N1.

    Maybe this has been added to the latest Energia beta?


  10. The errors are pretty much what they say they are - 

      sinewave.cpp.elf section `.bss' will not fit in region `ram' - something is too big to fit in RAM.

      region `ram' overflowed by 1114 bytes - and that is how much it is too big.


    This is your bits array:

    int  bits[100][8]={};

    How much space does that take up?  One 'int' is maybe 32-bits (yes?), so that's 4 bytes for one entry. Multiply by 800, to get 3200 bytes total. Find out what processor you are using and look-up how much RAM it actually has.  Maybe only 2K?


    EDIT: I forgot to tell you how to fix this! SImply change the type from 'int' to 'char' or 'byte'. Instead of storing a single bit in a 32-bit value, we'll store it in a 8-bit value. This is still quite wasteful, but that should reduce the memory usage by a factor of 4. 


    Also, there might be a problem in the three tests like this one:

     else if((sina[i]/16) > 1/2)

    That "1/2" is converted to "0" by the compiler. It is not a floating-point computation.


    Also, aren't all of your "sina[]" tests basically the same thing? I haven't thought deeply about this, but it seems to me that if "X/2 > 4", then "X/4 > 2" will also hold, and the same with "X/8 >1", and so on down the line.


    Finally, you say that 'sina' is a number from 0 to 8.  OK, then dividing by anything bigger than 8 will give you zero. This is integer arithmetic, not floating-point.


    PS: the code that creates "sina" and builds "bits" can be moved out of "loop" and into "setup". You don't even need the "sin" array, actually.


    Good luck!

  11. (I had an answer here which I thought was helpful, but I was mistaken, so ...

    I'll look around to see how to delete my comment.

    Sorry for messing up your topic.)


    In the meantime, this is the driverlib routine, which suggests you're doing the right thing.

    void WDT_A_holdTimer(void)
        //Set Hold bit
        uint8_t newWDTStatus = (WDT_A->rCTL.r | WDTHOLD);
        WDT_A->rCTL.r = WDTPW + newWDTStatus;
  12. Here's my two cents, might be worthless for you, since I'm on a Mac.


    I see a difference right here:




    Which one is real?  'username' or 'raul' ? Or was it just an edit for posting to protect the innocent?

    Or did you build from source instead of getting a binary?


    Personally, I think it looks strange that it got installed in 'src', instead of a "Programs"-type directory, but I've been away from Linux for awhile.


    I get this output, which looks like what you're getting, so that's good. (Ignore the different paths.)


    [/users/user/Apps/Energia.app/Contents/Resources/Java/hardware/tools/lm4f/bin/arm-none-eabi-g++, -c, -Os, -w, -fno-rtti, -fno-exceptions, -ffunction-sections, -fdata-sections, -mthumb, -mcpu=cortex-m4, -mfloat-abi=hard, -mfpu=fpv4-sp-d16, -fsingle-precision-constant, -DF_CPU=80000000L, -MMD, -DARDUINO=101, -DENERGIA=16, -I/Users/user/Apps/Energia.app/Contents/Resources/Java/hardware/lm4f/cores/lm4f, -I/Users/user/Apps/Energia.app/Contents/Resources/Java/hardware/lm4f/variants/stellarpad, /var/folders/pd/_29pt21s5y32d0l6tw4xkd1m0000gp/T/build6473424579527578532.tmp/BareMinimum.cpp, -o, /var/folders/pd/_29pt21s5y32d0l6tw4xkd1m0000gp/T/build6473424579527578532.tmp/BareMinimum.cpp.o]
    As for your second question: it's just compiling the sketch. Arduino hides a lot of stuff from us.
  13. I'm not sure which items you mean when you say "... but the displayed items are way too small".

    The Energia preferences lets you set the editor font and size.

    On the preferences panel it also shows you the location of the preferences text file preferences.txt.

    In there are settings for the font, the default window size and position, and some colors (I hate the bright red).

    For example:




    On OS X, it looks like the application icons are under Energia.app/Contents/Resources/Java/lib/theme
    and settings for the GUI fonts and colors are in the file Energia.app/Contents/Resources/Java/lib/theme/theme.txt
    I'm not sure where it will be on Windows.
    (And yay! now I can tone down that bright red!)
  14. I'm not sure I can help, but I'll give it a try.

    First, that link was for the Intel 8051, a 8-bit microprocessor from the 1980s. Some general notions of interrupts applied, but I found it pretty confusing since none of the details concerned us.
    Have you loaded the TM4C "pack" for Keil's product?  Just checking. There's bound to be some relevant files under there.
    I found some interesting pages on Keil's site. When you do a search, there's an 'advanced' search option. Using that, I searched under the ARM products only, for 'cortex interrupt' and some likely articles turned up.
    Here's one for the ADC on the STM32F : http://www.keil.com/support/man/docs/gsac/gsac_adc.htm
    Not exactly what we wanted, but it shows the things we'll have to do, since it's basically the same core with different peripherals.
    And maybe bookmark this, it looks very useful for using their IDE: http://www.keil.com/support/man/docs/gsac/gsac_intro.htm
    If you haven't already, install TI's Tivaware package - or at least unpack it; it has many examples for you under SW-EK-TM4C123GXL-
    TI has some good support videos and documents over here:  http://www.ti.com/TM4C123G-Launchpad-Workshop
    There's a video specifically for interrupts; and see pages 4-7, 4-17, 4-18 of the TM4C123G_LaunchPad_Workshop_Workbook.pdf
    Again, it's not a perfect match, since it uses TI's CCS instead of Keil's uVision.  Oh, well, I'm using gcc on OS X, so they're both foreign to me.
    An interrupt is just the hardware making a subroutine call for us, behind our backs, unexpectedly. The interrupt handler has to be careful not to trash any variables that other parts of our code might be using. And, other parts of our code might have to be careful not to assume they know the values of the data that the interrupt routine touched.
    I don't think you have to play with the priority register at first. Just get a plain interrupt happening; later tweak the priorities if you need to.
    All we do is:
    - set the bits in the ADC registers to allow interrupts
    - define a interrupt handler
    - put the name of the interrupt handler in the startup code
    I'm guessing that cstartup_M.c file was for the 8051. In the Tivawave examples, the file is startup_rvmdk.S for the Keil compiler.  Just find the line that has 'ADC1 Sequence 3' and replace 'IntDefaultHander' with the name of your ADC1 sequence 3 handler.
    ;; startup_rvmdk.S - Startup code for use with Keil's uVision.
    DCD     IntDefaultHandler           ; ADC1 Sequence 3
    replace with
    DCD     ADC1Seq3handler ; ADC1 Sequence 3
    After all that, here's my contribution. It measures the internal temperature sensor on ADC0 sequencer 3 at about 1KHz, and prints the temperature to the debug UART port about every two seconds. For some reason I clocked everything slowly and used delays so that we can watch it easier on a scope. I'm not sure that makes any sense now.
    It uses the Tivaware functions, so if you're using direct register access, it won't map directly to your needs.
    I hope this helps. Good luck!
     *	adci.c
     *	adc with interrupt to measure temp
     *	$Id:$
     *	NOTE! add ADC0handler to startup_gcc.c (or whatever your IDE uses)
     *		void ADC0handler(void);		// declare it
     *		...
     *		ADC0handler,			// ADC Sequence 3
     *	LED indicators
     *	  red    PF1  triggered conversion, waiting for conversion to finish
     *	  blue   PF2  inside ADC interuppt handler, reading conversion data
     *	  green  PF3  got conversion
     *	To make things take longer, to maybe see better on a scope,
     *	both the processor and ADC run from from slower clocks,
     *	and the ADC uses hardware averaging.
     *	The repetition rate of the loop is about 775Hz.
     *	It waits about 137 usec for a conversion complete.
     *	The ADC interrupt routine takes about 9.5 usec.
     *	About every two seconds the loop prints a line to UART0
     *		$08dc 2268    10 C   50 F
     *	Warm up (or cool off) your thumb, and hold against the chip,
     *	to see the temperature change.
    #include <stdbool.h>
    #include <stdint.h>
    #include "inc/tm4c123gh6pm.h"
    #include "inc/hw_memmap.h"
    #include "driverlib/adc.h"
    #include "driverlib/gpio.h"
    #include "driverlib/interrupt.h"
    #include "driverlib/pin_map.h"
    #include "driverlib/rom.h"
    #include "driverlib/sysctl.h"
    #include "driverlib/uart.h"
    #include "utils/uartstdio.h"
    // define the peripheral/port/pins for the LEDs 
    #define LED_RED		GPIO_PIN_1
    #define LED_GREEN	GPIO_PIN_3
    #define LED_BLUE	GPIO_PIN_2
    #define	LED_SET(X)	ROM_GPIOPinWrite(LED_PORT, LEDS, (X));
    // this array must be big enough to hold the channels we convert
    // (only need one entry for this example)
    uint32_t rawtemp[4];
    // this flag is set by the interrupt routine, and read by the wait loop
    volatile uint32_t newtemp;
    // this is the interrupt routine for the ADC
    void ADC0handler(void)
    	// clear the interrupt flag, grab the data, set the 'done' flag
    	ROM_ADCIntClear(ADC0_BASE, 3);
    	ROM_ADCSequenceDataGet(ADC0_BASE, 3, rawtemp);
    	newtemp = 1;
    void InitADC(void)
    	// enable ADC0
    	// set a slower conversion rate
    	// use sequencer 3 (single sample), with manual trigger
    	// seq 3, step 0, temperature-sensor, interrupt-enable, last-conversion
    	// enable sequencer 3
    	ROM_ADCHardwareOversampleConfigure(ADC0_BASE, 16); // 64 32 16 8 4 2
    	ROM_ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_PROCESSOR, 0);
    	ROM_ADCSequenceStepConfigure(ADC0_BASE, 3, 0, 
    	ROM_ADCSequenceEnable(ADC0_BASE, 3);
    	// make sure interrupt flag is clear
    	// enable the interrupt for the module and for the sequence
    	ROM_ADCIntClear(ADC0_BASE, 3);
    	ROM_ADCIntEnable(ADC0_BASE, 3);
    void InitConsole(void)
    	// enable the port that has UART0 pins
    	// configure the RX/TX port pins
    	// enable the uart, set the clock, set the pins
    	// set baud-rate
    	UARTStdioConfig(0, 115200, 16000000);
    int main(void)
    	uint32_t i, tempC, tempF;
    	// clock at 8 MHz from the crystal
    	UARTprintf("\n\nADC internal temperature sensor\n");
    	// allow interrupts
    	i = 0;
    	while ( 1 ) {
    		// clear the flag, show we're waiting
    		newtemp = 0;
    		// start a conversion
    		ROM_ADCProcessorTrigger(ADC0_BASE, 3);
    		// spin and wait for the interrupt handler to get the data
    		while ( newtemp == 0 ) {
    			__asm ("WFE\n	");
    		// print temps about every two seconds
    		if ( ++i == 2000 ) {
    			i = 0;
    			tempC = (1475 - ((2475 * rawtemp[0])) / 4096)/10;
    			tempF = ((tempC * 9) + 160) / 5;
    			UARTprintf("$%04x %4d   %3d C  %3d F\n", 
    				rawtemp[0], rawtemp[0], tempC, tempF);
    		// delay to slow down the loop to something around 1KHz
  15. The language that you write Energia applications in is C++.  This is why the Keil C complier is complaining -- it doesn't know the 'class' keyword of C++.  If Keil has a C++ compiler, and you have some time to bring the Energia support libraries over to the Keil environment, then it could work...  just my two cents...


    Maybe the booster pack vendor has some examples in plain C code?

    Good luck!

  16. It's a great little board, isn't it!  :-)


    In the little flyer that came with the board, on the spread that shows the header pin functions, you'll find that PD0 and PB6 are connected together. Similarly, PD1 and PB7 are also connected together. It's my understanding that this was done for backward compatibility with the older 43oh booster boards (or something like that). So, we can't drive both pins of those pairs at the same time.


    The user guide for the board is spmu296.pdf, full title "Tiva C Series TM4C123G LaunchPad Evaluation Board User's Guide".

    The schematic is in the back, and shows those pins connected together.


    Valvano's site has a video showing the removal of the two zero-ohm resistors; it was easy to do.

    This is his video link page:  http://users.ece.utexas.edu/%7Evalvano/Volume1/E-Book/VideoLinks.htm

    Here's one link http://youtu.be/MWIX7wgS9PM

    And the other: https://s3.amazonaws.com/edx-course-videos/ut-embedsys/UTXUT601T114-G018400_100.mp4


    Have fun!

  • Create New...