cancel
Showing results for 
Search instead for 
Did you mean: 

Read state of pin STM32

zizou_zaydoun1988
Associate II
Posted on May 11, 2012 at 15:28

HELLO,

I use

The

STM32L152RBT6

.

I want to know

how I can

read

the logic state

of a pine tree

if it is

up or down

and display it on

LCD. 

#!rocketscience
15 REPLIES 15
zizou_zaydoun1988
Associate II
Posted on May 15, 2012 at 10:50

I tried

to

connect the

PA3

pin

to pin

VDD and

sometimes

PIN 

3V

 

but

LCD

still

 

displays

''LOW''

, I

do not know why

:

(

Posted on May 15, 2012 at 13:32

I tried

 

to

 

connect the

 

PA3

 

pin

 

to pin

 

VDD and

 

sometimes

 

PIN 

3V

 

 

but

 

 

LCD

still

 

 

displays

 

''LOW''

, I

 

do not know why

:

It should be consistent, but I don't know if you have anything else connected to the pin in your circuit, or whether you have the GPIOA clock enabled.

You're basically asking us to guess what's wrong with your code/configuration without providing a complete context.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
zizou_zaydoun1988
Associate II
Posted on May 15, 2012 at 15:05

Sorry

,

currently no

circuit is connected

to my map

,

the clock

GPIOA

CCR

is active

,

I try

to test

just

how I

view the status

of a single

pin

on

LCD

before I

arm

him

,

but unfortunately

I have not

come

to

the

correct instruction

alok472
Associate II
Posted on May 16, 2012 at 15:10

''

but unfortunately

 

I have not

 

come

 

to

 

the

 

correct instruction''

 

You already got the answer from Clive1, Sequiera. What else you are looking for ?

Do you have a debugger connected ? Kindly check if you are able to see the change in IO state in debug window with this ? It's not clear from your post if you are struggling to read the pin state or Putting the info on LCD ? 

zizou_zaydoun1988
Associate II
Posted on May 23, 2012 at 00:09

yes, I just need the instruction of  Putting the info on LCD 

Thank you

Posted on May 23, 2012 at 02:45

yes, I just need the instruction ofPutting the info on LCD

Can you post the code you have now, or review the STM32L15x firmware library and the example code for the Discovery and Eval boards. Here's a 5 minute hack of the example code to monitor PA3

/**
******************************************************************************
* @file LCD/LCD_SegmentsDrive/main.c MODIFIED
* @author MCD Application Team
* @version V1.1.1
* @date 13-April-2012
* @brief Main program body
******************************************************************************
* Shamelessly Modified from
* STM32L1xx_StdPeriph_Lib_V1.1.1\Project\STM32L1xx_StdPeriph_Examples\LCD\LCD_SegmentsDrive
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include ''stm32l1xx.h''
#ifdef USE_STM32L152D_EVAL
#include ''stm32l152d_eval_glass_lcd.h''
#else
#include ''stm32l152_eval_glass_lcd.h''
#endif
/** @addtogroup STM32L1xx_StdPeriph_Examples
* @{
*/
/** @addtogroup LCD_SegmentsDrive
* @{
*/
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
#define SCROLL_SPEED 5000 /* Low value gives higher speed */
#define SCROLL_NUM 20
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
void RCC_Config(void);
/* Private functions ---------------------------------------------------------*/
/**
* @brief Main program.
* @param None
* @retval None
*/
int main(void)
{
 GPIO_InitTypeDef GPIO_InitStructure;
 

uint16_t current, last;
/*!< At this stage the microcontroller clock setting is already configured,
this is done through SystemInit() function which is called from startup
file (startup_stm32l1xx_xx.s) before to branch to application main.
To reconfigure the default setting of SystemInit() function, refer to
system_stm32l1xx.c file
*/
/* System Clocks Configuration */
RCC_Config();
/* LCD GLASS Initialization */
LCD_GLASS_Init();
#ifdef USE_STM32L152D_EVAL
LCD_GLASS_DisplayLogo(ENABLE);
#endif
/* GPIOA Periph clock enable */
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);
/* Configure PA3 as output pushpull mode */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_40MHz;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOA, &GPIO_InitStructure);
last = !GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_3);
/* Infinite loop */
while (1)
{
current = GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_3);
if (current != last)
{
if (current == 0)
LCD_GLASS_ScrollString(''PA3 LOW'', SCROLL_NUM, SCROLL_SPEED);
else
LCD_GLASS_ScrollString(''PA3 HIGH'', SCROLL_NUM, SCROLL_SPEED);
last = current;
}
}
}
/**
* @brief Configures the different system and peripherals clocks.
* @param None
* @retval None
*/
void RCC_Config(void)
{
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);
/* Allow access to the RTC */
PWR_RTCAccessCmd(ENABLE);
/* Reset Backup Domain */
RCC_RTCResetCmd(ENABLE);
RCC_RTCResetCmd(DISABLE);
/*!< LSE Enable */
RCC_LSEConfig(RCC_LSE_ON);
/*!< Wait till LSE is ready */
while (RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET)
{}
/*!< LCD Clock Source Selection */
RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE);
}
#ifdef USE_FULL_ASSERT
/**
* @brief Reports the name of the source file and the source line number where
* the assert_param error has occurred.
* @param file: pointer to the source file name
* @param line: assert_param error line source number
* @retval None
*/
void assert_failed(uint8_t* file, uint32_t line)
{
/* User can add his own implementation to report the file name and line number,
ex: printf(''Wrong parameters value: file %s on line %d

'', file, line) */
/* Infinite loop */
while (1)
{
}
}
#endif

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..