2014-02-19 5:10 AM
Hi all,
I have a question about HSE clock source. I loaded the demo and added some code to check the HSE clock on PA8....
GPIO_InitTypeDef GPIO_InitStructure;
...
int main(void){ 
...
RCC_HSEConfig(RCC_HSE_ON);
RCC_WaitForHSEStartUp();
/* GPIOA clock enable */
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE); 
RCC_MCOConfig(RCC_MCOSource_HSE , RCC_MCODiv_1);
GPIO_PinAFConfig(GPIOA, GPIO_PinSource8, GPIO_AF_MCO); 
/*GPIOA Configuration: Pin 8*/
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; 
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_40MHz; 
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; 
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; 
GPIO_Init(GPIOA, &GPIO_InitStructure); 
...2014-02-19 6:37 AM
/* SYSCFG Peripheral clock enable */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);2014-02-19 6:50 AM
> /* SYSCFG Peripheral clock enable */
Why? JW2014-02-19 7:20 AM
A guess based on other STM32 architectures.
Would probably want the BYPASS mode on too if the 8 MHz is derived from the ST-LINK's STM32F1032014-02-19 10:51 PM
Hi clive1,
I added the line:RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);RCC_HSEConfig(RCC_HSE_ON);
RCC_HSEConfig(RCC_HSE_Bypass); // This one
RCC_WaitForHSEStartUp();2014-02-20 11:54 PM
Any suggestions?
Best Regards,David.2014-02-21 2:50 AM
I'd have to put an STM32L100C-DISCO on the bench to confirm/understand your situation.
2014-02-21 2:12 PM
RCC_HSEConfig(RCC_HSE_Bypass);
Gets symmetric 8 MHz RCC_HSEConfig(RCC_HSE_ON); Gets asymmetric 4 MHz, odd but duly noted. The oscillator circuit doesn't need enabling as there is no crystal, but an external source. The startup_stm32l1xx.c uses the PLL + HSI, so doesn't address the bypass mode like other DISCO boards have.2014-02-24 2:35 AM
Hi clive1,
Thanks for the answer. Her is what I tried: First HSI picture attached http://itinypic.com/28cftqb.jpg. And added the line:RCC_HSEConfig(RCC_HSE_Bypass);RCC_HSEConfig(RCC_HSE_Bypass);
//or
RCC_HSEConfig(RCC_HSE_ON);
//or nothingTIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
NVIC_InitTypeDef NVIC_InitStructure;
GPIO_InitTypeDef GPIO_InitStructure;
/*GPIOC clock enable */
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOC, ENABLE);
/* TIM3 clock enable in Time base mode*/
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE);
/*GPIOC Configuration: Pin 5*/
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_40MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(GPIOC, &GPIO_InitStructure);
/* ------------------- TIMER Configuration -----------------------------------*/
/*TIM3*/
TIM_TimeBaseStructure.TIM_Prescaler =0;//31;
TIM_TimeBaseStructure.TIM_CounterMode =TIM_CounterMode_Up;
TIM_TimeBaseStructure.TIM_Period =31999;//1000;
TIM_TimeBaseStructure.TIM_ClockDivision =0;
TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStructure);
/*----------------------------------------------------------------------------*/
/* Enable the TIM3 gloabal Interrupt */
NVIC_InitStructure.NVIC_IRQChannel = TIM3_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
/* Enable the TIM3 to generate interrupt */
TIM_ITConfig(TIM3, TIM_IT_Update, ENABLE);
/* Enable TIM3 */
TIM_Cmd(TIM3, ENABLE);
//Interrupt
/* TIM3 */
void TIM3_IRQHandler(void)
{
if (TIM_GetITStatus(TIM3, TIM_IT_Update) != RESET)
{
TIM_ClearITPendingBit(TIM3, TIM_IT_Update);
GPIO_ToggleBits(GPIOC, GPIO_Pin_5);
}
}* 5. This file configures the system clock as follows:
*=============================================================================
* System Clock Configuration
*=============================================================================
* System Clock source | PLL(HSI)
*-----------------------------------------------------------------------------
* SYSCLK | 32000000 Hz
*-----------------------------------------------------------------------------
* HCLK | 32000000 Hz
*-----------------------------------------------------------------------------
* AHB Prescaler | 1
*-----------------------------------------------------------------------------
* APB1 Prescaler | 1
*-----------------------------------------------------------------------------
* APB2 Prescaler | 1
*-----------------------------------------------------------------------------
* HSE Frequency | 8000000 Hz
*-----------------------------------------------------------------------------
* PLL DIV | 2
*-----------------------------------------------------------------------------
* PLL MUL | 4
*-----------------------------------------------------------------------------
* VDD | 3.3 V
*-----------------------------------------------------------------------------
* Vcore | 1.8 V (Range 1)
*-----------------------------------------------------------------------------
* Flash Latency | 1 WS
*-----------------------------------------------------------------------------
* Require 48MHz for USB clock | Disabled
*-----------------------------------------------------------------------------
*=============================================================================2014-02-24 5:03 AM
When I measure the GPIOC PIN5 with the scope I get 500 Hz => 2ms ???
Toggling tends to do that, as it doubles the period. You could call it twice in the interrupt handler.