Search code examples
cembeddedstm32nucleo

STM32F103RB - How to know what pin to use to send a trigger signal


First of all forgive me as I am a beginner in embedded systems.

I am using a Nucleo STM32F103RB. I am trying to send a trigger signal from my STM to a FPGA card, by setting a GPIO pin of my STM but I am unsure about which pin to connect.

This is the code I use to drive my GPIO:

HAL_GPIO_WritePin(Trigger_GPIO_Port, Trigger_Pin, GPIO_PIN_SET);
//do something
HAL_GPIO_WritePin(Trigger_GPIO_Port, Trigger_Pin, GPIO_PIN_RESET);

with Trigger_GPIO_Port and Trigger_Pin being defined as follows:

#define Trigger_Pin GPIO_PIN_2
#define Trigger_GPIO_Port GPIOB

By using STMCube32 software I had the following picture:

enter image description here

So, I connected the PC9 pin of my board as the trigger by basing myself off the picture STM32Cube gave me.

Am I wrong in doing that? This doesn't seem to work... How can I simply send a trigger from my board?

Thank you for your help!


Solution

  • Your CubeMX pinout suggests PC9, but your code:

    #define Trigger_Pin GPIO_PIN_2
    #define Trigger_GPIO_Port GPIOB
    

    clearly defines PB2 as in GPIO Port B pin 2.

    It looks like at some stage you have modified the CubeMX configuration but failed to re-generate the code. You should have:

    #define Trigger_Pin GPIO_PIN_9
    #define Trigger_GPIO_Port GPIOC
    

    Or simply connect PB2 - although if you want to keep your code and CubeMX in sync, I suggest you regenerate the code, especially if you have made other changes that also need to be included.

    In the Nucleo connector pin-out, the labels in blue correspond to the microcontroller pins. The magenta labels are the corresponding Arduino Shield pin names.