Help me find a problem? Trying to program the pin G0, just to burn. I write the program in sublime-text, compile it with arm-toolchain, I sew up the program on STM32F746IG via Flash Loader Demonstrator from STM32. I check the pin with a multimeter, there is no signal. What could be the problem?

.equ RCC, 0x40023800 .equ RCC_CR, 0x40023800 .equ RCC_PLLCFGR, 0x40023804 .equ RCC_CFGR, 0x40023808 .equ RCC_CIR, 0x4002380C .equ RCC_AHB1RSTR, 0x40023810 .equ RCC_AHB2RSTR, 0x40023814 .equ RCC_AHB3RSTR, 0x40023818 .equ RCC_APB1RSTR, 0x40023820 .equ RCC_APB2RSTR, 0x40023824 .equ RCC_AHB1ENR, 0x40023830 .equ RCC_AHB2ENR, 0x40023834 .equ RCC_AHB3ENR, 0x40023838 .equ RCC_APB1ENR, 0x40023840 .equ RCC_APB2ENR, 0x40023844 .equ GPIOG, 0x40021800 .equ GPIOG_MODER, 0x40021800 .equ GPIOG_OTYPER, 0x40021804 .equ GPIOG_OSPEEDR, 0x40021808 .equ GPIOG_PUPDR, 0x4002180C .equ GPIOG_IDR, 0x40021810 .equ GPIOG_ODR, 0x40021814 .equ GPIOG_BSRR, 0x40021818 .equ GPIOG_LCKR, 0x4002181C .equ GPIOG_AFRL, 0x40021820 .equ GPIOG_AFRH, 0x40021824 .syntax unified .thumb .cpu cortex-m7 .section .text .word 0x20060000 .word reset+1 .word main+1 .word loop+1 reset: b main main: LDR R0, =0x40 LDR R1, =RCC_AHB1ENR STR R0, [R1] LDR R0, =0x01 LDR R1, =GPIOG_MODER STR R0, [R1] LDR R0, =0x00 LDR R1, =GPIOG_OTYPER STR R0, [R1] LDR R0, =0x00 LDR R1, =GPIOG_OSPEEDR STR R0, [R1] LDR R0, =0x00 LDR R1, =GPIOG_PUPDR STR R0, [R1] LDR R0, =0x01 LDR R1, =GPIOG_ODR STR R0, [R1] loop: b loop .end 

But the linker code

 MEMORY { FLASH(RX) : ORIGIN = 0x00000000, LENGTH = 0x100000 SRAM(WAIL) : ORIGIN = 0x20010000, LENGTH = 0x50000 } SECTIONS { .text : { KEEP(*(.text)); } > FLASH } 

    1 answer 1

    You have a number of errors related to the fact that you may have tried to take ready-made code intended for another device and adapt it to your controller.

    First, let's look at the linker script. It incorrectly indicated the addresses of flash-memory and RAM. Flash-memory should have the address 0x08000000 , the RAM should have the address 0x20000000 . For the available length of memory regions, check the documentation for your controller. At the designated address 0x00000000 in the microcontrollers of the stm32 family, there is a boot ROM in which the code for servicing the subsystems of the controller itself is stored, and it is not available for modification by the user.

    Now look at your code. According to ABI, at the beginning of the executable file there should be a table of interrupt vectors and you have it, but not quite correct.

     .word 0x20060000 ;Stack pointer .word reset+1 ;Reset handler .word main+1 ;NMI handler .word loop+1 ;HardFault handler 

    In the first place should be a stack pointer. The stack pointer must be a valid in-memory address. You wrote the address 0x20060000 , which, judging by your code of the linker, is outside the available area of ​​RAM. Usually, the last available machine word is assigned to the stack pointer, and when using the stack it will grow downwards. That is, you can specify the address 0x2004fffc , of course, if you specified the size of the RAM of the controller, and it really is 0x50000 . The other interrupt handler pointers are written correctly, but it would be better to register the NMI handler at reset+1 .

    Now look at the executable code itself. The process of writing values ​​to the peripheral registers takes place correctly, but I did not check their contents. Here you need a long time to deal with the documentation. I advise you, first, to verify with the documentation the addresses of all peripheral registers, and secondly, to clarify whether you write down the correct values ​​in them.

    UPD: judging by the fact that you have errors in the memory addresses of the linker script, I would advise you to check in the settings of the programmer whether you really write the program at 0x08000000 .

    • Thank you for your reply! Time will be rechecked and rewrite the code, and thanks so much! - Daniil