How to adjust pinouts for new boards

Post here first, or if you can't find a relevant section!
Post Reply
cagz
Posts: 6
Joined: Thu Aug 03, 2023 12:26 pm

How to adjust pinouts for new boards

Post by cagz »

I am developing a new variant using STM32L052K6T6, there are no existing variants for L0 family so I concluded that I had to create my own. Copied over F103 variant_BLUEPILL_F103C6.cpp and variant_BLUEPILL_F103C6.h over and preparing to adapt it to my board. This is where the confusion settled in !

variant_BLUEPILL_F103C6.h:

Code: Select all

#define PB9                     0
#define PB8                     1
#define PB7                     2
...
What are these numbers 0,1,2 ? It is not surely PIN 0 on the chip as there is no PIN 0, so what does this mapping represent ?

Code: Select all

#define PC14                    18
#define PC15                    19
#define PA0                     PIN_A0
#define PA1                     PIN_A1
#define PA2                     PIN_A2
#define PA3                     PIN_A3
Why these PAx ones are different ? What are they doing ?

Code: Select all

#define PB0_ALT1                (PB0  | ALT1)
#define PB0_ALT2                (PB0  | ALT2)
#define PB1_ALT1                (PB1  | ALT1)
I suppose these are setting alternate functions for those pins, but what are ALT1 / ALT2, how to set them for my board ?

variant_BLUEPILL_F103C6.cpp:

Code: Select all

const PinName digitalPin[] = {
  /* USB connector on the top, MCU side */
  /* Left Side */
  PB_9,  //D0
  PB_8,  //D1
  PB_7,  //D2
  PB_6,  //D3
What is the intention here, this array is filled in the order pins are placed on the actual PCB, but I cannot tell the use for them. PB9 is the zeroth element of this array, so is that 0 matching the 0 in .h file ?

Is there a document I can read ? Or otherwise there are references to a "genpinmap" utility, but I couldn't find it, seems like it has been deprecated.

I appreciate if someone can offer me a starting point.
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: How to adjust pinouts for new boards

Post by fpiSTM »

cagz wrote: Mon Aug 14, 2023 11:34 am

Code: Select all

#define PB9                     0
#define PB8                     1
#define PB7                     2
...
What are these numbers 0,1,2 ? It is not surely PIN 0 on the chip as there is no PIN 0, so what does this mapping represent ?
This is the pin bumber: 0 is equivalent to D0 (Arduino naming), it is used as index for the digital pin array to get the pinName.

cagz wrote: Mon Aug 14, 2023 11:34 am

Code: Select all

#define PC14                    18
#define PC15                    19
#define PA0                     PIN_A0
#define PA1                     PIN_A1
#define PA2                     PIN_A2
#define PA3                     PIN_A3
Why these PAx ones are different ? What are they doing ?
PIN_Ax are digital pins with analog capabilities. It allows to know that this pin has analog capabilities.

cagz wrote: Mon Aug 14, 2023 11:34 am

Code: Select all

#define PB0_ALT1                (PB0  | ALT1)
#define PB0_ALT2                (PB0  | ALT2)
#define PB1_ALT1                (PB1  | ALT1)
I suppose these are setting alternate functions for those pins, but what are ALT1 / ALT2, how to set them for my board ?
There is no link with Alternate Function.
It is used to get the Alternate peripheral of a GPI. Like same pin can have several IP instance ex: USART1 and USART2, using this notation allows to use the required instance.
cagz wrote: Mon Aug 14, 2023 11:34 am variant_BLUEPILL_F103C6.cpp:

Code: Select all

const PinName digitalPin[] = {
  /* USB connector on the top, MCU side */
  /* Left Side */
  PB_9,  //D0
  PB_8,  //D1
  PB_7,  //D2
  PB_6,  //D3
What is the intention here, this array is filled in the order pins are placed on the actual PCB, but I cannot tell the use for them. PB9 is the zeroth element of this array, so is that 0 matching the 0 in .h file ?
As stated below, yes this is the index.


cagz wrote: Mon Aug 14, 2023 11:34 am Is there a document I can read ? Or otherwise there are references to a "genpinmap" utility, but I couldn't find it, seems like it has been deprecated.
Yes genpinmap is deprected since a while. Now, all generic variants are generated for all MCU. End user do not have to bother with this.
juiweasley
Posts: 1
Joined: Tue Sep 12, 2023 8:12 am

Re: How to adjust pinouts for new boards

Post by juiweasley »

What can I do when the code does not compile and it marks "file does not exist" Do you have an answer to that?
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: How to adjust pinouts for new boards

Post by fpiSTM »

Which file does not exist?
Post Reply

Return to “General discussion”