We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi,
in MDK 3.40 Xtal is <undefined>.How can I solve this problem?
XTAL is a virtual register in the µVision simulator that specifies the external clock in MHz. This register is only available if you use our old/deprecated simulator. This knowledgebase article explains how to select this simulator:https://developer.arm.com/documentation/ka002225/latest/XTAL is not supported if you use a Fast Model of Fixed Virtual Platform (FVP) within uVision.
What do you want to do?
I want to define STM32F103C8 external clock. It is undefined which is why STM32 is not working correctly.
I still don't know what is not working correctly.
Please remember that XTAL is a virtual register in the µVision simulator. It has no influence on your code and therefore your application.
Dear Hans,
Please see the attached photo. My problem is I want to define my clock frequency in keil uvision but Keil doesn't let me, it shows <undefined>. For example, I write simple blink code, if I can't choose xtal frequency, it doesn't work correctly. Is there an alternative for choosing xtal frequency in keil uvision? I put the code below.
I want to blink my LED in 1 second.
#include "stm32f10x.h" // Device header
void delay(int rep);
int main(void){ RCC->APB2ENR |= 0x10; /// Or 0b10000 --> Anabling Preiph GPIOC GPIOC->CRH &= 0xFF0FFFFF; /// Reset the PORT C PIN 13 GPIOC->CRH |= 0x00300000; /// Set Port C PIN 13 as Output GPIOC->ODR |= 0x2000; /// Set Port C Pin 13 while(1) { /// Blinking the Port C pin 13 GPIOC->ODR |= 0x2000; delay(10); GPIOC->ODR &= ~0x2000; delay(10); }
}
/// Random time delay Functionvoid delay(int rep){ for(;rep>0;rep--) { int i; for(i=0; i< 100000;i++) {} }}
The definition provided above is not crucial, as you can configure it directly in your code.
This configuration is specifically for the STM32F103C8 microcontroller, utilizing an 8 MHz external clock and setting the system frequency to 36 MHz. Please note that this information is based on my previous code, which I have copied here for reference.
void CLOCK(void){ RCC_DeInit(); RCC_LSICmd(ENABLE); while(RCC_GetFlagStatus(RCC_FLAG_LSIRDY) == SET); RCC_HSEConfig(RCC_HSE_ON); while(RCC_WaitForHSEStartUp() != SUCCESS){} FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable); FLASH_SetLatency(FLASH_Latency_2); RCC_HCLKConfig(RCC_SYSCLK_Div1); RCC_PCLK1Config(RCC_HCLK_Div2); RCC_PCLK2Config(RCC_HCLK_Div1); RCC_PLLCmd(DISABLE); RCC_PLLConfig(RCC_PLLSource_HSE_Div2,RCC_PLLMul_12); RCC_PLLCmd(ENABLE); while(RCC_GetFlagStatus( RCC_FLAG_PLLRDY)!=SET); RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK); while (RCC_GetSYSCLKSource() != 0x08){} FLASH_SetLatency(FLASH_Latency_1); }
As mentioned already:
Hans Schneebauer said:Please remember that XTAL is a virtual register in the µVision simulator. It has no influence on your code and therefore your application
You need to define the clock-tree setup in your application. I suggest using STCube to do that. Please see our examples how to do that.