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.

PMSM code to be moved to flash

Other Parts Discussed in Thread: CONTROLSUITE, DRV8301

Hi,

I want to flash PMSM code available in the controlsuit (Path C:\ti\controlSUITE\development_kits\DRV830x-HC-C2-KIT_v105).  The processor used is F28035. 

Is there any standard procedure.  Could anyone share the same.

thx

KVRao

  • Hi,

    Did you check under Right click your Project -> Build configuration -> Set Active
    If you can't find flash configuration I'll help you out with the procedure to do so.

    Regards,
    Gautam
  • Thanks Gautham. 

    The flash configuration is not available in the Project -> Build configuration -> Set Active.  Could you please help me with the code or procedure.

    thx

    KVRao

  • Hi KVRao,

    Please have a look at this thread: e2e.ti.com/.../527385

    Try the steps outlined in my answer on this post and let me know if you are successful or not

    Sean
  • Thanks Gautham for your support.

    I downloaded the docs and gone over them but looks like my understanding is poor. I followed the following steps
    1) Created a New configuration DRV8301_F2803x_FLASH with settings copied from existing configuration DRV8301_F2803x_RAM.
    2) -w linker option invoked
    3) Large memory model enabled
    4) Non_DSP/BIOS project i.e., DSP2803x_headers_nonBIOS.cmd

    Added the following files
    DSP2803x_CodeStartBranch.asm
    DSP2803x_CSMPasswords.asm
    DSP2803x_PieCtrl.c
    DSP2803x_Sysvect.c
    f28035.cmd

    With above changes I am unable to built the code. Get the following errors.

    gmake:***[DSP2803x_PieVect.obj]Error 1
    gmake:***[DSP2803x_SysCtrl.obj]Error1
    gmake:***[PM_sosnsorless.obj]Error1
    gmake: Target 'all'not remade because of errors
    identifier:HRCAP1_INT_ISR" is
    identifier"HRCAP2_INT_ISR" is
    struct "SYS_CTRL_REGS"has no field

    Could you please review and suggest.
    thx
  • Hi Gautham and sean.  Could you please suggest.

    thx

  • Hi K.V.,

    Do you have Verbose Diagnostics enabled? That may help give me more insight into the error CCS is throwing at you

    Please check here: File -> Properties -> Build -> C2000 Compiler -> Advanced Options -> Diagnostic Options -> Verbose Diagnostics checkbox

    If this is not enabled, please enable and recompile. We should be able to get more info on your problem then. Post the error messages here

    Sean

  • Dear Mr.Sean,

    Thanks for your guidance.  I have enabled the verbose diagnostics and please find below the errors while building the PMSM code.

    What I did is took the example_28035_flash.pjt file and added the necessary PMSM files as shown.  Please review and suggest.

    thx

    kvrao

  • Kvrao,

    This looks like an issue with CCS locating the C source files for some of the files included in your project. Have you correctly linked in DRV8301_SPI.c, PM_Sensorless.c and PM_Sensorless-DevInit_F2803x.c?

    You can check the link setting by doing the following:

    Right click on the project name, i.e Example_28035_Flash, then select Properties from the drop down box

    Expand the Resource section, and select Linked Resources

    Select the Linked Resources tab at the top of the resultant page

    This tab shows all of the linked source files included in your CCS project. Please check the location of the three C source files I mentioned above, as they are causing a compiler/linker issue. Are the locations resolvable? If you linked the locations via a variable (i.e. "PROJECT_LOC" or something similar), is the variable address correct?

    Please try to correctly point your CCS project to the three problematic source files and report back

    Sean

  • Dear Sean,

    Thanks for your inputs resolved the linked file issues.  

    Could build the code successfully.  However still facing errors as in the attached image.  Please review and suggest.

    thx & rgds

    KVRao

  • KVRao,


    It appears that you did not include any attached image in your last post. Please try again so I can review the image.


    Sean

  • Sean,

    Oops please find enclosed the same.

    Thx

  • Mr.Sean /Mr.Gautham,
    could you please suggest.
    thx
  • KVRao,

    Usually an error for "symbol '_InitFlash' redefined: ..." means that the function InitFlash() has been instantiated two or more times within your source code. Please check if InitFlash() and PieVectTableInit() functions have two declarations within your code. I believe this can also happen if you have conflicting header file includes, two of which declare InitFlash(). The compiler will throw an error for the same function declared twice.

    As for the unresolved symbol error, you are trying to call a function (DLOG_4CH_init, DLOG_4CH_update) that the compiler cannot find. Is the source file linked correctly? Is the header file included correctly? It seems like you may have an issue along those lines.

    Sean
  • Thanks Sean for your inputs. Actually I am using the PMSM code from controlsuit and did not change any declarations. It works fine from RAM at the moment. With RAM the code builds without any error.

    Is the source file linked correctly?
    I think its linked correctly now. However let me know how to check this.

    Is the header file included correctly?
    there are no errors at the moment.

    Please suggest.
    thx
    KVRao
  • KVRao,

    Did you rename your CCS project from "Example_28035_Flash" to "PM_Sensorless_Flash"? I'm wondering why your project output is named Example_28035_Flash.out instead of PM_Sensorless_Flash.out.

    If you did indeed rename Example_28035_Flash to PM_Sensorless_Flash, what was the procedure you used to add all the additional source files (i.e. PM_Sensorless.c)?

    Sean
  • Sean,

    I followed the following procedure

    1) Imported the Example_28035_Flash.pjt from controlsuit
    2) In the CCS project explorer right clicked on the example_28035_flash and choose the "Add files.." option (3rd Option). Added all the additional needed files (i.e.incl PM_Sensorless.c) as required for PMSM code.
    3) Faced the file linking problem and corrected the same by following the method as suggested by you.
    4) Renamed the file as PM_Sensorless_Flash by right clicking on the project explorer and selecting the Rename...

    Still get errors for building the code as mentioned earlier.

    Please review the above and suggest how to sort this.
    thx
    KVRao
  • KVRao,

    You're going to want to change the PM_Sensorless project instead of the Example_28035_Flash project, as there is much less lifting needed to change the first instead of the second.

    I've gone through the process on my end, and was able to get the code to compile to flash after a few changes.

    1) You'll need to add F28035.cmd to PM_Sensorless project, as this linker command file has the correct sections set up to write program code to FLASH D section (as seen on line 124-129 of F28035.cmd)

    2) Exclude DSP2803x_Headers_nonBIOS.cmd from PM_Sensorless project

    3) Under project properties, you're going to need to change your Build->C2000 Compiler->Include Options. The include search path that I saw was "${DRV830x_F2803x_DEVICE_SUPPORT_ROOT}\DSP2803x_headers\include" - change that to "${DRV830x_F2803x_DEVICE_SUPPORT_ROOT}\..\v130\DSP2803x_headers\include". In essence we're changing the include path from older v124 option to newer v130 option

    4) Do the same for include search path "${DRV830x_F2803x_DEVICE_SUPPORT_ROOT}\DSP2803x_common\include" to "${DRV830x_F2803x_DEVICE_SUPPORT_ROOT}\..\v130\DSP2803x_common\include"

    5) In PM_Sensorless.c, change line 68 from extern Uint16 *RamfuncsLoadStart, *RamfuncsLoadEnd, *RamfuncsRunStart; to extern Uint16 *RamfuncsLoadStart, *RamfuncsLoadSize, *RamfuncsRunStart; . The old way looks for an address that represents the end of memory space, while the way I got it to work was instead supply the size of the memory space to be copied to RAM.

    6) In PM_Sensorless-DevInit_F2803x.c, go to function MemCopy() on line 670. Add this line of code before the while() loop: SourceEndAddr = (Uint16*)(SourceAddr+((Uint16)SourceEndAddr));

    7) Finally, in PM_Sensorless.h, add this line of code to the end: #define FLASH 1

    These changes should add an appropriate FLASH linker command file, correct the include path, update the FLASH MemCopy function, and enable the lines of source code that deal with copying your program from FLASH to RAM at run-time.

    For me, the code compiles and appears to execute correctly. I haven't tried running the project to spin a motor with the changes, so if it doesn't work, post back and we'll keep trying to tweak PM_Sensorless lab to load from FLASH

    Sean
  • Dear Sean,


    Thanks for your support and I appreciate it.  Did changes as suggested and its really cool.  Many errors were addressed with one or two left as in the attached image.  We are near to the solution.

    Please review and suggest.

    thx

    KV

  • KV,

    First thing I see is RamfuncsLoadEnd is still being called by some function. You're going to want to remove RamfuncsLoadEnd and instead pass RamfuncsLoadSize. You'll see in the F28035.cmd that the ramfuncs section only has RamfuncsLoadStart, RamfuncsLoadSize and RamfuncsRunStart defined.

    As for incompatible declaration of PieVectTable, can you check if struct PIE_VECT_TABLE has been declared twice? You can either ctrl+left click on the type to follow to it's declaration, or highlight -> right click -> Open Declaration to see if it has been declared twice (i.e. two separate header files)

    Please check the above and report back

    Sean
  • Dear Mr.Sean,

    Thanks for your valuable inputs.  I could sort the RamfuncsLoadEnd error by replacing it with RamfuncsLoadSize.  Cool.

    reg volatile struct PIE_VECT_TABLE PieVectTable : - Followed the procedure suggested.  it appears that its declared twice - line no.196 and line no.29 of PieVect.h.

    Could you please review and suggest.  Attached the image.

    Thx,

    KV

  • KV,

    With regards to PIE_VECT_TABLE in DSP2803x_PieVect.h - it's not declared twice in that header file. What's happening there is the definition of the struct on line 29 and then the subsequent declaration of a PIE_VECT_TABLE struct named PieVectTable on line 196. This convention is no problem for the compiler and isn't the cause of the error you're experiencing. The error you're seeing is related to the declaration in DSP2803x_GlobalVariableDefs.c, I'd need to see what's happening on line 314 of that as well. You're sure that there isn't two places where PieVectTable is being declared (i.e extern volatile struct PIE_VECT_TABLE PieVectTable;)?

    Sean

  • Hi Sean,

    I checked if PieVectTable is being declared twice but could not trace it.  You mentioned about line 314 but its some thing else.  Attached the pics.

    Please suggest.

    thx

  • KV,

    It looks like you've declared your PieVectTable as a volatile struct in PieVect.h but not in GlobalVariableDefs.c. You'll need to declare "volatile struct PIE_VECT_TABLE PieVectTable" in GlobalVariableDefs.c

    When you use the extern keyword, the compiler expects the exact same variable declaration external to the initial placeholder declaration. Here, you have declared one external volatile struct, but then instantiated a (non-volatile) struct.

    You may want to review the TMS320C28xx C language implementation here: www.ti.com/.../spru514k.pdf, specifically section 6.5

    Sean
  • Dear Mr.Sean,

    Thanks for your valuable support till now.  I really appreciate it.

    I changed the declaration and the code builds without any errors.  Unfortunately I get many warning messages as in the attached image.  Please suggest.

    thx

  • KV,


    The code should be able to compile and load even with warnings. Please try to run the code from FLASH regardless of the warnings.

    Sean

  • KV,

    If this post has sufficiently helped resolve your issue, I'll mark it as closed

    Sean
  • Hi Sean,

    Thanks for your support and apologise for the delay.

    I was reviewing Example_2803xFlash.c and they have mentioned

    Steps that were taken to convert the ePWM example from RAM to Flash execution:

    1) - Change the linker cmd file to reflect the flash memory map.
    2) - Make sure any initialized sections are mapped to Flash.   In SDFlash utility this can be checked by the View->Coff/Hex status utility. Any section marked as "load" should be allocated to Flash.
    3) - Make sure there is a branch instruction from the entry to Flash at 0x3F7FF6 to the beginning of code execution. This example uses the DSP0x_CodeStartBranch.asm file to accomplish this.
    4) - Set boot mode Jumpers to "boot to Flash"
    5) - For best performance from the flash, modify the waitstates and enable the flash pipeline as shown in this example.

    Note: any code that manipulates the flash waitstate and pipeline control must be run from RAM. Thus these functions are located in their own memory section called ramfuncs.

    I think we have taken care of step 1 and how about steps 2,3 & 5 and the note.  Could you please review and suggest if our code needs any further changes.

    Please do the needful.

    thx

    KV

  • KV,

    If you look at the beginning of the main() function call, you'll see MemCopy() and InitFlash() functions. These take care of steps 3 & 5. Please look into the .cmd file for step 2. You should see the ramfuncs section has load set for FLASHD.

    Sean
  • Dear Mr.Sean,

    Thanks for your support and you helped me progress till now.  Today I could successfully flash the code even with warnings.

    Tried to run the code but IsrTicker is not active.

    Attached the PPT too for your reference.  Could you please advice.

    thxpmsm_flash.pptx