- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Simple question I've looked at several different ways. Can someone look over the code below and help me understand what I'm doing wrong? I'm recieving the warning below and the Array is not functional. It has to be something simple I'm not seeing. Any help would be greatly appreciated.
"M0121: variable 'Input_Array' set but not used [-Wunused-but-set-variable]
int main()
{
int16 x;
uint8 Input_ADC;
uint8 ADC_Result =0;
uint8 Input_Array[16];
uint8 Input_Channel =0;
CyGlobalIntEnable; /* Enable global interrupts. */
ADC_SAR_1_Start();
ADC_SAR_1_IRQ_Enable();
M_4_Write(1); // enable external analog mux
while (x<3000) // delay before using
x++; //
x=0;
for(;;)
{
Control_Reg_1_Write (Input_Channel); // set channel external mux
while (x<3000) // Delay Before Conversion
x++;
x=0;
while (Input_Channel<16) // scan routine
{
ADC_SAR_1_StartConvert(); // Start Conversion
if(ADC_SAR_1_IsEndConversion(ADC_SAR_1_WAIT_FOR_RESULT));
{
ADC_Result = ADC_SAR_1_GetResult8();
Input_Array[Input_Channel] = ADC_Result;
Input_Channel++;
Control_Reg_1_Write (Input_Channel);
while (x<3000) // Delay Before Conversion
x++; //
x=0;
}
}
}// end for
}// end main
Solved! Go to Solution.
- Labels:
-
PSoC 5LP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Welcome in the Forum, Tim.
The warning is quite reasonable: You assign a value to Input_Array[] which is not a global variable (local to the function main) and you never use that value again. When not compiling with a strong optimization there will be no effect, just a warning. When compiling with optimization set to "Size" or "Speed" the assignment may be optimized-out.
Another pitfall: your delay-loop is quite undetermined. Better use CyDelay() or CyDelayus(), both documented in the "System Reference guide" (from Creator "Help"-menu.
Happy coding
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Welcome in the Forum, Tim.
The warning is quite reasonable: You assign a value to Input_Array[] which is not a global variable (local to the function main) and you never use that value again. When not compiling with a strong optimization there will be no effect, just a warning. When compiling with optimization set to "Size" or "Speed" the assignment may be optimized-out.
Another pitfall: your delay-loop is quite undetermined. Better use CyDelay() or CyDelayus(), both documented in the "System Reference guide" (from Creator "Help"-menu.
Happy coding
Bob