SOLVED!STM32F469: try to blink without use HAL/LL(only register). but HALTED...? - Page 1
Forum section: electronics / general

author: squadchannel
author_rank: Frequent Contributor
timestamp: December 19, 2024, 02:04:14 pm
content: I decided to play around with STM32 without using HAL (CubeMX).yes, I could blink with the internal HSI clock, so tried to input the HSI clock to the PLL to speed up the process, but it did not work.When I debugged it,"Break at address “0x0” with no debug information available, or outside of program code."Something seems to be happening.try again, change to the external HSE clock, but at a randomly(I did a Step Into)."Break at address “0x4b166012” with no debug information available, or outside of program code."dasm window:"4b166012: Failed to execute MI command: -data-disassemble-data-disassemble -s 1259757586 -e 1259757715 -- 3Error message from debugger back end: “Cannot access memory at address 0x0x2000.Cannot access memory at address 0x4b166012"What is going on!registers seem to be set correctly in the SFR window.The problem apparently occurs when the SYSCLK exceeds 48 MHz.Perhaps the other ICs on the Discovery board are affecting it?HSE = 8MHz.PLL PLLM = 8 (PLL input freq = 8/8=1MHz)PLL PLLN = 100 (PLL multiply freq = 1*100=100MHz)PLL PLLP = 2(0b00) (PLL main div freq = 100/2=50MHz)PLL PLLP = 2(0b00) (PLL main div freq = 100/2=50MHz)PLL is also locked (flagged), SWS register is also flagged, set the port for blink...HALTED!. Why?Do I need to set any registers yet?(SYSCLK has been checked with MCO1 output. Properly 50MHz.)Code:#define STM32F469xx#define __SOFT_FP__#include <stdint.h>#include <stm32f4xx.h>void delay(int delay_seconds);int main(void){//init clock//MCC1 outputRCC->AHB1ENR |= (0b1 << 0);//GPIOA clock enableGPIOA->MODER |= (0b10 << 16);//set alternate modeGPIOA->OTYPER |= (0b0 << 8);//set push-pull modeGPIOA->OSPEEDR |= (0b11 << 16);//set high speed modeGPIOA->PUPDR |= (0b00 << 16);//set without pullup/down//set HS External clock sourceRCC->CR |= (0b1 << 16);//wait to HSE clock is readywhile(!(RCC->CR & (0b1 << 17)));//set system clock source is HSERCC->CFGR |= (0b01 << 0);//wait to set clock sourcewhile(!(RCC->CFGR & (0b01 << 2)));//disable HS Internal clock sourceRCC->CR &= ~(0b1 << 0);//wait to HSI clock is disabledwhile(RCC->CR & (0b1 << 1));//set power scale 1PWR->CR |= (0b11 << 14);//set pll configRCC->PLLCFGR = (0b111 << 28) | (0b0100 << 24) | (0b1 << 22) | (0b00 << 16) | (100 << 6) | (8 << 0);RCC->CR |= (0b01 << 24);//wait to lock pllwhile(!(RCC->CR & (0b1 << 25)));RCC->CFGR = (0b11 << 21) | (0b110 << 13) | (0b110 << 10) | (0b10 << 0);//wait to set clock sourcewhile(!(RCC->CFGR & (0b10 << 2)));//init blink portRCC->AHB1ENR |= (0b1 << 6);//GPIOG clock enableGPIOG->MODER |= (0b01 << 12);//set output modeGPIOG->OTYPER |= (0b1 << 6);//set push-pull modeGPIOG->OSPEEDR |= (0b00 << 12);//set low speed modeGPIOG->PUPDR |= (0b00 << 12);//set without pullup/down modewhile(1){GPIOG->ODR |= (0b1 << 6);delay(1);GPIOG->ODR &= ~(0b1 << 6);delay(1);}}void delay(int delay_seconds){for(int i=0; i<delay_seconds; i++){int j=0;for(; j<1000000; j++);}}

author: squadchannel
author_rank: Frequent Contributor
timestamp: December 19, 2024, 04:21:30 pm
content: Other STM32s I have, blinkedSTM32G0B1RE(nucleo)Code:#define __SOFT_FP__#define STM32G0B1xx#include <stdint.h>#include <stm32g0xx.h>void delay(int delay_seconds);int main(void){//set pllRCC->PLLCFGR |= (0b001 << 29) | (0b1 << 28) | (0b0 << 24) | (0b0 << 16) | (20 << 8) | (4 << 4) | (0b10 << 0);RCC->CR |= (0b1 << 24);//wait to pll is readywhile(!(RCC->CR & (0b1 << 25)));RCC->CFGR = (0b010 << 0);while(!(RCC->CFGR & 0b010));//set led portRCC->IOPENR |= (0b1 << 0);GPIOA->MODER &= ~(0b10 << 10);GPIOA->OTYPER |= (0b0 << 5);GPIOA->OSPEEDR |= (0b01 << 10);GPIOA->PUPDR |= (0b00 << 10);/* Loop forever */while(1){GPIOA->ODR |= (0b1 << 5);delay(1);GPIOA->ODR &= ~(0b1 << 5);delay(1);}}void delay(int delay_seconds){for(int i=0; i<delay_seconds; i++){for(int j=0; j<1000; j++);}}think about it again tomorrow.

author: wek
author_rank: Frequent Contributor
timestamp: December 20, 2024, 08:33:32 am
content: You have toset FLASH waitstatesbefore switching to a higher frequency clock.JW

author: squadchannel
author_rank: Frequent Contributor
timestamp: December 20, 2024, 09:18:32 am
content: I found it a few hours ago too. Let's do it.https://electronics.stackexchange.com/questions/509231/why-the-program-does-not-work-when-i-enable-pll-on-stm32f4

author: squadchannel
author_rank: Frequent Contributor
timestamp: December 20, 2024, 09:44:03 am
content: Gocha! it works!thanks, wek!