Other Parts Discussed in Thread: C2000WARE
I have a CLA routine (Task3) which is triggered by ADC EOC interrupt. The Task 3 will fetch ADCC SOC0 result, and use it for PID calculation.
I use a pointer (*claAdcCresAddr) to access ADCC SOC0 result. The pointer is properly initialized in the Cla1DataRam1 section before switching the master from CPU to CLA.
claAdcCresAddr = (Uint16*)(ADCCRESULT_BASE);//ADCCRESULT_BASE is defined to 0x00000B40U.
However, when I run the below function, the sample_Uint16 value stays at 0, even though the actual ADC result is not 0.
__interrupt void Cla1Task3 ( void )
{
//Local Variables
float sample;
Uint16 sample_Uint16;
__mdebugstop();
// read ADC channel
sample_Uint16 = claAdcCresAddr[0];//0 is SOC number
sample = (float)sample_Uint16;
// run the PID controller
uk = DCL_runPID_L2(&pid1, rk, sample, lk);
__mnop();
__mnop();
__mnop();
}
I set a breakpoint at Line 31 (shown below). When I hover the mouse over claAdcCresAddr[0], the pop-up window shows the pointer value is 0xB40, which is the correct ADCC result address. The window also shows the value at the pointed address is 2085 (0x825).
Nevertheless the Registers window shows the ADCC Result0 value is 0x824.
When I hover mouse over the local variable sample_Uint16, the variable doesn’t appear to be assigned a value. Only the declaration is shown. The information would disappear once I press a key, so I cannot save a screenshot. So instead I am showing the Variables window, which shows the local variables sample and sample_Uint16 do not have a value. This result would remain the same after I step through the function.
So, even though CCS is able to read ADCC SOC0 result using the pointer address, the value cannot be passed to the local variable. What did I do wrong here?
I looked through the C2000ware examples, but did not find any example that shows how to directly read ADC result from CLA code. So please help.
Thank you very much.