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.

Using simulink block to generate C code with c2000 DSP



 

Hello community!

First post :)

I am working on a project that will use the f28335 dsp. I am using it for 3 months now. I started learning the programming part by reading the pdf files and started doing some experiments writing code using Code composer studio 3.3. That went well, ADCs, ePWMs worked well, everything was OK, followed some examples (thanks TI for that) and read some posts in this forum.

After some tests in simulink I found out that the code generated by matlab was pretty much the same I used before and due to the complexity of the project and my expertise in simulink it was decided to use simulink to make the code for us. Till here everything works GREAT! (very happy user :)

To the problem:

When i use certain blocks from simulink (to be precise: simpowersystems - discrete mean value) the program runs fine until theblock stops working. Everything works great but that block gives "continuous" zero output after some time. To test just that I made a smal program in simulink that used the mean value of the ADC output signal to control a ePWM compare (A) value in order to change the duty cycle of the pwm signal. If you want to test it: transformed the output signal of the ADC unit to double precision -> Discrete Mean value -> uint16 -> CMPA of ePWM unit. epwm was set to count up to 4095, so no need to adjust the output level of ADC. This setup runs ok for about 3 minutes, then stops working without any change. To be sure that it was the Discreet Mean Value block i connected the adc output to another block (change the phase shift of 2 other ePWM units) and they dont stop working.

Also, i checked for control bits change but (not that experienced user) didn’t noticed anything in the ADC or ePWM control registers. More... If i reset the unit from CCS everything runs ok again for a period of time.

Is this normal? Am i doing anything wrong? Did i miss some control?

I am about to try this without simulation mode (the error occurs even if i dont refresh the CCS variables) but i'm still learning (starting tbh) how to flash program the dsp :)

Thank you very much for your time and I hope you can help me figuring out what is happening.

  • Hallo there

    This is not a reply but rather a question.

    My setup is very similar to yours except that I am working wit the F28027 piccolo mcu which is similar to the F28335.

    So here's my question:

    In my simulink model I have configured my adc block for an analog signal input (<3.3) from adc-A1, but for some reason I can't display the value obtained from my adc in simulink. From your post it seems you have this figured out? After asking around some of my colleagues seem to think that it's got something to do with serial communication setup           ("SCI setup" block).

    Maybe it would also be wise to ad that I am not a frequent simulink user.

    Some advice would be greatly appreciated.

    Regards

    Renier

  • Helo Renier,

    Simulink (with its blocks) only generates the C code of your program. You can see simulink only as a visual programming program, it will build programs for anything it has support, including Texas DSPs and your computer.

    If you notice CCS has to be opened in order to program the DSP, when you Ctrl+B, Simulink will generate a new project (or update existant) with all the files needed and then instructs CCS to compile it. After that you can debug your code and monitor the register variables for the ADC and more (refreshing the Watch Window). From this point onwards you wont have any information regarding the dsp on simulink, you might as well turn Matlab off because it wont influence the DSP and saves up memory :) To add variables just use the gel file and menu. To be honest I still don't know how to do this on CCS v4. I don't have a licence for that yet.

    Other option is to configure your dsp to send over USB (using a serial protocol/interface - Serial Communication Interface SCI) the information you need and maybe use the same or another Simulink program to monitor the usb port. For this you need to configure the SCI Setup block, where you configure all the parameters for the serial data transfer. Sorry for not helping you as I never used this setup before, but would like to :) If you figure out how to do it simple and easy, please tell me/us how :)

    One final though, using Simulink i realised I couldn't use all my programming skills, dealing with interrupts is not that cleared, Simulink generates code with a certain order that sometimes isn't the best. From my little experience I believe that Simulink is very good to generate the backbone of your program after that i strongly recommend that you look at the generated code and try to understand what Simulink did and then change or rearrange that code.

    That's how I solved my previous problem with the mean value. Well, it was not the solution to the program looking at the code, but helped me figuring out what was causing the error.

    Hope this help!

    Rui Ventura