2
\$\begingroup\$

I am trying to make a project with NUCLEO-H563ZI in μVision5, starting simple with opening the embedded LED on the board.

main.c:

#include "stm32h5xx.h"                  // Device header
#include "stm32h563xx.h"
#include "stdint.h"
#include "stdio.h"

static void GPIOConfig (void);
void SysClockConfig (void);



void SysClockConfig (void)
{
    

    
    RCC->CR |= RCC_CR_HSEON;  
    while (!(RCC->CR & RCC_CR_HSERDY));
    
    
    RCC->AHB1ENR |=  1<<28; //RCC_APB1ENR_PWREN;  
    ADC1->CR |= ADC_CR_ADVREGEN; 
    
    
    
    FLASH->ACR =  FLASH_ACR_WRHIGHFREQ | FLASH_ACR_PRFTEN | FLASH_ACR_LATENCY_5WS;
    
    
    RCC->CFGR2 |= RCC_CFGR2_HPRE | RCC_CFGR2_PPRE1 | RCC_CFGR2_PPRE2;   //_DIV1;
    
    (RCC_PLL1CFGR_PLL1SRC_HSE);

    RCC->PLL1CFGR |=  RCC_PLL1CFGR_PLL1SRC; //_HSE;

    
    RCC->CR |= RCC_CR_PLL1ON;
    while (!(RCC->CR & RCC_CR_PLL1RDY));
    
    
    RCC->CFGR1 |= RCC_CFGR1_SWS;
    while ((RCC->CFGR1 & RCC_CFGR1_SW));
}


static void GPIOConfig (void)
{

    RCC->AHB2ENR |= (1<<6);
    GPIOG->PUPDR &= ~(1<<9);
    GPIOG->MODER &= ~((1<<8) | (1<<9));
    GPIOG->MODER |= (1<<8);
    GPIOG->OTYPER &= ~(1<<4);
    GPIOG->OSPEEDR &= ~((1<<8) | (1<<9));

}


int main(void)
{
    SysClockConfig ();
    GPIOConfig();
    
    GPIOG -> BRR   = 1<<4;
    GPIOG -> BSRR  = 1<<4;
    while (1)
      {


      }

}           

For those wandering I am using μVision5 is because I want to be able to configure the MCU with registers alone for future projects.

For this application I managed to make it compile where I had to change these configurations

enter image description here enter image description here enter image description here enter image description here

After compiling I tried flashing the memory and as far I understand it was successful.

enter image description here

So I can't figure out why the LED is not switching on, when I used similar code in the STM32CubeIDE it worked.

That's what I see on the debugging end:

enter image description here

\$\endgroup\$
5
  • 3
    \$\begingroup\$ You are programming the MCU through a debugger. Have you debugged what the problem is, what code is executed and what isn't? \$\endgroup\$
    – Justme
    Commented Apr 24 at 12:23
  • \$\begingroup\$ I am gonna edit the question \$\endgroup\$
    – George P.
    Commented Apr 24 at 12:30
  • \$\begingroup\$ Also I don't see how you "want to be able to configure the MCU with registers alone" depends on any IDE. Just code, compile and upload, using any tools you want. Nobody forces you to configure the MCU with the CubeMX GUI code generator. Create an empty non-cubeMX project. \$\endgroup\$
    – Justme
    Commented Apr 24 at 12:47
  • \$\begingroup\$ I am aware I can and have done so, but the whole point is to have to use as little libraries as possible, and be able to configure it (if possible) almost entirely using the registers directly, thank you. \$\endgroup\$
    – George P.
    Commented Apr 24 at 13:30
  • 1
    \$\begingroup\$ When you download/start the program in the debugger, does the execution reach a breakpoint at main()? If so, then step through to see where the execution stops behaving as you expect. If not, then have you included into your project startup files for the run-time environment, such as startup_stm32h563xx.s and system_stm32h5xx.c? If so then set a breakpoint where the startup code calls SystemInit() and see if you can get to and step from there. \$\endgroup\$
    – kkrambo
    Commented Apr 25 at 10:45

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.