2020-06-19 04:48 AM
I have MCU STM32F103VET6, the microcontroller is clocked from HSI (internal 8MHz oscillator).
Bun the frequency at the MCO pin is 6.4MHz. Why?
I have the same MCU bought years ago, with the same code the frequency is correct - 8MHz.
Here is my code:
void SystemInit (void)
{
// Set HSION bit */
RCC->CR |= (uint32_t)0x00000001;
// Reset SW, HPRE, PPRE1, PPRE2, ADCPRE and MCO bits
RCC->CFGR &= (uint32_t)0xF8FF0000;
// Reset HSEON, CSSON and PLLON bits
RCC->CR &= (uint32_t)0xFEF6FFFF;
// Reset HSEBYP bit
RCC->CR &= (uint32_t)0xFFFBFFFF;
// Reset PLLSRC, PLLXTPRE, PLLMUL and USBPRE/OTGFSPRE bits
RCC->CFGR &= (uint32_t)0xFF80FFFF;
// Disable all interrupts and clear pending bits
RCC->CIR = 0x009F0000;
SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET;
}
2020-06-19 06:15 AM
Where do you enable MCO?
2020-06-19 07:19 AM
void main () {
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);
while(1) ;
}
2020-06-19 10:53 AM
In these days, when it comes to 'F103, the first question is, where do you have them from/aren't they counterfeit (I know it's more likely the 'F103C8, but still).
What happens if you replace the whole SystemInit() by an empty function?
What's the value of RCC->CR, namely the HSICAL/HSITRIM fields?
JW