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.

MSP-GANG: Issues with creating a c# app to program devices

Part Number: MSP-GANG
Other Parts Discussed in Thread: MSP430F67771,

I have a device that requires a specific order of steps to properly program and I'm attempting to automate the process. I'm having trouble getting the board to program using the commands listed in MSP Gang Programmer User's Guide.

I have a text file that we upload and then write to device. I'm able to get this to work when using the app downloaded from TI's website. When I attempt to run the c# example it crashes saying it cannot load the dll. Also looking through the code I don't see how to program the board. 

Currently I'm running the following commands

  1. MSPGANG_API.InitCom("COM66", 115200); 
  2. MSPGANG_API.Default_Config();
  3. MSPGANG_API.Set_MCU_Name("MSP430F67771");
  4. MSPGANG_API.Interactive_Open_Target_Device("MSP430F67771")
  5. MSPGANG_API.SetConfig(ConfigIndexes.CFG_TARGET_EN_INDEX, 0x01); // Trying with only one device connected to the first connector.
  6. MSPGANG_API.Read_Code_File(filePath);
  7. MSPGANG_API.MainProcess(1000);
  8. MSPGANG_API.Interactive_Close_Target_Device();

All steps above return a status of 0 but the firmware does get loaded onto the device. 

Here's a screencap of the TI app after a successful run.

  • Hello Dave,

    To clarify, your C# implementation doesn't seem to be behaving properly, but the FW you try to load does indeed get loaded into the device?

    Also from a high level, what steps are you trying to accomplish our steps you need to do that putted you down the path of utilizing the DL? If this is just a simple application of automating a specific programming order, have you considered the scripting option for the MSP-GANG instead? Its described in www.ti.com/lit/slau358 

  • Hi Dave,

    Did you try the demo in C# located in 

       C:\Program Files (x86)\Texas Instruments\MSP-GANG\Examples\C#-MSP-DLL

    You should run first software in GUI, make it working then save configuration file as... Use that configuration file with your dll.
    Let me know if you have any questions.

    Regards,
    Gregory Czajkowski
    Elprotronic Inc.
    gregory@elprotronic.com

  • I attempted to run that program via VS Debugger and get it crashes when I click the Load or Start button. It can't load the DLL. Message copied below.

    System.DllNotFoundException: 'Unable to load DLL 'MSP-GANG.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)'

  • Basically I want to mimic what happens when you click the "Go" button the TI's Gang Programmer app (screen shot of it included in my first post). Unfortunately I won't be able to use the scripting option since I need to communicate with a 3rd device which will power cycle the device being programmed. 

  • Hi Dave,

    We are going to look into this, but it may take a couple days for us to reproduce/debug.

    My initial impression is that this is a build issue or a runtime issue with the DLL path that is preventing your application from finding the DLL.

    As I dig into this I may post back questions for you or things for you to try.

    Regards,

    Evan

  • Hi Dave,

    Quick update here: I'm actually able to reproduce the "DLL missing issue" in the example project included with mspgang. I'll have to dig into it some more, but I'm hopeful it should be an simple fix because I expect the example project to work.

    I'll keep looking into it and get back to you.

    Regards,

    Evan

  • Hi Dave,

    I haven't been able to find the root cause here, but I noticed that if I run the .exe in bin/Debug directly it works. Can you try this?

    Regards,

    Evan

  • Also, what version of visual studio are you using?

  • I was able to run it from the debug folder but I'm getting error when trying to connect. I changed Demo.ComPort to the correct value (eg: "COM66") and made sure no other software was using the connection. Text from the app below

    MSPGANG_InitCom              ERROR 310: Open Comm port - invalid handle value
    MSPGANG_CreateGangImage        Operation successful.
    MSPGANG_EraseImage           ERROR 306: Timeout during operation - Correct COM port selected?

    My VS is VS Professional 2019, v16.9.2

    Thanks

  • Ok interesting, can you confirm that you can connect using the GUI?

    Evan

  • Dave,

    I also wanted to ask what your overall system requirements are. MSP-GANG has other automation options which may allow you to do what you need without using directly interfacing with the DLL.

    Evan

  • Yes I'm able to connect with the GUI

    My goal is to automate the programming process. This would require taking a hex file and flashing it onto the device using the GANG programmer. I have a working c# app that interacts with MSP-FET Hardware programming tool | TI.com (using the MSP Flasher v1.3.20 CLI, see screen shot below) but this can only program one device at a time. We would like to speed up the process using the GANG programmer. I have no objections to using similar CLI commands if they exist. 

    Using the built-in scripting is not an option since our device has to be power cycle multiple times during the programming process which requires a third party device. 

  • Hi Dave, 

    Thanks for sharing the context. I looked to see if we have any other options for running MSP-GANG without the gui, but other than the .dll I couldn't find any. Given that you already have a C# program, I think the best option is to try to reuse.

    So as of now we have a couple problems:

    1) Can't connect to the MSPGANG even when correct com port is specified.

    2) When debugging the program is having issues loading the DLL.

    It would be nice to be able to use the debugger, but for now I think let's work on 2). Unfortunately, I don't have a GANG device with me, so I may have to pull in some more team members. Give that's it's holiday week, it may take some time. 

    Can you detail a bit more about what you tried regarding the "invalid handle" error? The comm port you are using is COM66. Does this imply that there are a lot of devices connected to this workstation? You said that you close the MSPGANG gui when running your program but are they other programs actively using serial ports on this workstation?

    Regards,

    Evan

  • Hi Dave,

     We provide demo with C# and MSP DLL. You should get it from location

     C:\Program Files (x86)\Texas Instruments\MSP-GANG\Examples\C#-MSP-DLL

     when install the MSP-GANG software package.

     Best regards,
    Gregory Czajkowski
    Elprotronic Inc.

  • I'll be out for the holiday too so I probably won't be able to try anything else until next week. 

    I only had GANG programmer and a mouse connected via USB (it was my laptop). The high COM number is due to some other devices that I work on frequently don't properly clear out the com port which leads to numbers getting higher and higher. 

    When I tried this no other programs were connected to the COM port. 

  • Also, are you using the demo project or your own? I think we should make sure we can use the demo project, before we port the code over to your project.

**Attention** This is a public forum