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.

MSPGANG DLL

Other Parts Discussed in Thread: MSP-GANG, MSP430F5325

Hi,

I'm using VB6 to write test routine utilised MSPGANG DLL, and got some questions:

code:

lPRGSValue = MSPGANG_Read_Code_File(strProgFile)    

 If lPRGSValue = 0 Then        

strMsg = strMsg & "Reading of code file was successful." & vbCrLf & vbCrLf    

 Else      

strMsg & "Reading of code file failed. Code file is : " & vbCrLf & strProgFile & vbCrLf & "Error code is " & lPRGSValue & " : " & MSPGANG_GetErrorString(lPRGSValue) & vbCrLf & vbCrLf    

End If

But I got error code of   355, also, MSPGANG_GetErrorString could not return relevant error description. Can anybody help? Thank you.

  strMsg =

 

 

  • Hi Lisa,

    Looking in the MSP-GANG user's guide on p. 42, Error #355 is listed as "open file error". The code was unable to open the file that you tried to pass to it.

    Are you sure that the file path is 100% correct? When I have used the MSP-GANG DLL before, I usually was using a relative path from where the executable was running to where the file was stored. For example, in the example C application that comes with the MSP-GANG software package, you can see that it points to the file in the lib folder in the nearby directory by using this "..\\lib\\test_1k.txt" as the file name. But you also need to make sure that the file is present at that location.

    One other thing I noticed that may cause an issue (though this is a guess) - it looks like your file path has a space in the file name. Could you try renaming the file to something without a space in it (maybe put an underscore instead) and see if your issue goes away? Sometimes software does not handle spaces in file names - though I have not tested it in this case.

    Regards,

    Katie

  • Hi Katie,

     

    Thanks for the reply. I changed the code file path, and it works.

    But then I encountered another problem, here is the code:

    lPRGSValue = MSPGANG_Interactive_Close_Target_Device()        

    lPRGSValue = MSPGANG_SetTmpGANG_Config(gcCFG_TMP_CUMULATIVE_ST_EN, 0)          'gcCFG_TMP_CUMULATIVE_ST_EN=28  

    If lPRGSValue = 0 Then        

         strMsg = "SetTmpGANG_Config  was successful" & vbCrLf & vbCrLf    

    Else

         strMsg = "SetTmpGANG_Config failed." & vbCrLf & "Error code is " & lPRGSValue & " : " & MSPGANG_GetErrorString(lPRGSValue) & vbCrLf & vbCrLf    

    End If        

    lPRGSValue = MSPGANG_Interactive_Open_Target_Device("Demo")    

    If lPRGSValue = 0 Then

            strMsg = strMsg & "Opening of target device Demo  was successful" & vbCrLf & vbCrLf    

    Else  

            strMsg = strMsg & "Opening of target device Demo failed." & vbCrLf & "Error code is " & lPRGSValue & " : " & MSPGANG_GetErrorString(lPRGSValue) & vbCrLf & vbCrLf    

    End If

    I've checked the MCU name  which is correct, and target device is 1. Can you help on this? Thank you.

  • Hi,

    As stating in prev post, When calling function of Interactive_Open_Target_Device , I still got error of 23. I'm not sure if it caused by improper used of MSPGANG_Set_MCU_Name, The declaration is:

    Declare Function MSPGANG_Set_MCU_Name Lib "C:\MSPGANG\MSP-Gang.dll" (ByVal S As String) As Long

    Here is how to call it:

    lPRGSValue = MSPGANG_Set_MCU_Name(strDeviceType)

     Where:

    Dim strDeviceType As String * 23,

    Data assigned to strDeviceType is :
    Bit   Char   Asc(Char)

    0       M       77

    1       S       83

    2       P       80

    3       4       52

    4       3       51

    5       0       48

    6       F       70

    7       5       53

    8       3       51

    9       2       50

    10      5       53

    11              32

    12              32

    13              32

    14              32

    15              32

    16              32

    17              32

    18              32

    19              32

    20              0

    21              0

    22              0

    Can anybody help on problem of error 23 when opening the target device. We need this to be solved urgently.

    Thank you.

     

     

  • Hi Lisa,

    Are you basing your code off of the MSP-GANG DLL examples? Have you made sure that the configuration is all set up to be correct for your hardware setup (JTAG vs. SBW, Vcc supplied by programmer or externally, etc) and checked all of your connections with your MSP430 target? What connections have you made to the target device (in hardware)? Do you have problems connecting to the target when using the MSP-GANG GUI (will tell us if DLL issue, or if it is your hardware)?

    Error #23 is MCU device initialization, which means that the MSP-GANG is having a problem trying to communicate with your MSP430, which is why I suspect a configuration or hardware error. You may want to post your full DLL code so we can see your configuration.

    Finally, it looked like you passed the value 28 when calling the SetTmpConfig command. I only see values up to 26 defined in the user's guide. What was this line of code supposed to do (what were you trying to configure?)

    Regards,

    Katie

  • Hi Katie,

    I tried the sample code of CPP_Interactive_MSP_DLL, and it is working with my unit, I'm able to open target and program my unit,  MSP-GANG GUI is working too, so hardware is not an issue.

     

    Sample code from CPP_Interactive_MSP_DLL (void CDLLtestDlg::OnBnClickedOpenTarget() in Interactive-demo-Dlg.cpp)

    status = MSPGANG_Interactive_Close_Target_Device();   //close if was open

    MSPGANG_SetTmpGANG_Config( CFG_TMP_CUMULATIVE_ST_EN, 0 );   //must be just before MSPGANG_Interactive_Open_Target_Device(..)

    status = MSPGANG_Interactive_Open_Target_Device("Demo");

    And in MSP-GANG.h,

    #define   CFG_TMP_CUMULATIVE_ST_EN  28    // 0   - disable    // 1 - enable ( default )

     

    I'm not sure why value 28 is used, but just trying to convert the C++ to our VB6 test program. Code in VB6:

    lPRGSValue = MSPGANG_InitCom(strPort, lSpeed)     'lSpeed=115200

    Code for button Set Config which is pressed before opening target:

    lPRGSValue = MSPGANG_Default_Config()

    Call MSPGANG_SetConfig(gcCFG_PROJECT_SOURCE, 0)                 ' Interactive Mode    

    Call MSPGANG_SetConfig(gcCFG_COPY_CFG_FROM_MEMORY_EN, 0)        ' Direct    

    Call MSPGANG_SetConfig(gcCFG_USE_SCRIPT_FILE, 0)                ' disable script file (default)

    lPRGSValue = MSPGANG_Set_MCU_Name(strDeviceType)

    lPRGSValue = MSPGANG_SetConfig(gcCFG_VCCINDEX, lVol)         'lVol = 3300

    lPRGSValue = MSPGANG_SetConfig(gcCFG_TARGET_EN_INDEX, 1)

    lPRGSValue = MSPGANG_Read_Code_File(strProgFile)

    Code for button Open Target

    lPRGSValue = MSPGANG_Interactive_Close_Target_Device()

    lPRGSValue = MSPGANG_SetTmpGANG_Config(gcCFG_TMP_CUMULATIVE_ST_EN, 0)

    lPRGSValue = MSPGANG_Interactive_Open_Target_Device("Demo")

    By executing above statements sequentially, once the  last statement is executed, error 23 comes.

    Also, from my previous post, you could see that I tried to catch error description by calling function of MSPGANG_GetErrorString(lPRGSValue), and nothing returned.

     Thanks for help, and hope to hearing from you soon..

    Regards.

    Lisa

  • Hi Lisa,

    To debug this if I were you, what I would probably do would be to go into the Set Config button code that you have, and add in the commands that you have left out from the example (since the example is known to work). Then see if this causes open target device to now work. If it does work, then you can start commenting out commands until you find out what makes it break.

    I think that one crucial command that it looks like you left out for set config is setting the Vcc settle time. But as I said, I'd probably start from the known good configuration and then start modifying only one thing at a time and checking if your code still works at each step. This will help you find where it is going wrong.

    Regards,

    Katie

  • Hi Katie,

     

    Even I set the VCC settle time (same as defined in sample, 10), I still got the same error code.

     

    As you point out, error 23 means that MCU Device Init.

    Declaration: Declare Function MSPGANG_Set_MCU_Name Lib "C:\MSPGANG\MSP-Gang.dll" (ByVal S As String) As Long

    I checked the data passed in above function in sample code which is exactly the same as data sent in my VB6 program:

    0x005aa094 "MSP430F5325         "

        [0]: 77 'M'

        [1]: 83 'S'

        [2]: 80 'P'

        [3]: 52 '4'

        [4]: 51 '3'

        [5]: 48 '0'

        [6]: 70 'F'

        [7]: 53 '5'

        [8]: 51 '3'

        [9]: 50 '2'

        [10]: 53 '5'

        [11]: 32 ' '

        [12]: 32 ' '

        [13]: 32 ' '

        [14]: 32 ' '

        [15]: 32 ' '

        [16]: 32 ' '

        [17]: 32 ' '

        [18]: 32 ' '

        [19]: 32 ' '

        [20]: 0

        [21]: 0

        [22]: 0

     

    What I found is, the issue to convert the C++ to VB6 could be happened when LPTSTR is passed or returned, as mentioned before, I could not get any return for function MSPGANG_GetErrorString:

    Declare Function MSPGANG_GetErrorString Lib "C:\MSPGANG\MSP-Gang.dll" (ByVal errCode As Long) As String

     

    One more thing is, we need to get this solved quickly, but it takes too long to solve problem via forum, as when I post the question, it takes several hours to approve, then it could be another day  or days for the answer back, is it possible to speed up the reply.

     

    Thank you.

     

    Regards,

    Lisa

     

  • Hi Lisa,

    I understand what you are saying now - you suspect that the issue is with the MCU Device name and the way that strings are handled in C++ vs. VB6. Unfortunately, VB6 is not an area of expertise for me, so I'm not really the best person to help with this. I can definitely help with MSP-GANG questions, but it looks like this has turned into a C++/VB6 code porting issue.

    I think you will need to go to some programming forums on this subject and do some searching about porting strings and code between C++ and VB6 to find the answer for this. Sorry to not be greater help in this instance.

    Regards,

    Katie