cancel
Showing results for 
Search instead for 
Did you mean: 

GPIO - arduino pin mapping for STM32F769I-discovery?

benyBoy
Associate II
Posted on April 24, 2017 at 06:35

Hi , I have succesfuly managed to merge the GPIO example code into my project.

I am using the audio application project as the base project.

The GPIO button toggles the LED.

I would like to define 3 GPIO pins as digital ouputs on the arduino headers of the STM32F769I-discovery board

so far I have code below, but can't find the arduino pin : GPIO pin map ?

can arduino pins GPIO ? or should I be doing this a different way ? I just need to toggle 3 pins high and low.

static void EXTI0_GPIO_BEN(void)

{

  GPIO_InitTypeDef   GPIO_InitStructure;

  /* Enable GPIOC clock */

  __HAL_RCC_GPIOA_CLK_ENABLE();

// configure gpio pins for reset for external adc dsp and dac devices

// gpio reset for ADC

  GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;

  GPIO_InitStructure.Pull = GPIO_NOPULL; // no pullup or pull dowm resistors ?

  GPIO_InitStructure.Pin = GPIO_PIN_0;

  // gpio reset for DSP

  GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;

   GPIO_InitStructure.Pull = GPIO_NOPULL; // no pullup or pull dowm resistors ?

   GPIO_InitStructure.Pin = GPIO_PIN_1;

   // gpio reset for DAC

    GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;

     GPIO_InitStructure.Pull = GPIO_NOPULL; // no pullup or pull dowm resistors ?

     GPIO_InitStructure.Pin = GPIO_PIN_1;

  HAL_GPIO_Init(GPIOA, &GPIO_InitStructure);  /// go initilize pins ?

  // i don't think I need to have interrupts for this ??

 /* Enable and set EXTI line 0 Interrupt to the lowest priority */

 //  HAL_NVIC_SetPriority(EXTI0_IRQn, 2, 0);

 //  HAL_NVIC_EnableIRQ(EXTI0_IRQn);

}
12 REPLIES 12
Posted on April 24, 2017 at 10:50

so far I have code below, but can't find the arduino pin : GPIO pin map ?

UM2033 Table 13 and Fig.33

JW

Posted on April 24, 2017 at 11:43

 ,

 ,

Hi waclawek,

I looked at table 13 but cannot see how it relates to GPIO pin definition in example GPIO code.

for example which physical pin in table 13 is GPIO_PIN_0 , ?

GPIO_InitStructure.Pin = GPIO_PIN_0,

from the table,

pin number , , , , , , pin name  , , , , , label , , , , , , , , , , , , , , , , , , , , , comment

C2 , , , , , , , , , , , , , , , , , , , , PI8 , , , , ,  ,  ,  ,  ,  , , GPIO_Input , , , , , , , , , NC4

from GPIO example,

/** @defgroup GPIO_pins_define GPIO pins define

 ,

 , * @{

 ,

 , */

 ,

♯ define GPIO_PIN_0 , , , , , , , , , , , , , , , , ((uint16_t)0x0001U) , /* Pin 0 selected , , , */

 ,

♯ define GPIO_PIN_1 , , , , , , , , , , , , , , , , ((uint16_t)0x0002U) , /* Pin 1 selected , , , */

 ,

♯ define GPIO_PIN_2 , , , , , , , , , , , , , , , , ((uint16_t)0x0004U) , /* Pin 2 selected , , , */

 ,

♯ define GPIO_PIN_3 , , , , , , , , , , , , , , , , ((uint16_t)0x0008U) , /* Pin 3 selected , , , */

 ,

♯ define GPIO_PIN_4 , , , , , , , , , , , , , , , , ((uint16_t)0x0010U) , /* Pin 4 selected , , , */

 ,

♯ define GPIO_PIN_5 , , , , , , , , , , , , , , , , ((uint16_t)0x0020U) , /* Pin 5 selected , , , */

 ,

♯ define GPIO_PIN_6 , , , , , , , , , , , , , , , , ((uint16_t)0x0040U) , /* Pin 6 selected , , , */

 ,

♯ define GPIO_PIN_7 , , , , , , , , , , , , , , , , ((uint16_t)0x0080U) , /* Pin 7 selected , , , */

 ,

♯ define GPIO_PIN_8 , , , , , , , , , , , , , , , , ((uint16_t)0x0100U) , /* Pin 8 selected , , , */

 ,

♯ define GPIO_PIN_9 , , , , , , , , , , , , , , , , ((uint16_t)0x0200U) , /* Pin 9 selected , , , */

 ,

♯ define GPIO_PIN_10 , , , , , , , , , , , , , , , ((uint16_t)0x0400U) , /* Pin 10 selected , , */

 ,

♯ define GPIO_PIN_11 , , , , , , , , , , , , , , , ((uint16_t)0x0800U) , /* Pin 11 selected , , */

 ,

♯ define GPIO_PIN_12 , , , , , , , , , , , , , , , ((uint16_t)0x1000U) , /* Pin 12 selected , , */

 ,

♯ define GPIO_PIN_13 , , , , , , , , , , , , , , , ((uint16_t)0x2000U) , /* Pin 13 selected , , */

 ,

♯ define GPIO_PIN_14 , , , , , , , , , , , , , , , ((uint16_t)0x4000U) , /* Pin 14 selected , , */

 ,

♯ define GPIO_PIN_15 , , , , , , , , , , , , , , , ((uint16_t)0x8000U) , /* Pin 15 selected , , */

 ,

♯ define GPIO_PIN_All , , , , , , , , , , , , , , ((uint16_t)0xFFFFU) , /* All pins selected */

