Getting Started with PLL and USART3--STM32F100C8
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2012-04-09 11:12 PM
Hi,
I am having difficulty getting sysclock to work at 24Mhz using HSI and PLL.I am also facing difficulty in getting USART3 to transmit something.I have seen and tried what other members on this forum , with similar situation did but have not able to get it to work for me.I am looking forward to your suggestions if I missed out anything.Thanks//main starts hereRCC_ClocksTypeDef RCC_Clocks;RCC_HSICmd(ENABLE);/* HCLK = SYSCLK */RCC_HCLKConfig(RCC_SYSCLK_Div1); /* PCLK2 = HCLK */RCC_PCLK2Config(RCC_HCLK_Div1); /* PCLK1 = HCLK */RCC_PCLK1Config(RCC_HCLK_Div1);RCC_PLLConfig(RCC_PLLSource_HSI_Div2, 6);/* Enable PLL */ RCC_PLLCmd(ENABLE);/* Wait till PLL is ready */while (RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET);RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);while (RCC_GetSYSCLKSource() != 0x08);RCC_GetClocksFreq(&RCC_Clocks); //SYS clock is still 8mhz.//Starting USART 3 below/* Enable GPIOx Clock */ RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO| RCC_APB2Periph_GPIOB, ENABLE); GPIO_InitTypeDef GPIO_InitStructure; USART_InitTypeDef USART_InitStructure; USART_ClockInitTypeDef USART_ClockInitStructure; RCC_APB1PeriphResetCmd(RCC_APB1Periph_USART3, ENABLE); /* Configure USART3 Rx (PB11) as input floating */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; GPIO_Init(GPIOB, &GPIO_InitStructure); /* Configure USART3 Tx (PB10) as alternate function push-pull */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_Init(GPIOB, &GPIO_InitStructure); USART_ClockStructInit(&USART_ClockInitStructure);USART_ClockInit(USART3,&USART_ClockInitStructure);USART_StructInit(&USART_InitStructure); USART_Init(USART3, &USART_InitStructure); USART_Cmd(USART3, ENABLE); USART_SendData(USART3, 'B'); while (!USART_GetFlagStatus(USART3,USART_FLAG_TXE)); //execution loops here forever #stm32f100- Labels:
-
STM32F1 Series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2012-04-10 1:46 AM
You're only resetting, not enabling USART3 clock.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2012-04-10 4:26 AM
Hi,
Thanks Domen, I called the function RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3,Enable);and it is working now.Can you please also see if I'm missing out something in the PLL initializationIm using HSI/2 as the clock input to the PLL and then mutiplying it by 6 to get 24Mhz.But calling RCC_GetClocksFreq(&RCC_Clocks); reveals SYSCLOCK is 8MhzRegards,Hansen- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2012-04-10 8:54 AM
RCC_PLLConfig(RCC_PLLSource_HSI_Div2, RCC_PLLMul_6);
RCC_PLLMul_6 = 0x00100000, ie NOT 6Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2012-04-11 2:43 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2012-04-11 2:48 AM
Hi,
I was supposed to RCC_PLLcmd(Enable) after RCC_PllConfig(....)Its working now at 24 MhzThanks all for helping me out.Regards,Hansen- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2012-04-11 2:58 AM
Hi
Im able to run the sysclock at 56Mhz by pll..wow..Uart and GPIO are working fine.Has anyone tried this?Regards,- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2012-04-11 11:07 AM
Im able to run the sysclock at 56Mhz by pll..wow..Uart and GPIO are working fine.Has anyone tried this?
I've run some at 32 MHz without issues, beyond that I'm pretty sure you'd need to add FLASH wait states. I also have F205 parts with more RAM and FLASH memory than specified. These are fun to test in the lab, but something I would avoid in shipping product.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2012-04-11 10:32 PM
Hi,
Yes maybe it does need flash wait cycles because it just stops sometimes.I will just run it at 24Mhz for nowThanks,Hansen