cancel
Showing results for 
Search instead for 
Did you mean: 

difference between _pin and _gpio_port

MJean.3
Associate III

In cubeMX, Il gave a user name 'led1_rouge' to PI1.

When I go to Keil microvision, intellisense gives me two names :

led1_rouge_pin

led1rouge_gpio_port

What is the difference between them ?

Jean

1 ACCEPTED SOLUTION

Accepted Solutions

Microcontrollers, since the beginning, have bundled their GPIO pins in groups. These groups, called ports, were originally external chips that would hang off of the address and data bus. When the proper address showed up, the chips would be selected and the data off of the data bus would get saved in these chips, being presented on their output pins. These chips could also be set up as inputs, then when selected, they would put their data onto the data bus.

In modern microcontrollers, these port chips have been incorporated into the processor die, but they still keep their historic structure. The processors now group GPIO pins in groups of 1 to 32 or more (some or all will be populated).

So a port is a group of I/O pins. The pin number will determine which pin within a group you are dealing with. On an STM32, you may have port A, B, C, and D (and others). Port A will have pins 0,1,2,3,4 (for instance), but port B will have pins 0,1,2,3,4 as well. But they are discrete, pin A1 is a different pin than pin B1. And pin A1 is different from pin A2.

In Cube, you gave your pin the name led1_rouge (for non-french speakers, that's LED1_RED). It is on a particular port and pin (say PORTA PIN6), but in your program you can use PORTA and PIN6 or you can use the symbols led1_rouge_pin and led1_rouge_gpio_port instead. That way a future reader of your code can understand that this is the port and pin that control le led rouge (le, la? is an LED masculine or feminine?) rather than having to go back to the schematic to figure out what is connected to A6.

Also, if you revise your board and move led rouge to pin E4, for instance, you regenerate your code from the cube model and you don't have to alter your code because, in main.h, led1_rouge_gpio_port will have been redefined as PORTE and led1_rouge_pin will be redefined as PIN4.

ça va?

View solution in original post

5 REPLIES 5

Hi MJean.3,

Can you share your .ioc file for further check ?

Thanks in advance,

Regards,

Khouloud.

MJean.3
Associate III

here it is ...

I asked the same question on keil forum but I haven't any answer yet.

Jean

Microcontrollers, since the beginning, have bundled their GPIO pins in groups. These groups, called ports, were originally external chips that would hang off of the address and data bus. When the proper address showed up, the chips would be selected and the data off of the data bus would get saved in these chips, being presented on their output pins. These chips could also be set up as inputs, then when selected, they would put their data onto the data bus.

In modern microcontrollers, these port chips have been incorporated into the processor die, but they still keep their historic structure. The processors now group GPIO pins in groups of 1 to 32 or more (some or all will be populated).

So a port is a group of I/O pins. The pin number will determine which pin within a group you are dealing with. On an STM32, you may have port A, B, C, and D (and others). Port A will have pins 0,1,2,3,4 (for instance), but port B will have pins 0,1,2,3,4 as well. But they are discrete, pin A1 is a different pin than pin B1. And pin A1 is different from pin A2.

In Cube, you gave your pin the name led1_rouge (for non-french speakers, that's LED1_RED). It is on a particular port and pin (say PORTA PIN6), but in your program you can use PORTA and PIN6 or you can use the symbols led1_rouge_pin and led1_rouge_gpio_port instead. That way a future reader of your code can understand that this is the port and pin that control le led rouge (le, la? is an LED masculine or feminine?) rather than having to go back to the schematic to figure out what is connected to A6.

Also, if you revise your board and move led rouge to pin E4, for instance, you regenerate your code from the cube model and you don't have to alter your code because, in main.h, led1_rouge_gpio_port will have been redefined as PORTE and led1_rouge_pin will be redefined as PIN4.

ça va?

MJean.3
Associate III

ça va très bien ! C'est une réponse très détaillée !!

et on dit une Led

merci beaucoup et bon week-end

Jean

As we say in Canada, pas du sweat.