/var/www/restricted/ssh/stm32/www/stm32circle/ STM CircleOS forum / Newbie: Help with reading data from the extension

Username:     
Password:     
             

Forum

# 1   2010-11-17 10:18:55 Newbie: Help with reading data from the extension

hozefa26
New member
Registered: 2010-11-16
Posts: 1

Newbie: Help with reading data from the extension

Dear all,

I am trying to read data from pin 11 from the STM32Primer2 extension. Using the multimeter I can see some voltage over pin 11 (between 1-1.7V) but when I try to read it in my code, it doesn't quite work out. I got the STM32Primer2 with the extension yesterday and have been trying to figure it out since. Any help would be appreciated. My Application_Ini and Application_Handler functions look as follows:

Code:

enum MENU_code Application_Ini(void)
    {
    // Ensure that the current OS version is recent enough
    if(strcmp(UTIL_GetVersion(), NEEDEDVERSION) < 0)
        {
        return MsgVersion();
        }


    // TODO: Write your application initialization function here.

    GPIO_InitTypeDef  GPIO_InitStructure;
    GPIO_InitStructure.GPIO_Pin = currentpin;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_Init(GPIOC, &GPIO_InitStructure);
    GPIO_ResetBits(GPIOC, currentpin);
    return MENU_CONTINUE_COMMAND;

    }

enum MENU_code Application_Handler(void)
    {
   
   
    // u8 ret1 = GPIO_ReadOutputDataBit(GPIOC, currentpin);
    // u16 ret2 = GPIO_ReadOutputData(GPIOC);
     u8 ret3 = GPIO_ReadInputDataBit(GPIOC, currentpin);
    char str[4];
    UTIL_uint2str( str, ret3, 1, 0);
    DRAW_DisplayString( 5, 100, str, sizeof(str));
   
    // This routine will get called repeatedly by CircleOS, until we
    // return MENU_LEAVE

#if 1
    // If the button is pressed, the application is exited
    if(BUTTON_GetState() == BUTTON_PUSHED)
        {
        BUTTON_WaitForRelease();
        return MENU_Quit();
        }
#endif

    return MENU_CONTINUE;   // Returning MENU_LEAVE will quit to CircleOS
    }

Looking forward to your advice/suggestions/comments.

Thank you in advance.

-Hozefa

Offline

 

# 2   2010-11-18 07:15:34 Newbie: Help with reading data from the extension

yrt
Administrator
From: Grenoble-France
Registered: 2008-06-11
Posts: 520
Website

Re: Newbie: Help with reading data from the extension

Hi Hozefa,

First remark, you configured the input in floating mode : have you connected a pull-up resistor on the extension connector to fix the default voltage ? Else you should configured it in pull-up mode (GPIO_Mode_IPU) or pull-down (GPIO_Mode_IPD).

Second question : what is the value of "currentpin" ? Is it "GPIO_Pin_11" or something like that, because remember it is a mask value and not a pin number.

Hope this helps.

Yves

Offline

 

Board footer