This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Looking for means to transfer data from PC to ucontroller

Other Parts Discussed in Thread: LAUNCHXL-RM42, RM42L432

Hi fellow Launchpaders

For my application I need data, stored in an array to control the Hercules ucontroller, to be present at power up (or upon receiving a specific hardware interrupt event). To accomplish this I am presently changing (often multiple times daily) the firmware of the Hercules ucontroller by assigning new values to the control variable array and then recompiling the code and flashing it to the ucontroller. I would like to avoid having to flash the code to the ucontroller so frequently since the flash banks eventually wear out. Instead I would like to have the ucontroller read the data for the array assignment stored on a PC. I guess this could be done using the UART but I have not done that sort of thing yet. Any other possible solutions or suggestions? Are there code examples or utilities available for doing this sort of data transfer over the UART.

Dan

  • To accomplish the task of reading new data into my control array at power-up could I use the USB host controller of the Hercules Launchpad to read data from a USB flash drive in which the data always exists in the same place on the flash drive? I know so little about this presently.
  • Hi Dan,

    Which Hercules MCU launchpad are you working with?

    Regards,
    Sunil
  • Sunil

    RM42x
  • Dan,

    On the RM46x, RM48x and RM57x MCUs, you have an additional option of using the Parameter Overlay Module (POM). This allows you to overlay an area of flash memory with an internal/external RAM. All read accesses to these flash memory locations (e.g. constants that you are tuning) are re-routed to the overlayed RAM region. Then you can even use the debugger to update these constants in the RAM without actually stopping the code execution and without having to reprogam the flash memory.

    Unfortunately the RM42 MCUs do not include this POM feature.

    Regards,
    Sunil
  • With respect to my original question of sending the contents of a file to the microcontroller: Is there a way to do this over the UART. So I would write to the microcontroller (not sure how to do this) and read a character at a time with the UART receiver (I have experimented with this)?
  • Dan S17 said:
    Any other possible solutions or suggestions?

    GUI Composer allows you to create a GUI to control variables on the target.

    With CCS 6.1 was able to use GUI Composer to change a variable on a program running on a LAUNCHXL-RM42 when JTAG was used to change the variable on the target - although had to pause the running program to allow GUI Composer to change the variables as couldn't get the LAUNCHXL-RM42 to work with "Continuous Refresh".

  • Hi Chester

    Thanks for that information. Is GUI Composer only in CCS 6.1? I am running 6.0.1.

    How do you pause the running program on the ucon?

    Do you think that I could change the contents of a array of structs on the target using this method?

    Daniel
  • . Is GUI Composer only in CCS 6.1? I am running 6.0.1.

    GUI composer is available in CCS 6.0.1.

    How do you pause the running program on the ucon?

    Press the "Suspend" button    on the debug tool bar.

    [I found some CCS training which said on Hercules devices that CCS is supposed to be able to access memory over JTAG while the target CPU continues to run - so raised a query on the CCS forum about having to pause the target to access memory. See https://e2e.ti.com/support/development_tools/code_composer_studio/f/81/t/413892 ]

    Do you think that I could change the contents of a array of structs on the target using this method?

    http://processors.wiki.ti.com/index.php/GUI_Composer/Bind_Expressions says that GUI composer can bind to structures. 

  • Hi Chester

    Is there a way in which I could use GUI Composer to assign values to an array of 200 ints on the target? The values of the array elements would be stored in a file on the host PC.

    Dan

  • Dan S17 said:
    Is there a way in which I could use GUI Composer to assign values to an array of 200 ints on the target? The values of the array elements would be stored in a file on the host PC.

    I had a look at the GUI Composer documentation, and couldn't see any example which did that. However, GUI composer allows javascript to be used so may be possible to add file handling code.

    Given that you only want to assign values from the contents of a file, using GEL_MemoryLoad() or the Load Memory Wizard. from CCS to load a block of memory from a file might be simpler. CCS supports loading memory from binary or text file formats. See the "Saving and Loading Memory Data Files" topic in CCS help for details.

  • Hi Chester

    Thanks for the tip. When using the Load Memory Wizard am I given a pointer to or an address for the location of the memory which would contain my array? To use this feature am I ultimately reflashing data to EEPROM rather than placing it in ucontroller RAM? I am asking this question because I am trying to find a way to read data into an array stored in the ucontroller RAM so that I don't wear out the EEPROM by repeatedly erasing and writing to flash memory.


    Daniel

  • Hi Dan,

    Sorry to interrupt what seems like a really good discussion.

    But if your main concern is wearing out the part on your launchpad, for practical purposes I wouldn't worry about this.

    You are very observant to note that the write/erase cycles in the datasheet for the flash are pretty low if you compare them
    to a consumer flash - but if you read the details these are specs for 15 years of data retention and operation across the temperature range -40 to 125C. And if you can use the small data flash - which is designed for EEPROM emulation - we spec this at an even higher # of cycles.

    So I wouldn't spend a lot of time / effort on this if your only concern is to get your development project(s) done without wearing out the part.

    If on the other hand you are designing your system so that it cycles the flash like this then you'd have valid concerns.

    If you want to keep a data table in RAM but have it's default values in Flash (so you power up, during initialization the code copies data from storage in flash to RAM, and then at runtime your code is linked to use the RAM values) then the linker supports this. Search through the linker documentation for copy tables and the difference between 'load address' (which would be flash) and 'run address' which would be RAM. The compiler even includes a runtime support library function that will take the linker generated copy table and move it to RAM for you (just need to call it) so it's pretty easy to do this nowadays...

    If you were going to get really fancy - and I don't believe the part on the TMS5704 launchpad has this capability - so just mentioning as an FYI - we have something called "POM" on the higher end parts - like the LS3137. This is designed so that in hardware it can 'remap' a parameter table from flash to SRAM, where you can use a tool like the DMM port (unfortunately the tools for this are $$) which can modify the on-chip SRAM without using JTAG and without halting the running processor.
  • When using the Load Memory Wizard am I given a pointer to or an address for the location of the memory which would contain my array?

    On the first screen of the Load Memory dialogue you can specify the file to load the data from and the file type:

    If you untick the "Use the file header information to set the start address and size of the memory block to be loaded", on the second page of the Load Memory dialogue you can enter the start address, either as an address in hexadecimal or as the name of variable. An array named "global_array" in RAM in this example:

    So, yes you can specify the address (or name) of the memory which contains the array.

    To use this feature am I ultimately reflashing data to EEPROM rather than placing it in ucontroller RAM

    The Load Memory dialogue performs direct writes, starting from the requested Start Address. and thus the target address must be in RAM.

    [E.g. I tried getting the Load Memory dialogue to write to Hercules flash which simply didn't change the flash - since the Load Memory dialogue doesn't know how to perform writes to non-volatile memory.]

  • Thanks again Chester!

    I will give that a try. Do I have to pause the code on the microcontroller, using the pause button in CCS, and then use the Load Memory gui?
  • Dan S17 said:
    Do I have to pause the code on the microcontroller, using the pause button in CCS, and then use the Load Memory gui?

    Yes

  • Thanks again Chester

    Is there a Load Memory routine and a pause routine that I could call instead of using the Load Memory and CCS GUI?

    Dan
  • Is there a Load Memory routine and a pause routine that I could call instead of using the Load Memory and CCS GUI?

    You can use GEL to combine pausing, loading and running. E.g. the following was added to a GEL file for the LAUNCHXL-RM42:

    menuitem "Data Data"
    
    hotmenu Pause_Load_And_Run()
    {
    	int is_halted;
    	unsigned int original_delay;
    	unsigned int changed_delay;
    	
    	is_halted = GEL_IsHalted ();
    	
    	if (!is_halted)
    	{
    		GEL_Halt ();
    	}
    	
    	original_delay = delay;
    	GEL_MemoryLoad (&delay, 0, 1, "/home/Mr_Halfword/workspace_v6_1/RM42_GUI_composer/delay_data.dat");
    	changed_delay = delay;
    	
    	GEL_TextOut ("delay changed from %d to %d\n",,,,, original_delay, changed_delay);
    	
    	if (!is_halted)
    	{
    		GEL_Run ();
    	}
    }

    This adds a command to CCS under Scripts -> Data Data -> Pause_Load_And_Run which:

    a) Pauses the target if already running.

    b) Uses GEL_MemoryLoad to set the contents of the delay variable on the target from a file.

    c) Displays the value of the delay variable before and after the memory load so you can check the memory load worked.

    d) Sets the target running if was running.

    I copied the <ccs_install_directory/ccsv6/ccs_base/emulation/gel/rm42l432.gel GEL file into the project directory, added the above code and then changed the Target Configuration to use the modified rm42l432.gel GEL file for the CortexR4: