Pin numbers

Development environment specific, Arduino, Eclipse, VS2013, Em::Blocks etc
Post Reply
mebab
Posts: 115
Joined: Mon Aug 24, 2020 12:42 pm
Answers: 4

Pin numbers

Post by mebab »

I have been using Nucleo L476 and I used Arduino-like pins to address Chip Select (CS) of peripherals. Now, I have developed a new board on STM32L476RG and in Arduino IDE I select:
Board: Nucleo 64 and then
Board Part number: Nucleo L476

I can program the new processor. However, it doesn't work as expected. I guess the pin numbers I have already used on Nucleo 64 are not fit correctly in the new board.
I used to write:

Code: Select all

const int CS_SD = 4; // on Nucleo 
What it should be on STM32L476 when it is connected to pin 57?

Many thanks
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Pin numbers

Post by fpiSTM »

First you should use generic L476RG because Nucleo have probably a specific clock config using HSE bypass.
About the pin number simply use the ST pin like PB6.
mebab
Posts: 115
Joined: Mon Aug 24, 2020 12:42 pm
Answers: 4

Re: Pin numbers

Post by mebab »

Thanks, fpiSTM.
First you should use generic L476RG because Nucleo have probably a specific clock config using HSE bypass.
About the pin number simply use the ST pin like PB6.
I did so. Again, I can upload the program via ST-Link just after I pull up Boot0 to Vcc. However, it cannot be executed. The reason might be HSE configuration as you mentioned.
Since I deal with ArduinoIDE, I don't know if I should use STM32CubeIDE to change HSE and LSE configurations to use Crystal (as is the case in my board) or I have to do it in some other ways?
mlundin
Posts: 94
Joined: Wed Nov 04, 2020 1:20 pm
Answers: 6
Location: Sweden

Re: Pin numbers

Post by mlundin »

Try a simple 1Hz blink in the loop, no serials or USB or tricky stuff. That will show if the loop is running and the clock frequency.

As for clocks, look in the variant.cpp file corresponding to your selected core/board/variant, its quite easy to see what clock and frequency is selected. If you board is different you can simply copy the clock setup code from another variant into your sketch and call it from setup(); If the crystal frequency is not default that migh have to be specified in "hal_conf_extra.h" for instance I use a 10MHz external Oscillator on a L432 and I have

Code: Select all

/* HAL Configuration */
#define  HSE_VALUE  10000000
mebab
Posts: 115
Joined: Mon Aug 24, 2020 12:42 pm
Answers: 4

Re: Pin numbers

Post by mebab »

Thanks mlundin. Helpful hints!
I have defined all pins in STM32CubeIDE and generated code, copied the relevant parts of 'main.cpp' in the 'variant_generic.cpp' file.
I am working on it to get a response and will reply as soon as I find the root cause. The main problem is that I use ST-Link and cannot debug the program effectively!
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Pin numbers

Post by fpiSTM »

No no no. Simply use the generic variant which uses the HSI.
Do not modify the variant files. If you want change the clock config redefine it at sketch level as described in the wiki:
https://github.com/stm32duino/wiki/wiki ... ock_config
mebab
Posts: 115
Joined: Mon Aug 24, 2020 12:42 pm
Answers: 4

Re: Pin numbers

Post by mebab »

Thanks a lot, fpiSTM and mlundin.

I just figured out that I have had another problem that was preventing the normal code operation. I fixed it as well and it works fine now. I am ready to apply your comments now.

Thanks again.
Post Reply

Return to “IDE's”