Tool/software: TI C/C++ Compiler
Dear all,
I have work on a new project that needs SD16 to convert analog data to digital data.
In order to get the data with the lowest tolerance scope, I do SD16 for many times and get average.
In the process, I define a temporarily variable with the format unsigned long, and the variable is used or saving the result of SD16MEM.
After the process is finished, I get the average of the temporarily variable into times of getting SD16.
My trouble is that if the times(define as SD16_Check_Time in the code) is higher the 40, MSP will reboot in the process of SD16.
What is the reason that cause the status?
If I still need a lot of times to do this operation, how can I solve the problem?
This is the code I use for get SD16,
#define SD16_Check_Time 30 void Get_SD16_Data(void) { unsigned long temp_AD_Value; unsigned int temp_SD16; unsigned short loop; temp_AD_Value=0; for(loop=0;loop<SD16_Check_Time;loop++) { SD16CCTL0 = SD16SNGL + SD16SC;// Set bit to start conversion while ((SD16CCTL0 & SD16IFG)==0);// Poll interrupt flag for CH0 temp_SD16=SD16MEM0;// Save CH0 results (clears IFG) temp_AD_Value += temp_SD16; } AD_Value=temp_AD_Value/SD16_Check_Time; }
Sincerely,
Yu-Chuan, Chen