hey,,
>>i want to use usart-2 peripheral on MCBSTM32C and i realised the baud rate set was incorrect, (inspite of right calculations) which was because of the incorrect plck-1 (=112.5Mhz, which should be 36Mhz),, also plck-2 and hclk, system clock set are wrong.
>>for clock setup i'm using SystemInit function from system_stm32f10x_cl.c (i took this from keil's example program.)
>>so i tried running an example prog from keil on the board. i flashed Blinky_ULp into the board ,, but still the same problem of incorrect pclk-1, pclk-2, hclk, sysclk etc persisted,,
please help.. i cant understand why example codes work incorrectly !!!!!
Hey ,, thank you very much for ur response..
>>the exact problem i'm facing is that when i run the code into mcbstm32c, in hardware-debug mode the clock peripherals shows incorrect value for pclk1, pclk2, hclk, sysclk because of which my baud rate is not set correctly.
i m using uvision 4 .
>>my hse is enabled and set to 25Mhz
>>for clock initialisation i call SystemInit() from system_stm32f10x_cl.c and all my clock configuration settings are the same.
>>the same problem occurs when i burn keil's example code Blinky_ULp into it,, (incorrect hclk, pclk1, pclk2, sysclk)
>>in the abstract file of this program it says
Clock Settings: - XTAL = 25.00 MHz - PLL3 = (XTAL/5)*10 = 50.00 MHz - PLL2 = (XTAL/5)* 8 = 40.00 MHz - PLL1 = (PLL2/5)* 9 = 72.00 MHz - SYSCLK = PLL1 = 72.00 MHz - HCLK = SYSCLK = 72.00 MHz - PCLK1 = 36.00 Mhz - PCLK2 = 72.00 Mhz
>>whereas they are set as: (as shown in clock peripheral of jtag debugger) - XTAL = 25.00 MHz - PLL3 = not shown - PLL2 = not shown - PLL1 = not shown PLL = 225Mhz - SYSCLK = PLL1 = 225.00 MHz - HCLK = SYSCLK = 225.00 MHz PCLK1 = 112.5 Mhz PCLK2 = 225 Mhz
/*---------------------------------------------------------------------------- * Name: Blinky.c * Purpose: LED Flasher for MCBSTM32E * Note(s): *---------------------------------------------------------------------------- * This file is part of the uVision/ARM development tools. * This software may only be used under the terms of a valid, current, * end user licence from KEIL for a compatible version of KEIL software * development tools. Nothing else gives you the right to use this software. * * This software is supplied "AS IS" without warranties of any kind. * * Copyright (c) 2009 Keil - An ARM Company. All rights reserved. *----------------------------------------------------------------------------*/ #include <stdio.h> #include <stm32f10x_cl.h> #define LED_NUM 8 /* Number of user LEDs */ const unsigned long led_mask[] = { 1UL<<15, 1UL<<14, 1UL<<13, 1UL<<12, 1UL<<11, 1UL<<10, 1UL<< 9, 1UL<< 8 }; /* Import external functions from Serial.c file */ extern void SER_init (void); /* Import external variables from IRQ.c file */ extern volatile unsigned short AD_last; extern volatile unsigned char clock_1s; /* variable to trace in LogicAnalyzer (should not read to often) */ volatile unsigned short AD_dbg; /*---------------------------------------------------------------------------- Function that initializes ADC *----------------------------------------------------------------------------*/ void ADC_init (void) { RCC->APB2ENR |= (1<<4); /* enable periperal clock for GPIOC */ GPIOC->CRL &= ~0x000F0000; /* Configure PC4 as ADC.14 input */ RCC->APB2ENR |= (1<<9); /* enable periperal clock for ADC1 */ ADC1->SQR1 = 0x00000000; /* Regular channel 1 conversion */ ADC1->SQR2 = 0x00000000; /* Clear register */ ADC1->SQR3 = (14<< 0); /* SQ1 = channel 14 */ ADC1->SMPR1 = ( 5<<12); /* sample time channel 14 55,5 cycles */ ADC1->CR1 = (1 << 8) | /* Scan mode on */ (1 << 5) ; /* EOC interrupt enable */ ADC1->CR2 = (1 << 20) | /* Enable external trigger */ (7 << 17) | /* EXTSEL = SWSTART */ (1 << 0) ; /* ADC enable */ ADC1->CR2 |= (1 << 3); /* Reset calibration */ while (ADC1->CR2 & (1 << 3)); /* wait unil reset finished */ ADC1->CR2 |= (1 << 2); /* start calibration */ while (ADC1->CR2 & (1 << 2)); /* wait unil calibration finished */ NVIC_EnableIRQ(ADC_IRQn); /* enable ADC Interrupt */ } /*---------------------------------------------------------------------------- Function that initializes LEDs *----------------------------------------------------------------------------*/ void LED_init(void) { RCC->APB2ENR |= (1<<6); /* Enable GPIOE clock */ GPIOE->CRH = 0x33333333; /* Configure the GPIO for LEDs */ } /*---------------------------------------------------------------------------- Function that turns on requested LED *----------------------------------------------------------------------------*/ void LED_On (unsigned int num) { GPIOE->BSRR = led_mask[num]; } /*---------------------------------------------------------------------------- Function that turns off requested LED *----------------------------------------------------------------------------*/ void LED_Off (unsigned int num) { GPIOE->BRR = led_mask[num]; } /*---------------------------------------------------------------------------- Function that outputs value to LEDs *----------------------------------------------------------------------------*/ void LED_Out(unsigned int value) { int i; for (i = 0; i < LED_NUM; i++) { if (value & (1<<i)) { LED_On (i); } else { LED_Off(i); } } } /*---------------------------------------------------------------------------- MAIN function *----------------------------------------------------------------------------*/ int main (void) { /* Main Program */ short AD_value, AD_print; SystemInit(); SysTick_Config(SystemFrequency/100); /* Generate interrupt each 10 ms */ LED_init(); /* LED Initialization */ SER_init(); /* UART#1 Initialization */ ADC_init(); /* ADC Initialization */ while (1) { /* Loop forever */ if (AD_value != AD_last) { /* Make sure that AD interrupt did */ AD_value = AD_last; /* not interfere with value reading */ AD_dbg = AD_value; } AD_print = AD_value; /* Get unscaled value for printout */ if (clock_1s) { clock_1s = 0; printf ("AD value = 0x%03x\n\r", AD_print); } } }
I was actually thinking about the PLL, but never mind, I can review the original source in my tree.
Can you confirm the physical values in RCC CFGR/CFGR2/CR? Or the clocks via the MCO pin?
Perhaps the decoder is the issue and not the one for a 105/107 series part, but rather a 100/103
hey,, how do i check physical value of the registers rcc_cr, cngf, cngf2 ??
and yes,, i can check mco,, i will do that and reply here in the morning,,
thank you for your response. :)
Place a Memory View window over the RCC register space.