AnsweredAssumed Answered

ADC Values

Question asked by hamza.yassine on Mar 11, 2015
Hello,
I'm working on the STM32f429i  und i have to program a  game on it using FreeRTOS and uGfx
and i have a Gamepad(Nokia 5110 Gamepad) connected with the STM32f429i.The Buttons are working fine(i used the function GPIO_ReadInputDataBit ) but i have a problem with the Joystik axis.To measure the ADC values of the Joystik  axis  I used the function TM_ADC_Read(ADC3,ADC_Channel4) for the first axis(connected with PF6) and TM_ADC_Read(ADC1,ADC_Channel5) for the second axis(connected with PA5)  but this functions always stop in  while(ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC) == RESET) and  while(ADC_GetFlagStatus(ADC3, ADC_FLAG_EOC) == RESET) .this is my code:
static void myTask() {

    font_t font1;
    font1 = gdispOpenFont("DejaVuSans24*");


    int x=0,y=0,z=0,e=0,f=0;
    char str[50];



    while(1)
    {


       f=TM_ADC_Read(ADC3,ADC_Channel4);

      e=TM_ADC_Read(ADC1,ADC_Channel5);



        x=GPIO_ReadInputDataBit(RTPL_Register_Buttons,RTPL_Pin_Button_1);
        y=GPIO_ReadInputDataBit(RTPL_Register_Buttons,RTPL_Pin_Button_2);
        z=GPIO_ReadInputDataBit(RTPL_Register_Buttons,RTPL_Pin_Button_J);

        sprintf(str,"But1:%d But2:%d But3:%d J1:%d J2:%d",x,y,z,e,f);

           gdispClear(White);
        gdispFillString(0,120,str, font1, Red,White);
        vTaskDelay(100);
    }


}
So I decided to do it in another way so i changed the code to this one:
static void myTask() {

    font_t font1;
    font1 = gdispOpenFont("DejaVuSans24*");


    int x=0,y=0,z=0,e=0,f=0;
    char str[50];



    while(1)
    {

    TM_ADC_InitADC(ADC1);
    f=ADC_GetConversionValue(ADC3);
    TM_ADC_InitADC(ADC1);
    e=ADC_GetConversionValue(ADC1);

      x=GPIO_ReadInputDataBit(RTPL_Register_Buttons,RTPL_Pin_Button_1);
        y=GPIO_ReadInputDataBit(RTPL_Register_Buttons,RTPL_Pin_Button_2);
        z=GPIO_ReadInputDataBit(RTPL_Register_Buttons,RTPL_Pin_Button_J);

        sprintf(str,"But1:%d But2:%d But3:%d J1:%d J2:%d",x,y,z,e,f);

           gdispClear(White);
        gdispFillString(0,120,str, font1, Red,White);
        vTaskDelay(100);
    }


}
But then i have  another problem: When i move the Joystik the adc_values don't changes but if i reset the Board they do.So although i use a while loop and i move the Joystik  The ADC_GetConversionvalue always gives the same values and i don't understand why.
PS:Thank you for your Time and I'm sorry for my English

Outcomes