2021-08-02 05:37 PM
boot from flash
Board:Stm32f401ccu6 black phill
these are my upload status
STMicroelectronics ST-LINK GDB server. Version 5.8.0
Copyright (c) 2020, STMicroelectronics. All rights reserved.
Starting server with the following options:
Persistent Mode : Disabled
Logging Level : 1
Listen Port Number : 61234
Status Refresh Delay : 15s
Verbose Mode : Disabled
SWD Debug : Enabled
Waiting for debugger connection...
Debugger connected
-------------------------------------------------------------------
STM32CubeProgrammer v2.7.0-RC1
-------------------------------------------------------------------
ST-LINK SN : 152719002C135737334D4E00
ST-LINK FW : V2J37S7
Board : --
Voltage : 3.22V
SWD freq : 4000 KHz
Connect mode: Under Reset
Reset mode : Hardware reset
Device ID : 0x423
Revision ID : --
Device name : STM32F401xB/C
Flash size : 256 KBytes
Device type : MCU
Device CPU : Cortex-M4
Memory Programming ...
Opening and parsing file: ST-LINK_GDB_server_a05628.srec
File : ST-LINK_GDB_server_a05628.srec
Size : 1256 Bytes
Address : 0x08000000
Erasing memory corresponding to segment 0:
Erasing internal memory sector 0
Download in Progress:
File download complete
Time elapsed during download operation: 00:00:00.332
Verifying ...
Download verified successfully
Debugger connection lost.
Shutting down...
my code
#include "stm32f4xx.h"
#define PLLM 25
#define PLLN 320
#define PLLP 1//divide 4
int clock_80MHz_Ex_pll();
int pinMode();
void InitTIM2();
void Delay_us();
void Delay_ms(int x);
int clock_80MHz_Ex_pll()
{
RCC->CR|=RCC_CR_HSEON;//External Crystal Oscillator
while(!(RCC->CR & RCC_CR_HSERDY));// External Crystal oscillator status flag checking
RCC->APB1ENR|=RCC_APB1ENR_PWREN;// power Enable
PWR->CR|=PWR_CR_VOS;// voltage scaling
FLASH->ACR|=(FLASH_ACR_DCEN|FLASH_ACR_ICEN|FLASH_ACR_PRFTEN|FLASH_ACR_LATENCY_2WS);
RCC->CFGR|=(RCC_CFGR_PPRE2_DIV1|RCC_CFGR_PPRE1_DIV2|RCC_CFGR_HPRE_DIV1);
RCC->PLLCFGR|=(PLLM<<0|PLLN<<6|PLLP<<16|1<<22);
RCC->CR|=RCC_CR_PLLON;
while(!(RCC->CR & RCC_CR_PLLRDY));
RCC->CFGR|=RCC_CFGR_SW_PLL;
while(!(RCC->CFGR & RCC_CFGR_SWS_PLL));
return 1;
}
int pinMode()
{
RCC->AHB1ENR|=RCC_AHB1ENR_GPIOCEN;
GPIOC->MODER|=0x55555555;
GPIOC->OTYPER=0;
GPIOC->OSPEEDR=0;
return 0;
}
void InitTIM2()
{
RCC->APB1ENR|=(1<<0);//Enable timer 2
TIM2->PSC =80+1;
TIM2->ARR=0xFFFF;
TIM2->CR1 |=(1<<0);
}
void Delay_us()
{
TIM2->CNT=0;
while(TIM2->CNT < 1000);
}
void Delay_ms(int x)
{
for(int i=0;i<x;i++){
Delay_us();}
}
int main()
{
clock_80MHz_Ex_pll();
pinMode();
InitTIM2();
while(1){
GPIOC->ODR=(1<<13);
Delay_ms(1000);
GPIOC->ODR=~(1<<13);
Delay_ms(1000);
}
return 0;
}
2021-08-02 06:51 PM
> TIM2->PSC =80+1;
> TIM2->ARR=0xFFFF;
If your timer clock is 80 MHz, your timer ticks at a rate of 1 tick per 1.025us (80 MHz / 82).
Because of this, your delay_us() will wait for 1 ms (technically 1.025ms, plus overhead). And your delay_ms(1000) will wait for 1000 seconds.
If you want 1 timer tick per us, PSC should be 79.
2021-08-02 08:14 PM
2021-08-02 08:42 PM
2021-08-03 12:22 AM
2021-08-03 07:06 AM
How are you doing the uploads exactly? STM32CubeIDE?
Generally things upload to the start of flash memory by default, although this is a choice.
You can use STM32CubeProgrammer to verify the content of the flash.
2021-08-05 03:36 AM
2021-08-05 04:14 AM
Can't you look at whatever code you're running in the second case.
For the ROM based system loader you pass the address as part of the protocol. The host application usually infers this from the addresses in the .HEX or .ELF file, or you input via the user interface. The linker builds these object files based on addresses you furnish.
Do you work with anyone more experienced who can help you with all these doubts, or help you review documentation, or provide appropriate training?