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.

Convert from C++ to VB6

Other Parts Discussed in Thread: MSP-GANG

Hi,

After successfully running sample code for MSPGANG programmer, CPP_Interactive_MSP_DLL, I tried to convert the sample code in VB6, however, I found same DLL working in the sample code but could not work properly in VB6.

Issue 1:

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

The function could not return any error description.

Issue 2:

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

After call the function : lPRGSValue = MSPGANG_Interactive_Open_Target_Device("Demo"), I got error number 23, on MSPGANG programmer user guide page 41, it says:

ERROR # 023 - MCU device init.

So I tracked back the function used to initialise the MCU:

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

lPRGSValue = MSPGANG_Set_MCU_Name(strDeviceType)

Where strDeviceType is declared as string with 23 character length : Dim strDeviceType As String * 23

The data format passed for strDeviceType  is exactly the same as data passed in the sample code:

Data passed in VB:

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

Declaration in sample code:

LONG WINAPI MSPGANG_Interactive_Open_Target_Device( LPTSTR name );

Data passed in sample code:

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

 

It seems to me that, I could have issue to convert the C++ to VB6 when LPTSTR is passed or returned. Did I miss anything? Can anybody help to solve these issues as we have very limit timeframe on this? Thank you.

Regards,

Lisa

  • I don't know anything about MSP-GANG.  But I might be able to shed some light.

    So the product comes with a library of routines you can call for programming flash.  You have built the C++ examples that come with that library, and they work fine.  Am I correct so far?  Why do you think it is possible to call the functions in this library with Visual Basic code?

    Thanks and regards,

    -George

  • Hi George,

    The C++ sample code comes from TI, as we are still using VB6 as development platform, therefore I'm trying to convert the code in VB6 to utilise our existing function\ns.

     

    Hope this can be solved quickly. Thank you.

     

    Regards,

    Lisa

  • The MSP-GANG manual says nothing about Visual Basic.  Thus, it is very unlikely that you can use Visual Basic with the functions in the associated library.  

    If you want, I can try to find the group which releases that library and ask them.  But I'm very confident you will get the same answer.

    Thanks and regards,

    -George

  • Hi George,

     

    It would be good if you can pass the question to the group who releases the library. As:

    1. I think the DLL works like a bridge between the MCU and custom user application, thus, it should not be language limited.

    2. I'm able to use some functions defined in that DLL, please refer to my another post for more details : RE: MSPGANG DLL(http://e2e.ti.com/support/microcontrollers/msp430/f/166/p/292857/1026113.aspx#1026113)

    3. We are using pros430 DLL for over 10 years for our test jig, now we change to MSPGANG because diff MCU is selected, and we would like to modify our jig, so we can launch our product quickly.

    Hope to hearing from you soon.

    Thank you.

     

    Regards,

    Lisa

  • Perhaps this Microsoft article would be helpful:

    How To Write C DLLs and Call Them from Visual Basic

  • Hi Archaeologist,

    Do you mean that I cannot use the MSP-Gang.Dll provided directly for VB, but have to use C++ to wrap and create another DLL for VB application? Instead of digging down more and more which is really time consuming, I think TI should provide  a DLL which can be easily used by all end users.  I'm not a C++ guru, can you give bit more specific hints on this?

    Thank you.

    Regards,

    Lisa

     

  • Hi,

    Finally found out, problem happened because of this statement:

    MSPGANG_SetConfig(gcCFG_TARGET_EN_INDEX, 1) Where gcCFG_TARGET_EN_INDEX=10

    However, doesn't matter what target I specified (I changed it from 1 to 255), target 5 is always  the only one nominated,  so I can only program for target number 5.

    So I proved that the MSP-Gang.dll can be used by VB6 directly, but there are some bugs:

    Problem1: MSPGANG_GetErrorString returns nothing

    Problem 2: MSPGANG_SetConfig can only enable target #5

    Can anybody help on these issues, as we would like to utilise all 8 target provided to speed up productivity?

     

    Thank you.

     

    Regards,

    Lisa

  • Lisa Qian said:
    It would be good if you can pass the question to the group who releases the library.

    Unfortunately, I don't know who that is.  But I have begun the process of finding them.  I expect it will take a few days.

    Lisa Qian said:
    I think the DLL works like a bridge between the MCU and custom user application, thus, it should not be language limited.

    Is it technically possible for Visual Basic to calls functions in a DLL that is implemented in C?  I suspect it is.  But I suggest you should be more concerned about whether this particular library is tested for use by Visual Basic.  I strongly suspect it is not.

    Thanks and regards,

    -George

  • Hi George,

    As an end user, what we expect from TI is to get tools and apply it to our product easily and quickly, hope we can have good news from you soon.

     

    Thank you.

     

    Regards,

    Lisa

  • Hi George,

    Here is bit more feedback on what we found for MSP-Gang.dll:

    1. MSPGANG_SetConfig doesn't work properly.

    By using function MSPGANG_Default_Config, we could have JTAG, Vcc, etc set correctly, but we cannot use function MSPGANG_SetConfig to change settings, for example, when we call MSPGANG_SetConfig (10,1) to change target, and data got from MSPGANG_GetConfig(10) is 1633620, doesn't matter what value we pass to Index 10, data got is the same, which means bit5 is set all the time, hence, we can only program target #5. Similarly,  when we try to set the VCC level (index 7) , data got is always = 3600.

    2. Data doesn't describe in user guide (SLAU358D, what does that mean?

    After using function  MSPGANG_Default_Config, we use function MSPGANG_GetConfig(index) to read each setting:

    MSPGANG_GetConfig(43) = 5 ( UART Speed)

    3. Index doesn't describe in user guide (SLAU358D, but in sample code, what does that mean?

    sample

    CPP_Interactive_MSP_DLL

    code

    #define   CFG_TMP_CUMULATIVE_ST_EN  28

               // 0   - disable

               // 1   - enable     ( default )

    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");

    In the User Guide,  CFG_TMP_CUMULATIVE_ST_EN is up to 26 (page 87), and why do we need it before openinng the target?

    Hope it helps.

    Thank you.

     

    Regards,

    Lisa

     

  • Dear Lisa,

    Can you please clarify if you are now compiling "SetConfig" in C++ or still using VB?

    Thanks, Carlo.

  • Hi Carlo,

     

    VB is the language we used for all our jigs. So we are waiting for reply from TI before modifying our jig.

     

    Regards,

    Lisa

  • Hi Lisa,

    we don't test the MSP-GANG DLL with Visual Basic. Theoretically, it should work, it is nothing else as using the C++ DLL out of Visual Basic. There are a lot of examples in Web.

    How to use the functionality of the DLL - you can see C or C++ examples, which are installed "Examples"-folder.

    One thing could make easy life for you: using the GANG430.DLL. This is wrapper-dll for the MSP-GANG.dll, which has the API from older GANG430. We have made it for the compatibility. It can not control the whole functionality of MSP-GANG, but probably could be good enough for you. If you have used it before with GANG430, you can try to use it now. Please refer to chapter 4.1 of the UG slau358 and Wrapper examples.

    Please let me know if it helps.

    Regards,
    Rosty