AnsweredAssumed Answered

6MHz HSE from 8MHz creating many problems?

Question asked by potato.mr on Oct 15, 2015
Latest reply on Oct 16, 2015 by potato.mr
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?

Outcomes