-2

I just started working with STM32F407VGT Discovery kit and I for the start I wanted to turn on/off LED's on-board. I am using CubeMX to generate initialization code and SystemWorkBench Eclipse to compile and also ST-LINK STM32 for programming my board. In CubeMX I initialized PD12-PD15 ports as output. I used function HAL_GPIO_WritePin to set my LED's ON. After compilation and programming to device, nothing happens... Please give me some advice what I did wrong.

int main(void)
{
  /* USER CODE BEGIN 1 */

  /* USER CODE END 1 */


  /* MCU Configuration--------------------------------------------------------*/

  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();

  /* USER CODE BEGIN Init */
  /* USER CODE END Init */

  /* Configure the system clock */
  SystemClock_Config();

  /* USER CODE BEGIN SysInit */

  /* USER CODE END SysInit */

  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  /* USER CODE BEGIN 2 */

  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
      HAL_GPIO_WritePin(GPIOD, GPIO_PIN_13, GPIO_PIN_SET); 
    /* USER CODE END WHILE */
    /* USER CODE BEGIN 3 */
  }
  /* USER CODE END 3 */
}

David
  • 1
  • 1
  • Did you verify, is that port / pin configured as digital output? – virolino Sep 17 '19 at 13:53
  • yes, I did it in CubeMX. Clicked on ex. PD12 port and set it as GPIO_Output – David Sep 17 '19 at 14:14
  • Did you check on the board datasheet that PD13 is indeed connected to the LED ? Sometimes CubeMX makes mistakes... – Guillaume Petitjean Sep 18 '19 at 08:29
  • Rather check the actual connections on the board itself with a multimeter. On the STM32H743-Nucleo2 board, 2 of 3 LEDs are indicated on the wrong pins in the CubeMX project, and at least one is indicated on the wrong pin in the user manual. While you're at that, you can as well check that pin is actually driven high when your program runs. – followed Monica to Codidact Sep 18 '19 at 14:01

1 Answers1

0

Problem solved! It seems that ST-LINK is not uploading hex correctly, I used AC6 to upload and everythig seem to work fine

David
  • 1
  • 1
  • Are yous sure ? I would be interested to get more details on that. – Guillaume Petitjean Sep 19 '19 at 10:27
  • So, after I generate code from CubeMX, then open project in AC6, build It and upload via ST-LINK, everything works correctly. Then I did some changes to code like toogling LED and built It and tried to upload via ST-LINK again and nothing happens on the board. But if I upload It via AC6, everything Is going good. Its really weird but I don't know what's wrong with it – David Sep 19 '19 at 12:17
  • what do you mean by "upload via AC6" ? Is there an AC6 jtag/swd probe ? – Guillaume Petitjean Sep 19 '19 at 12:25
  • I mean the green "Run" button next to Debug button in the top menu – David Sep 19 '19 at 12:39
  • @David: Did you by any chance forget to press the reset button on the board to activate the loaded program? –  Oct 09 '19 at 15:02