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.
Hi,
I saw in the CLA_Adc example (from ControlSUITE) that it used " Cla1Task8 " to initialize the values of the " Cla1ToCpuMsgRAM " variables.
I am wondering if this is the only way to do it.
Thank you,
Frank
Hi,
I did some experiments by modifying the CLA_Adc example from ControlSUITE. I used the variable " ConversionCount " as an experiment target.
Here is what I did:
In the main source file " Example_2803xClaAdc.c"
1. I removed CLA task8 register initialization
Cla1Regs.MVECT8 = (Uint16) (&Cla1Task8 - &Cla1Prog_Start)*sizeof(Uint32);
2. I disable task8 by changing from " Cla1Regs.MIER.all = (M_INT8 | M_INT2); "
to "Cla1Regs.MIER.all = M_INT2; "
3. I added the initialization of ConversionCount (as shown below) in the main() function --- right after the ADC initialization " InitAdc(); "
ConversionCount =0;
In the assembly file " CLA.asm":
1. I deleted the following two lines of code from Task8:
MMOVIZ MR0, #0.0
MMOV16 @_ConversionCount, MR0
2. In Task1, I deleted the following lines of code
line 70: MCMPF32 MR0, #NUM_DATA_POINTS.0
line 75: MBCNDD _RestartCount, GEQ
line 81: _RestartCount
line 82: MMOV16 @_ConversionCount, MR1
So now, the counter " ConversionCount" won't be able to restart when it reaches the values of NUM_DATA_POINTS, so it will just keep increasing.
Up to this point, it did what it was expected to do.
Since I added code " ConversionCount =0; " to the Main() function, I expected the ConversionCount would start from Zero every time after I rebuild the project and re-run the code.
But, it turned out it didn't do that. The variable ConversionCount was not re-initialized after I re-build the project and re-run the code, It actually kept the value from the previous run.
I really want to know why it was doing like that.
Thank you,
Frank
ConversionCount is placed in the section Cla1ToCpuMsgRAM which is only accesible to the CLA. The reason it worked the first time is when you power the device the RAM location for ConversionCount was 0 which is why it only works after a power cycle and never after that
If you place a variable in a CLA only accessible location and you want to initalize it you will need to do it through a software triggered task...need not be task8 but since its has the least priority among all the tasks we use it to do one time initalization
Hi Vishal,
Thank you for your reply. I have two more questions.
1.
Initially, when I was reading the TI Document on CLA, I learned that variables in the section Cla1ToCpuMsgRAM were not accessible to CPU.
The reason I still tried to initialize these variables (Cla1ToCpuMsgRAM ) in the Main() function by CPU and expected it to work was that I have seen somebody did that in their project and it worked.
The difference between that project and the experiment I did (as described in my previous posting) is that they didn't put all the initialization in Main() function. Instead, they used a separated source file ( i.e. CLA.c) to declare variables in both sections ( Cla1ToCpuMsgRAM and CpuToClaMsgRAM ), and they created an function " InitializeCLA() in this source file to assign initial values to these variables.
Of course, they had to declare the function " InitializeCLA() " in the header file " CLA.h ", and extern the variables in the header file "CLAShared.h". Then, both the header files were included in the Main() source file.
Eventually, they put the function " InitializeCLA() " in the Main() function as part of the system initialization. (of course, they had to initialize other things of the system).
And, I was told that It worked.
My first question is : Does that make sense to you in terms of the way they did it ? and Why ? (since I don't see the real difference between what they did and what I have done in my experiment)
2.
Is there any alternative way to initialize variables in the section Cla1ToCpuMsgRAM other than initializing them in a CLA Task ?
Thank you,
Frank
Frank,
It is unlikely that the function worked for the Cla1ToCpuMsgRAM variables as the C28 doesn't have write access to it. These variables have to be initialized from within the CLA.
Now, if you are dealing with variables in the CLA data rams or in the CpuToCla1MsgRAM then yes you can intialize them in Main(). For the Data rams you need to make sure that they are mapped to the C28 first i.e. RAMxE = 0 before initializing the variables
Hi Vishal,
I think you are right.
The variables they initialized were in CLA data rams, not in Cla1ToCpuMsgRAM
Thank you,
Frank