HSE clock on STM32L100CDISCOVERY
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎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);
...
Then I measured with Oscilloscope on PA8 and it shows 4MHz , but when I measure direct on the pin of the oscillator it shows 8MHz.
Where is the problem?
Best Regards,
David.
#stm32l100cdiscovery
- Labels:
-
STM32L1 Series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2014-02-19 6:37 AM
/* SYSCFG Peripheral clock enable */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);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
‎2014-02-19 6:50 AM
> /* SYSCFG Peripheral clock enable */
Why? JW- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2014-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 STM32F103Up 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
‎2014-02-19 10:51 PM
Hi clive1,
I added the line:RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
And nothing changed, then i commented this line and added: RCC_HSEConfig(RCC_HSE_ON);
RCC_HSEConfig(RCC_HSE_Bypass); // This one
RCC_WaitForHSEStartUp();
And now I have on PA8 the desired 8 MHz Now I tried to do the same thing with mysystem_stm32l1xx.c file and again not working. I added My file generated withSTM32L1xx_Clock_Configuration_V1.2.0 Thanks for help. Best Regards, David.
________________
Attachments : MY_system_stm32l1xx.c : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006Hzzt&d=%2Fa%2F0X0000000bS0%2FWSCHjEzAmcOY61uK0ORbxshu_fCpksqMDgJ4SkfWnLw&asPdf=false
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2014-02-20 11:54 PM
Any suggestions?
Best Regards,David.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2014-02-21 2:50 AM
I'd have to put an STM32L100C-DISCO on the bench to confirm/understand your situation.
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
‎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.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
‎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);
and get the 8MHz.
Second HSEpicture attached http://itinypic.com/28cftqb.jpg.
Added the line:
RCC_HSEConfig(RCC_HSE_Bypass);
//or
RCC_HSEConfig(RCC_HSE_ON);
//or nothing
always get the 4MHz clk onRCC_MCOSource_HSE output.
Next I tried to use timer for time base of 1ms with interrupt ie. to toggle GPIO.
The code for timer:
TIM_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);
}
}
According to table:
* 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
*-----------------------------------------------------------------------------
*=============================================================================
Clk for TIM3 = 32MHz. Prescaler=0,Period=319
UpdateRate=TIMCLK/(prescaler+1)/(Period+1)=32MHz/1/32000=1kHz => 1ms update.
When I measure the GPIOC PIN5 with the scope I get 500 Hz => 2ms ???
How or where can I check the value of HCLK, AHB Prescaler, APB1 Prescaler, PCLK1, TIM3CLK?
Thank for Your time.
Best Regards,
David.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎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.Up vote any posts that you find helpful, it shows what's working..
