when boot0 pin low mode my timer program works fine and get correct delay but after the reset the timer not working and no blink led what are the reasons?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-08-02 5: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;
}
- Labels:
-
STM32F4 Series
-
TIM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-08-02 6: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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-08-02 8:14 PM
My problem is when uploaded my led blink+ timer code​ which is working fine.but I reconnected that board or reset the board the delay not showing the led constantly turn on. Look at when I upload the code I press button of the boot0 pin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-08-02 8:42 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-08-03 12:22 AM
I have mentioned the boot configuration details here.
Consider situation 1,I uploaded the program into mcu through boot from
fash memory.
Consider situation 2,I uploaded the program into mcu through boot from
system memory.
My doubt is the both programming method store the program on the same
memory location or different location?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-08-03 7: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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-08-05 3:36 AM
I will give you two different situations?
1st.i uploaded my cobe on stm32 through system Boot loader method.
2nd .I uploaded my code on stm32 through flash memory boot mode.
My doubt is both methods store the main code in same memory block or another?
For example
System memory booting stored main code in 0x8000000.such as flash memory stored in 0x 8000000.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-08-05 4: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.
​
D​o you work with anyone more experienced who can help you with all these doubts, or help you review documentation, or provide appropriate training?
Up vote any posts that you find helpful, it shows what's working..
