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.

Running from Flash CLA code in C

Other Parts Discussed in Thread: CONTROLSUITE

Hi,

I have a CLA script written in C which I want to run from Flash on piccolo F28069. I run the F28069_example_nonBIOS_flash and it works perfectly. However, I tried writing the cla script in C (instead of assembly). I made sure to add the following lines to CLA_lnk.cmd since they were in the assembly script:

_Cla1Prog_Start = _Cla1funcsRunStart;

--undef_sym=__cla_scratchpad_end
--undef_sym=__cla_scratchpad_start

the program compiled successfully. I got only one warning saying that the compiler version was not installed. The code for the main CPU runs from flash, but the cla code doesn't run (I toggle a pin in the cla_isr and read the signal on an oscilloscope. I get no signal).

My question is: do I need to add/do something else in order for the C code to work instead of the assembly code provided in the example?

Thanks in advance! 

  • Christoffer,

    You can compile and run C code for the CLA, but not from flash. The CLA only has access to certain blocks of RAM so your CLA code must be loaded into these before it can be run. I recommend opening one of the CLA examples in controlSUITE to see how the project is set up. Look also at how the CLA sections are allocated into memory in the linker command file.

    Regards,

    Richard
  • Hi Richard,

    I think my post was not very clear. I didn't mean to run the CLA code from flash, rather to store the code in flash, copy it to the ram on startup, and then run it. I'm building a drone and I use the CLA for the control loop calculations. I don't want to have to program the drone every time I power cycle. The example in control suite already shows how to do what I want, but the CLA code that they provide is written in assembly. Since I don't want to rewrite my C program in assembly, I thought that it should be possible to be able to do it in C.

    The example I'm talking about is called F28069_example_nonBIOS_flash (from control suite). I tried replacing the assembly CLA code with C. The project compiles with no errors and one warning that I mentioned above. However, I don't get the desired functionality.

    Are you saying that the CLA code must be in assembly in order for it to be written to the flash and then copied to the ram??

    Regards,

    Christoffer

  • Christoffer,

    Sorry, I think I may have misunderstood too.  It is absolutely possible to write code for the CLA in C and to load into flash in the same way as assembly code.  

    From the filename I think the project you are using came from application note SPRA958 - is that correct?  If you had it working previously with CLA code in assembly it should have been straigtforward to get it going with C.  Is your C code in a file with ".cla" extension, and is CLA support enabled in the CCS settings (see attached)?CLA enable.pdf

    Regards,

    Richard

  • Hi,

    Glad we're on the same page now :D

    The project name is Example_2806xClaAdcFirFlash in ControlSUITE (I mentioned the wrong project in my previous post. I apologize for the mistake).

    I do have my C code with ".cla" extension and the CLA support is enabled in settings.

    When I switch to from assembly to C code I get this following warning:

    "creating output section ".scratchpad" without a SECTIONS"

    I searched for what can cause this and apparently it has to do with that I don't have the equivalent of { .sect        "Cla1Prog" } instruction in my C code.  I tried editing the F28069_CLA_lnk.cmd to include a .scratchpad section but I couldn't fix the problem.

    Do you have access to the project/files I'm working on, or should I include a copy of them in a comment?

  • Christoffer,

    Can you let me know where in controlSUITE this project is please? I'm having trouble finding it. Thanks.

    Regards,

    Richard
  • Christoffer,

    Just to add, attached is the correct way to add the scratchpad definition to the linker command file.

    Regards,

    Richard

    scratchpad link.pdf

  • C:\ti\controlSUITE\device_support\f2806x\v150\F2806x_examples_ccsv5\cla_adc_fir_flash

    Regards,

    Christoffer
  • Hi Richard,

    I implemented the steps mentioned in "scratchpad link.pdf", but the code is still not working (I'm not getting the task finish interrupts, contrary to when I use the assembly code). However, the warning I had before is gone now. What should I do next?

    Regards,

    Christoffer
  • Christoffer,

    Sorry for the delay - I have been having trouble with my test setup so I haven't been able to test this.  A colleague reminded me there is a CCS project which implements CLA code in C running from flash.  The project is in the multi-day workshop for F28069 which you can download at:

    http://processors.wiki.ti.com/index.php/C2000_Archived_Workshops#C2000_Piccolo_Multi-Day_Workshop_-_Revision_5.0_May_2014_.28ExpKit_F28069.3B_CCSv6.0.29

    Module 10 covers the CLA.  I think this will help you.

    Regards,

    Richard

  • Richard,

    Thanks for your help. The workshop is helpful and now I have an example that is running as I want. I will try to edit my own code accordingly and hopefully get my stuff working!

    Regards,

    Christoffer