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
esiqueira
Associate II
Posted on May 11, 2012 at 15:53

/* Reads the pin(3) of the GPIOA and store it in ReadValue variable */

u8 ReadValue;

ReadValue = GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_3);

esiqueira
Associate II
Posted on May 11, 2012 at 15:54

if (

GPIO_ReadInputDataBit(GPIOA

,

GPIO_Pin_3)==0)

{

    [...code...]

}

LCD SPI?

Posted on May 11, 2012 at 16:21

LCD SPI?

Probably not, the STM32L152 can drive the simple glass on it's own.

Not sure how the pine tree works, spruce or douglas?

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 11, 2012 at 16:26

thank you very much

,

but

is it possible

to give me

the instruction to

display the status

of

pine

on the display

LCD

STM32

board

after

reading it

and

thank you in advance

esiqueira
Associate II
Posted on May 11, 2012 at 16:32

Sorry,

Is this board???

  • STM32L152RBT6 microcontroller featuring 128 KB Flash, 16 KB RAM, 4 KB EEPROM, in an LQFP64 package

  • On-board ST-Link/V2 with selection mode switch to use the kit as a standalone ST-Link/V2 (with SWD connector for programming and debugging)

  • Board power supply: through USB bus or from an external 3.3 or 5 V supply voltage

  • External application power supply: 3 V and 5 V

  • IDD current measurement

  • LCD

    • DIP28 package

    • 24 segments, 4 commons

  • Four LEDs:

    • LD1 (red/green) for USB communication

    • LD2 (red) for 3.3 V power on

    • Two user LEDs, LD3 (green) and LD4 (blue)

  • Two pushbuttons (user and reset)

  • One linear touch sensor or four touchkeys

  • Extension header for LQFP64 I/Os for quick connection to prototyping board and easy probing

  • http://www.st.com/internet/evalboard/product/250990.jsp

    From: ayari.zied

Posted: Friday, May 11, 2012 4:26 PM

Subject: Read state of pin STM32

thank you very much

,

but

is it possible

to give me

the instruction to

display the status

of

pine

on the display

LCD

STM32

board

after

reading it

and

thank you in advance

zizou_zaydoun1988
Associate II
Posted on May 11, 2012 at 16:46

yes it is

the same card

as mine

, so

is

that

you can help me

?

esiqueira
Associate II
Posted on May 11, 2012 at 18:29

I think you need reference the library: stm32l_discovery_lcd

Then use this function to display message at LCD

/* Display Welcome message */

LCD_GLASS_ScrollSentence('' **PIN 3 ACTIVE**'',1,SCROLL_SPEED);

This funcion can be found at: stm32l_discovery_lcd.c

/**

* @brief This function writes a char in the LCD RAM.

* @param ptr: Pointer to string to display on the LCD Glass.

* @retval None

* @par Required preconditions: Char is ASCCI value ''Ored'' with decimal point or Column flag

*/

void LCD_GLASS_DisplayStrDeci(uint16_t* ptr)

{

uint8_t i = 0x01;

uint8_t char_tmp;

// LCD_GLASS_Clear();

/* Send the string character by character on lCD */

while ((*ptr != 0) & (i < 8))

{

char_tmp = (*ptr) & 0x00ff;

switch ((*ptr) & 0xf000)

{

case DOT:

/* Display one character on LCD with decimal point */

LCD_GLASS_WriteChar(&char_tmp, POINT_ON, COLUMN_OFF, i);

break;

case DOUBLE_DOT:

/* Display one character on LCD with decimal point */

LCD_GLASS_WriteChar(&char_tmp, POINT_OFF, COLUMN_ON, i);

break;

default:

LCD_GLASS_WriteChar(&char_tmp, POINT_OFF, COLUMN_OFF, i);

break;

}

/* Point on the next character */

ptr++;

/* Increment the character counter */

i++;

}

}

________________

Attachments :

stm32l_discovery_lcd.c : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HtDW&d=%2Fa%2F0X0000000aKO%2FFhSOtSxvdFAq6DUKhYrE6hnMtwnlFnyWftoSsjUTpB8&asPdf=false

stm32l_discovery_lcd.h : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HtVt&d=%2Fa%2F0X0000000aR6%2FUs8_tSilfLoz7gyKUumW5SKx._7_RWoGFoSo66gJn3Q&asPdf=false
zizou_zaydoun1988
Associate II
Posted on May 14, 2012 at 10:53

Again, thank you

,

but I want

the instruction that

allows me to send

the logic state of 

pin

PA3 for

example

to

LCD

Posted on May 14, 2012 at 19:48

Again, thank you

,

but I want

the instruction that

allows me to send

the logic state of

pin

PA3 for

example

to

LCD

if (GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_3)==0)
LCD_GLASS_DisplayString(''PA3 LOW'');
else
LCD_GLASS_DisplayString(''PA3 HIGH'');

Perhaps you need to review some of the example code for the STM32L Discovery board and get more familiar with programming
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..