2015-10-15 02:52 AM
Hi.I'm using 6MHz external crystal for STM32F0 instead of 8MHz.Following standard setup,i have successfully clocked the APB & AHB at 48MHz via PLL with the following modification on the code pasted below:
/* PLL configuration = HSE * 8 = 48 MHz */
RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_PLLSRC | RCC_CFGR_PLLXTPRE | RCC_CFGR_PLLMULL));
RCC->CFGR |= (uint32_t)(RCC_CFGR_PLLSRC_PREDIV1 | RCC_CFGR_PLLXTPRE_PREDIV1 | RCC_CFGR_PLLMULL8);
Do i need to alter more in other part?I doubt this is causing UART framing error although i use this code:
int main(void)
{
USART_InitTypeDef USART_InitStructure;
GPIO_InitTypeDef GPIO_InitStructure;
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1,ENABLE);
GPIO_PinAFConfig(GPIOA, GPIO_PinSource9, GPIO_AF_1);
GPIO_PinAFConfig(GPIOA, GPIO_PinSource10, GPIO_AF_1);
/* Configure USART1 pins: Rx and Tx ----------------------------*/
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9 | GPIO_Pin_10;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(GPIOA, &GPIO_InitStructure);
USART_InitStructure.USART_BaudRate = 9600;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_Parity = USART_Parity_No;
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
USART_Init(USART1, &USART_InitStructure);
USART_Cmd(USART1,ENABLE);
while(1)
{
while(USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET);
USART_SendData(USART1, 'X');
}
}
What could be wrong again?
2015-10-15 05:34 AM
Do you have HSE_VALUE defined in your system? Does its value match the crystal?
2015-10-15 06:44 PM
Hi John,
Yup.Found and altered the HSE constant in 32f0xx.h. Sorry.I'm a newbie in ARM.Do i need to alter this as well?/* HSE oscillator clock selected as PREDIV1 clock entry */
SystemCoreClock = (HSE_VALUE / prediv1factor) * pllmull;
Thanks.
2015-10-15 07:04 PM
No, it's a define usually passed in the compiler command line (see C compiler settings, or makefile), or in the stm32f0xx_conf.h file related to the project.
ie -DHSE_VALUE=6000000 or #define HSE_VALUE 60000002015-10-15 07:53 PM
Hi Clive,
There's not such definition in mentioned file.Searched everywhere. I'm using CooCoox.2015-10-15 09:01 PM
http://www.google.com/search?q=CooCox+HSE_VALUE
http://www.coocox.org/forum/viewtopic.php?f=2&t=1886
2015-10-15 09:56 PM
Okay.It's in Configurations > Compile.
Thanks Clive.2015-10-15 10:12 PM
Okay.Now i got 36 MHz.What are the other alteration i should look at apart from RCC_CFGR_PLLMULL6?
Thanks.