♯ define GPIO_PIN_MASK , , , , , , , , , , , , , ((uint32_t)0x0000FFFFU) /* PIN mask for assert test */

 ,

/**

 ,

 , * @}

 ,

 , */
Posted on April 24, 2017 at 12:38

In Tab13, search for lines where in Comment the name starts with ARD_. Fig.33 may be more comprehensive.

I am not going comment on the example code and 'libraries'.

JW

john doe
Lead
Posted on April 24, 2017 at 14:53

Your code in your first post shows how to initialize a gpio pin.

The relevant files are stm32f7xx_hal_gpio.h and stm32f7xx_hal_gpio.c

Its just a connector on a board. there is no arduino gpio api in the HAL.

Posted on April 24, 2017 at 13:29

Thanks Waclawek , helpful 

still don't know how to define a GPIO pin though. I should have guessed ARD was Arduino !

Maybe it would help if I knew the hardware address of say ARD_D0 ? Then I could work backwards

through the libraries / code to see the relationship.

Anyone know where I can find that information ?

does GPIO_PIN_0 or hardware address 0x0001 = ARD_D0 ?

maybe i'm looking for the hardware address of ARD_D0 , ARD_D1 etc

0690X00000606qHQAQ.png
Posted on April 24, 2017 at 14:59

I'd maybe forget about looking for and usingthe BSP defines, you have the info you need on the schematic

ARD_D0 is shown as PC7

To use that as an output you have to enable the GPIO clock for GPIO C and init the pin(s) as so:

GPIO_InitTypeDef GPIO_InitStructure;
__HAL_RCC_GPIOC_CLK_ENABLE();
GPIO_InitStructure.Pin = GPIO_PIN_6 | GPIO_PIN_7 | GPIO_PIN_8;
GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_OD; //GPIO_MODE_OUTPUT_PP; // ;GPIO_MODE_OUTPUT_OD
GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_HIGH;
GPIO_InitStructure.Pull = GPIO_NOPULL; // GPIO_PULLDOWN;
HAL_GPIO_Init(GPIOC, &GPIO_InitStructure);�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?

(I've also defined PC6 and PC8 as outputs above)

If you wanted to use the pins as part of a peripheral like I2C / SPI then you need to look at the examplesin the _msp files. These are where the GPIO is configuredvia callback from the HAL eg, within HAL_I2C_Init()

void HAL_I2C_MspInit(I2C_HandleTypeDef *hi2c)
{
 GPIO_InitTypeDef GPIO_InitStruct;
.
.
 /* Enable DMAx clock */
 I2Cx_DMA_CLK_ENABLE(); 
 
 /*##-3- Configure peripheral GPIO ##########################################*/ 
 /* I2C TX GPIO pin configuration */
 GPIO_InitStruct.Pin = I2Cx_SCL_PIN;
 GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
 GPIO_InitStruct.Pull = GPIO_PULLUP;
 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
 GPIO_InitStruct.Alternate = I2Cx_SCL_SDA_AF;
 HAL_GPIO_Init(I2Cx_SCL_GPIO_PORT, &GPIO_InitStruct);
�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?.
.
�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?

In this case, the I/O is #defined in a Board Support header file somewhere... when writing your own projects, I would recommend putting all the I/O setup in one place and replacing the #defines with actual pin numbers so you can see what's going on a bit easier.

egI2Cx_SCL_PIN might be GPIO_PIN_8 andI2Cx_SCL_GPIO_PORT might be GPIOBfor the processor you're using

Posted on April 24, 2017 at 15:40

Maybe it would help if I knew the hardware address of say ARD_D0 ? Then I could work backwards through the libraries / code to see the relationship.

Anyone know where I can find that information ?

does GPIO_PIN_0 or hardware address 0x0001 = ARD_D0 ?

maybe i'm looking for the hardware address of ARD_D0 , ARD_D1 etc

'ARD_D0' is just an arbitrary name for a signal/connection in the schematics.

Down to the right of your image, at CN13, you see an instance of ARD_D0, and directly to the left, 'PC7'.

This PC7 is the actual GPIO pin of the MCU used to provide that 'ARD_D0' functionality.

You will find the pin name PC7 in the usual documents (as Jan suggested).

With time and experience, you gonna get use to read schematics.

Posted on April 24, 2017 at 16:27

thank for this, so I can use these as digital output if I initialise them as such ?

PC02 = GPIO_PIN_2 = ARD_A2  ( arduino anlouge pin 2 )

PC06 = GPIO_PIN_6 = ARD_D1 ( arduino digital pin 1 )

PC07 = GPIO_PIN_7 = ARD_D0 ( arduino digital pin 0 )

PC08 =  GPIO_PIN_8 = ARD_D5 ( arduino digital pin 5 )

are there any other physical GPIO pins available as digital outputs on the STM32F769I-discovery ?

what does PCx , PFx , PAx etc stand for ?

Posted on April 24, 2017 at 19:03

I took a look at stm32f7xx_hal_gpio.c and came up with...

 HAL_GPIO_WritePin(GPIOA, 7,1); // GPIO_PIN_6 , ARD_D0 HIGH

  HAL_Delay(500);

  HAL_GPIO_WritePin(GPIOA, 7,0); // GPIO_PIN_6 , ARD_D0 LOW

HAL_Delay(500);

  HAL_GPIO_WritePin(GPIOA, 7,1); // GPIO_PIN_6 , ARD_D0 HIGH

HAL_Delay(500);

Will try it now and report back here if it works.

I noticed HAL_GPIO_TogglePin() but thought I'd try WritePin first.

I'm not really sure what GPIOA is doing and having a guess 0 is off and 1 is on !