Hello,
I have a problem with the Timer_Callback function.
This is the sourcecode:
#define GRAPH_Y_ORIG 35 #define GRAPH_X_ORIG 5 #define AXIS_Y_LEN 165 #define AXIS_X_LEN 310 void Timer_Callback(void const *arg) { int adcValue; int x_new = 5; int y_new; int dif; int j, k; if(x_cnt == 311) { GLCD_ClearScreen(); Init_GLCD(); x_cnt = 0; i = 0; } ADC_StartConversion(); while(ADC_ConversionDone()<0); adcValue = ADC_GetValue(); x_new = x_new + x_cnt; x_cnt = x_cnt + 1; y_new = ((165.0f / 1024.0f) * adcValue) - 165.0f; y_new = fabs(y_new) + 35; if(i == 1) { GLCD_SetForegroundColor(GLCD_COLOR_YELLOW); GLCD_DrawPixel(x_new, y_new); if(y_old < y_new) { dif = y_new - y_old; for(j=0; j<=dif; j++) { y_old = y_old + 1; GLCD_SetForegroundColor(GLCD_COLOR_YELLOW); GLCD_DrawPixel(x_old, y_old); } } else if(y_old > y_new) { dif = y_old - y_new; for(k=0; k<=dif; k++) { y_old = y_old - 1; GLCD_SetForegroundColor(GLCD_COLOR_YELLOW); GLCD_DrawPixel(x_old, y_old); } } else { GLCD_SetForegroundColor(GLCD_COLOR_YELLOW); GLCD_DrawPixel(x_new, y_new); } x_old = x_new; y_old = y_new; } else { GLCD_SetForegroundColor(GLCD_COLOR_YELLOW); GLCD_DrawPixel(x_new, y_new); x_old = x_new; y_old = y_new; i = 1; } }
My problem is if I set the start time of my timer 1ms, it works.
int main(void) { ADC_Initialize(); GLCD_Initialize(); Init_GLCD(); id = osTimerCreate(osTimer(Timer), osTimerPeriodic, NULL); if(id) osTimerStart(id, 1); }
But if I set it greather then 1ms it doesn't work. Can anyone help me?