文档库 最新最全的文档下载
当前位置:文档库 › 37x时钟配置

37x时钟配置

37x时钟配置
37x时钟配置

September 2012Doc ID 023352 Rev 11/16

AN4132Application note

Clock configuration tool for STM32F37x/STM32F38x

microcontrollers

Introduction

This application note presents the clock system configuration tool for the STM32F37x and STM32F38x microcontroller families.

The purpose of this tool is to help the user to configure the microcontroller clocks, taking into consideration product parameters such as power supply and Flash access mode.

Note:The clock configuration tool for STM32F37xx and STM32F38xx microcontrollers will be

referred to as “STM32F37x clock configuration tool“ throughout the document.

“STM32F37x“ will refer to STM32F37xx and STM32F38x.

The configuration tool is implemented in the “STM32F37x_Clock_Configuration_VX.Y .Z.xls” file which is supplied with the STM32F37x Standard Peripherals Library and can be downloaded from https://www.wendangku.net/doc/9f14061763.html, .

This tool supports the following functions for the STM32F37x:

Configuration of the system clock, HCLK source and output frequency ●

Configuration of the Flash latency (number of wait states depending on the HCLK frequency)●

Setting of the PCLK1, PCLK2, TIMCLK (timer clocks) and I2SCLK frequencies ●Generation of a ready-to-use system_stm32f37x.c file with all the above settings (STM32F37x CMSIS Cortex-M4 Device Peripheral Access Layer System Source File)The STM32F37x_Clock_Configuration_VX.Y .Z.xls is referred to as “clock tool” throughout this document.

Before using the clock tool, it is essential to read the STM32F37x microcontroller reference manual (RM0313). This application note is not a substitute for the reference manual.This tool supports only the STM32F37x devices.

For VX.Y .Z, please refer to the tool version, example V1.0.0.

Table 1 lists the microcontrollers concerned by this application note.

Table 1.Applicable products

Type Applicable products

Microcontrollers STM32F37x

STM32F38x

https://www.wendangku.net/doc/9f14061763.html,

Contents AN4132

Contents

1Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

2Getting started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

2.1Software requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

2.2Hardware requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

2.2.1Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

2.2.2Clock scheme for STM32F37x microcontrollers . . . . . . . . . . . . . . . . . . . 6

2.2.3I2S clock generator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

3Tutorials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

3.1Wizard mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

3.2Expert mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 4Known limitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 5Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 6Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

2/16Doc ID 023352 Rev 1

AN4132List of figures List of figures

Figure 1.Clock scheme. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Figure 2.I2S clock generator architecture. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Figure 3.Wizard mode user interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Figure 4.Select the clock source. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 Figure 5.File generation error. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 Figure 6.Expert mode user interface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 Figure 7.System clock frequency is exceeded . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

Doc ID 023352 Rev 13/16

Glossary AN4132 1 Glossary

Table 2.Definition of terms

Term Description

HCLK AHB clock

PCLK1APB1 clock

PCLK2APB2 clock

TIMCLK Timer clock

F CPU Cortex-M4 clock

Ext.Clock External clock

V DD Power supply

HSI High-speed internal clock

HSE High-speed external clock

MCLK Master clock

I2S Integrated interchip sound

Fs Sampling frequency

I2SCLK I2S clock

4/16Doc ID 023352 Rev 1

AN4132Getting started Doc ID 023352 Rev 15/16

2 Getting started

This section describes the requirements and procedures needed to start using the clock

tool.

2.1 Software requirements

To use the clock tool with Windows ? operating system, a recent version of Windows, such

as Windows XP , Vista or Windows 7 must be installed on the PC with at least

256 Mbytes of RAM.

Before starting to use the clock tool, make sure that Microsoft? Office is installed on your

machine and then follow these steps:

Download the latest version of the clock tool for the STM32F37x product from https://www.wendangku.net/doc/9f14061763.html, .●Enable macros and ActiveX? controls:.

Excel ? 1997-2003 version

1.Click Tools in the menu bar.

2. Click Macro .

3. Click Security .

4. Click Low (not recommended).

Note:If ActiveX controls are not enabled, a warning message is displayed asking you to enable

ActiveX. In this case, you should click “OK” to enable it.

Excel 2007 version

1.Click the Microsoft Office button and then click Excel options .

2. Click Trust Center , click Trust center settings , and then click Macro settings .

3. Click Enable all macros (not recommended, potentially dangerous code can run).

4. Click Trust Center , click Trust center settings , and then click ActiveX settings .

5. Click Enable all controls without restrictions and without prompting (not

recommended; potentiality dangerous controls can run).

6. Click OK .

Note:For more information about how to enable macros and ActiveX controls, please refer to the

Microsoft Office website.

Getting started AN41326/16Doc ID 023352 Rev 1

2.2 Hardware requirements

2.2.1 Introduction

The clock tool is designed to configure the system clocks and generate the

system_stm32f37x.c file for STM32F37x microcontrollers.

The system_stm32f37x.c file is provided as a template system clock configuration file which

can be easily modified to select the corresponding system clock frequency and to configure

the Flash latency.

2.2.2 Clock scheme for STM32F37x microcontrollers

This section describes the system clock scheme that is dependent on the voltage

requirements (V DD ) versus the system clock frequency and Flash latency versus the system

clock frequency.

Three different clock sources can be used to drive the system clock (SYSCLK):

1.

HSI (8 MHz) oscillator clock 2.

HSE (4 MHz to 32 MHz) oscillator clock 3. Main phase-locked loop (PLL) clock with a PLL voltage-controlled oscillator

(PLLVCO) input frequency.

All peripheral clocks are derived from the SYSCLK.

Note:The number of Flash memory wait states (latency) is defined according to the frequency of

the CPU (Cortex-M4):

Zero wait states if 0 < SYSCLK <= 24 MHz ●

One wait state if 24 MHz < SYSCLK <= 48 MHz ●Two wait state if 48MHz < SYSCLK <= 72MHz

AN4132Getting started

Doc ID 023352 Rev 17/16

Getting started AN41328/16Doc ID 023352 Rev 1

2.2.3 I2S clock generator

This section describes the I2S clock generator. It is dependent on:

Master clock MCLK (enable or disable)●

Frame width ●I2S peripheral clock (I2SCLK).Figure 2.

I2S clock generator architecture

The audio sampling frequency may be 192 kHz, 96 kHz, 48 kHz, 44.1 kHz, 32 kHz,

22.05 kHz, 16 kHz, 11.025 kHz or 8 kHz. To reach the desired frequency, the linear divider

(DIV) needs to be programmed according to the formulas below:

When the master clock is generated (MCKOE bit in the SPI_I2SPR register is set):

FS = I2SxCLK/[(16*2)*((2*I2SDIV)+ODD)*8)] when the channel frame is 16 bits wide ●FS = I2SxCLK/[(32*2)*((2*I2SDIV)+ODD)*4)] when the channel frame is 32 bits wide

Where ODD is an odd factor for the prescaler.

When the master clock is disabled (MCKOE bit cleared):

FS = I2SxCLK/[(16*2)*((2*I2SDIV)+ODD))] when the channel frame is 16 bits wide ●FS = I2SxCLK/[(32*2)*((2*I2SDIV)+ODD))] when the channel frame is 32 bits wide

Note:This tool does not configure the I2S register.

The sampling frequency error is computed as an indicator according to the I2S parameters

which are not configured in the output file “system_stm32f37x.c”.

8-bit divider +linear

CK ODD I2SDIV[7:0]I2SxCLK CHLEN

I2SMOD reshaping stage Divider by 4Div21

0MCKOE MCKOE MCK 0

1

AN4132Tutorials Doc ID 023352 Rev 19/16

3 Tutorials

This section describes how to use the clock tool to configure all system clocks and generate

the system_stm32f37x.c file. Two modes are available: Wizard and Expert . The selection is

made in the Configuration mode list box.

3.1 Wizard mode

This mode (default mode) guides you through a series of steps to obtain the desired clock

system configuration quickly and easily.

Figure 3.Wizard mode user interface

Note:The ‘Reset ’ button allows to set the system clock for the default configuration.

The wizard guides you through the following steps:

1.Set the HSE frequency (if it is used in your application) between a minimum of 4 MHz,

and a maximum of 32 MHz if a crystal oscillator is used for the STM32F37x. If the

frequency entered is out of range, an error message is displayed, and a valid frequency

must be entered.

The definition of HSE_VALUE in the stm32f37x.h file must be modified each time the

user changes the HSE oscillator value.

Tutorials AN413210/16Doc ID 023352 Rev 1

2. Configure the Prefetch buffer (select ON or OFF from the list box).

3.

Specify if the I2S clock is needed. If needed, enable it and follow steps 7, 8 and 9. Otherwise, go to step 4.4.

Specify the USB clock if needed 5.

Set the desired HCLK frequency. If the value entered is higher than the maximum HCLK frequency, an error message is displayed.6. Select the PCLK1 and PCLK2 prescaler settings from the list box to obtain the desired

PCLK1 and PCLK2 frequencies. The TIMCLK frequencies are configured automatically

depending on the PCLK1 and PCLK2 prescaler settings.

Note:In this product, PCLK1 and PCLK2 share the same clock signal, so APB1 prescaler should

always equal APB2 prescaler.

7.

If the I2S clock is needed, select the frame width (16 or 32 bits).8.

Specify if the master clock is enabled or disabled (Select ON/OFF from the list box).9. Select the Frequency from the list box. The Fs value can be 192 kHz, 96 kHz, 48 kHz,

44.1 kHz, 32 kHz, 22.05 kHz, 16 kHz, 11.025 kHz, or 8 kHz.

10. Click the RUN button.

If more than one clock source is possible, a message box displays the clock sources

that can be selected (see Figure 4). Choose HSE, HSI or PLL (which are sourced by

the HSI or HSE).

Figure 4.Select the clock source

11. Click the Generate button to automatically generate system_stm32f37x.c file.

The system_stm32f37x.c file is generated in the same location as the clock tool.

Display the file to verify:

- the value of the system clock, SystemCoreClock,

- the values of HCLK, PCLK1, PCLK2, Flash access mode, - and other parameters which are defined in the SetSysClock function.

If the file is not generated, an error message is displayed, as shown in Figure 5.

Figure 5.File generation error

12. The system_stm32f37x.c file must be added to the working project to be built.

AN4132Tutorials

Doc ID 023352 Rev 111/16

3.2 Expert mode

This mode provides more flexibility regarding the configuration setup but the user must

ensure that the configuration is correct.

Figure 6.Expert mode user interface

The ‘Reset ’ button permits the system clock to be reset to the default configuration.

These main steps are described in detail in this section:

1.

Configure the SYSCLK frequency.2.

If required, enable the I2S clock and configure the I2S clock frequency.3. If required, configure the Prefetch buffer.

4. Generate the system_stm32f37x.c file.

5. Add the system_stm32f37x.c file to the working project to be built.

Tutorials AN413212/16Doc ID 023352 Rev 1

1.Configure the SYSCLK frequency.a) If the HSE is used in your application, set its frequency between 4 MHz and

32 MHz (set it to 32 MHz if a crystal oscillator is used for the STM32F37x).

If the frequency entered is out of range, an error message is displayed. A valid

frequency must be entered.

Note:The definition of HSE_VALUE in the stm32F37x.h file must be modified each time the user

changes the HSE oscillator value.

b) Configure the SYSCLK source (PLL, HSE or HSI). If the clock source selection is

invalid (HCLK frequency is too high), the error message in Figure 7 is displayed.

Figure 7.System clock frequency is exceeded

c) If PLL is selected as the SYSCLK source, it is necessary to select the source clock

for the PLL (HSE or HSI).

d) If PLL is selected as the SYSCLK source, configure the main PLL (PLLMUL) and

the PLL division factor (PREDIV) if HSE is selected as the PLL clock source.

e) Set HCLK prescaler using the AHBPrescaler list box to obtain the desired HCLK

frequency.

f) Select PCLK1 prescaler settings from the list box to obtain the desired PCLK1

frequency. The TIMCLK frequencies are configured automatically depending on

the PCLK1 prescaler settings.

g) Select PCLK2 prescaler settings from the list box to obtain the desired PCLK2

frequency. The TIMCLK frequencies are configured automatically depending on

the PCLK2 prescaler settings.

Note:In this product, PCLK1 and PCLK2 share the some clock signal, so APB1 prescaler should

always equal APB2 prescaler.

h) Configure the Flash Latency: after setting the HCLK prescaler, the number of

Flash wait states is configured automatically with the best value (lowest possible

value) which can be modified to any value higher than the best value.

i)

Generate the clock configuration files by clicking on the Generate button.2. If required, enable the I2S clock and configure the I2S clock frequency.

a) Select the frame width (16 or 32 bits) and specify if the master clock is enabled or

not.

b) Select Fs from the list box. The Fs value can be 192 kHz, 96 kHz, 48 kHz,

44.1 kHz, 32 kHz, 22.05 kHz, 16 kHz, 11.025 kHz and 8 kHz.

3. Optionally configure the Prefetch buffer.

4. Generate the system_stm32f37x.c file.

Click the Generate button to automatically generate the system_stm32f37x.c file in the

same location as the clock tool. It can be displayed to verify:

- the value of the SYSCLK, SystemCoreClock,

AN4132Known limitations

Doc ID 023352 Rev 113/16

- the values of HCLK, PCLK1, PCLK2, Flash access mode,

- and other parameters which are defined in the “SetSysClock” function.

5. The system_stm32f37x.c file must be added to the working project to be built.

4 Known limitations

This section describes the known limitations of the clock configuration tool.

This tool does not support configurations that use the HSE external clock source (HSE

bypass).

Conclusion AN413214/16Doc ID 023352 Rev 1

5 Conclusion

This application note provides a description of how to use the clock tool with the

STM32F37x microcontroller devices.

This tool generates a source code file system_stm32f37x.c to configure the clock system of

the STM32F37x. It can be accessed from either of the two configuration modes:

Wizard mode: provides a quick and easy way to configure the system clocks. ●Expert mode: offers more flexibility in setting up the system clock configuration while still respecting all the product constraints.

AN4132Revision history Doc ID 023352 Rev 115/16

6 Revision history

Table 3.Document revision history

Date Revision

Changes 26-Sep-2012

1Initial release

AN4132

Please Read Carefully:

Information in this document is provided solely in connection with ST products. STMicroelectronics NV and its subsidiaries (“ST”) reserve the right to make changes, corrections, modifications or improvements, to this document, and the products and services described herein at any time, without notice.

All ST products are sold pursuant to ST’s terms and conditions of sale.

Purchasers are solely responsible for the choice, selection and use of the ST products and services described herein, and ST assumes no liability whatsoever relating to the choice, selection or use of the ST products and services described herein.

No license, express or implied, by estoppel or otherwise, to any intellectual property rights is granted under this document. If any part of this document refers to any third party products or services it shall not be deemed a license grant by ST for the use of such third party products or services, or any intellectual property contained therein or considered as a warranty covering the use in any manner whatsoever of such third party products or services or any intellectual property contained therein.

UNLESS OTHERWISE SET FORTH IN ST’S TERMS AND CONDITIONS OF SALE ST DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY WITH RESPECT TO THE USE AND/OR SALE OF ST PRODUCTS INCLUDING WITHOUT LIMITATION IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE (AND THEIR EQUIVALENTS UNDER THE LAWS OF ANY JURISDICTION), OR INFRINGEMENT OF ANY PATENT, COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT. UNLESS EXPRESSLY APPROVED IN WRITING BY TWO AUTHORIZED ST REPRESENTATIVES, ST PRODUCTS ARE NOT RECOMMENDED, AUTHORIZED OR WARRANTED FOR USE IN MILITARY, AIR CRAFT, SPACE, LIFE SAVING, OR LIFE SUSTAINING APPLICATIONS, NOR IN PRODUCTS OR SYSTEMS WHERE FAILURE OR MALFUNCTION MAY RESULT IN PERSONAL INJURY, DEATH, OR SEVERE PROPERTY OR ENVIRONMENTAL DAMAGE. ST PRODUCTS WHICH ARE NOT SPECIFIED AS "AUTOMOTIVE GRADE" MAY ONLY BE USED IN AUTOMOTIVE APPLICATIONS AT USER’S OWN RISK.

Resale of ST products with provisions different from the statements and/or technical features set forth in this document shall immediately void any warranty granted by ST for the ST product or service described herein and shall not create or extend in any manner whatsoever, any liability of ST.

ST and the ST logo are trademarks or registered trademarks of ST in various countries.

Information in this document supersedes and replaces all information previously supplied.

The ST logo is a registered trademark of STMicroelectronics. All other names are the property of their respective owners.

? 2012 STMicroelectronics - All rights reserved

STMicroelectronics group of companies

Australia - Belgium - Brazil - Canada - China - Czech Republic - Finland - France - Germany - Hong Kong - India - Israel - Italy - Japan - Malaysia - Malta - Morocco - Philippines - Singapore - Spain - Sweden - Switzerland - United Kingdom - United States of America

https://www.wendangku.net/doc/9f14061763.html,

16/16Doc ID 023352 Rev 1

SPI时钟模式的配置

SPI时钟模式的配置 【SPI基础知识简介】设备与设备之间通过某种硬件接口通讯,目前存在很多

种接口,SPI接口是其中的一种。 SPI中分Master主设备和Slave从设备,数据发送都是由Master控制。 —个master可以接一个或多个slave o 常见用法是一个Master接一个slave,只需要4根线: SCLK : Serial Clock,(串行)时钟 MISO : Master In Slave Out,主设备输入,从设备输出 MOSI : Master Out Slave In,主设备输出,从设备输入 SS: Slave Select,选中从设备,片选 SPI由于接口相对简单(只需要4根线),用途算是比较广泛,主要应用在EEPROM, FLASH,实时时钟,AD转换器,还有数字信号处理器和数字信号解码器之间。 即一个SPI的Master通过SPI与一个从设备,即上述的那些Flash, ADC等,进行通讯。 而主从设备之间通过SPI进行通讯,首先要保证两者之间时钟SCLK要一致,互相要商量好了,要匹配,否则,就没法正常通讯了,即保证时序上的一致才可正常讯。 而这里的SPI中的时钟和相位,指的就是SCLk时钟的特性,即保证主从设备两者的时钟的特性一致了,以保证两者可以正常实现SPI通讯。

【SPI相关的缩写或说法】 先简单说一下,关于SPI中一些常见的说法: SPI的极性Polarity和相位Phase,最常见的写法是CPOL和CPHA,不过也有 —些其他写法,简单总结如下: (1)CKPOL (Clock Polarity) = CPOL = POL = Polarity =(时钟)极性 (2)CKPHA (Clock Phase) = CPHA = PHA = Phase =(时钟)相位 (3)SCK二SCLK二SPI 的时钟 ⑷Edge=边沿,即时钟电平变化的时刻,即上升沿(rising edge)或者下降沿 (falling edge) 对于一个时钟周期内,有两个edge,分别称为: Leading edge=前一个边沿二第一个边沿,对于开始电压是1,那么就是1变成0 的时候,对于开始电压是0,那么就是0变成1的时候; Trailing edge二后一个边沿二第二个边沿,对于开始电压是1,那么就是0变成1 的时候(即在第一次1变成0之后,才可能有后面的0变成1),对于开始电压是0,那么就是1变成0的时候; 本文采用如下用法? 极性二CPOL 相位=CPHA SCLK二时钟 第一个边沿和第二个边沿

RCC时钟配置

时钟配置RCC_Configuration() 在比较靠前的版本中,我们需要向下面那样设置时钟: ErrorStatus HSEStartUpStatus; /*********************************************************************** *************** * FunctionName : RCC_Configuration() * Description : 时钟配置 * EntryParameter : None * ReturnValue : None ************************************************************************ **************/ void RCC_Configuration(void) { /* 复位所有的RCC外围设备寄存器,不改变内部高速振荡器调整位(HSITRIM[4..0])以及 备份域控制寄存器(RCC_BDCR),控制状态寄存器RCC_CSR */ RCC_DeInit(); // RCC system reset(for debug purpose) /* 开启HSE振荡器*/ /* 三个参数: RCC_HSE_ON-开启RCC_HSE_OFF-关闭RCC_HSE_BYPASS-使用外部时钟振荡器*/ RCC_HSEConfig(RCC_HSE_ON); // Enable HSE /* HSEStartUpStatus为枚举类型变量,2种取值,0为ERROR,非0为SUCCESS 等待HSE准备好,若超时时间到则退出*/ HSEStartUpStatus = RCC_WaitForHSEStartUp(); // Wait till HSE is ready if (HSEStartUpStatus == SUCCESS) // 当HSE准备完毕切振荡稳定后 { /* 配置AHB时钟,这个时钟从SYSCLK分频而来分频系数有1,2,4,8,16,64,128,256,512 */ RCC_HCLKConfig(RCC_SYSCLK_Div1); // HCLK = SYSCLK /* 设置低速APB2时钟,这个时钟从AHB时钟分频而来分频系数为1,2,4,8,16 */ RCC_PCLK2Config(RCC_HCLK_Div1); // PCLK2 = HCLK /* 设置低速APB1时钟,这个时钟从AHB时钟分频而来分频系数为1,2,4,8,16 */ RCC_PCLK1Config(RCC_HCLK_Div2); // PCLK1 = HCLK/2 FLASH_SetLatency(FLASH_Latency_2); // Flash 2 wait state FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable); // Enable Prefetch Buffer /* 设置PLL的时钟源和乘法因子 第一个入口参数为时钟源,共有3个 RCC_PLLSource_HSI_Div2 RCC_PLLSource_HSE_Div1

stm32如何配置时钟

学习STM32笔记2 如何配置时钟 学习STM32笔记2 如何配置时钟 /************************************************************* 该程序目的是用于测试核心板回来后是否能正常工作。包括 两个按键、两个LED现实。按键为PC4、PC5,LED为PA0\PA1。LED为 低电平时点亮。按键为低电平时触发。 ************************************************************/ #i nclude "stm32f10x_lib.h" void RCC_Configuration(void);//设置系统主时钟 void GPIO_Configuration(void);//设置邋邋IO参数 void NVIC_Configuration(void);//设置中断表地址 void delay(void);//延时函数 int main(void) { #ifdef DEBUG debug(); #endifRCC_Configuration(); NVIC_Configuration(); GPIO_Configuration(); while (1) { delay(); //设置指定的数据端口位 GPIO_SetBits(GPIOA,GPIO_Pin_0); //设置指定的数据端口位 delay(); GPIO_ResetBits(GPIOA,GPIO_Pin_0); //清除指定的数据端口位 GPIO_SetBits(GPIOA,GPIO_Pin_1); delay(); GPIO_ResetBits(GPIOA,GPIO_Pin_1); delay(); /********************************************* 使用setbits 与resetbits 是比较简单,其实还是可以使用 其它函数。例如可以使用GPIO_WriteBit GPIO_WriteBit(GPIOA, GPIO_Pin_1, Bit_SET); GPIO_WriteBit(GPIOA, GPIO_Pin_1, Bit_RESET);对于好像流水灯呀这些一个整段IO,可以使用GPIO_Write(GPIOA, 0x1101); *********************************************/

学习STM32笔记2如何配置时钟

学习STM32笔记2 如何配置时钟* 学习STM32笔记2 如何配置时钟 原创笔记2009-09-20 19:56 阅读116 评论0 字号:大中小 /************************************************************* 该程序目的是用于测试核心板回来后是否能正常工作。包括 两个按键、两个LED现实。按键为PC4、PC5,LED为PA0\PA1。LED为 低电平时点亮。按键为低电平时触发。 ************************************************************/ #i nclude "stm32f10x_lib.h" void RCC_Configuration(void);//设置系统主时钟 void GPIO_Configuration(void);//设置邋邋IO参数 void NVIC_Configuration(void);//设置中断表地址 void delay(void);//延时函数 int main(void) { #ifdef DEBUG debug(); #endifRCC_Configuration(); NVIC_Configuration(); GPIO_Configuration(); while (1) { delay(); //设置指定的数据端口位 GPIO_SetBits(GPIOA,GPIO_Pin_0); //设置指定的数据端口位 delay(); GPIO_ResetBits(GPIOA,GPIO_Pin_0); //清除指定的数据端口位 GPIO_SetBits(GPIOA,GPIO_Pin_1); delay(); GPIO_ResetBits(GPIOA,GPIO_Pin_1); delay(); /********************************************* 使用setbits 与resetbits 是比较简单,其实还是可以使用 其它函数。例如可以使用GPIO_WriteBit GPIO_WriteBit(GPIOA, GPIO_Pin_1, Bit_SET); GPIO_WriteBit(GPIOA, GPIO_Pin_1, Bit_RESET);对于好像流水灯呀这些一个整段IO,可以使用GPIO_Write(GPIOA, 0x1101); *********************************************/

SPI时钟模式的配置

S P I时钟模式的配置集团标准化小组:[VVOPPT-JOPP28-JPPTL98-LOPPNN]

【S P I基础知识简介】 设备与设备之间通过某种硬件接口通讯,目前存在很多种接口,SPI接口是其中的一种。 SPI中分Master主设备和Slave从设备,数据发送都是由Master控制。 一个master可以接一个或多个slave。 常见用法是一个Master接一个slave,只需要4根线: SCLK:SerialClock,(串行)时钟 MISO:MasterInSlaveOut,主设备输入,从设备输出 MOSI:MasterOutSlaveIn,主设备输出,从设备输入 SS:SlaveSelect,选中从设备,片选 SPI由于接口相对简单(只需要4根线),用途算是比较广泛,主要应用在EEPROM,FLASH,实时时钟,AD转换器,还有数字信号处理器和数字信号解码器之间。 即一个SPI的Master通过SPI与一个从设备,即上述的那些Flash,ADC等,进行通讯。 而主从设备之间通过SPI进行通讯,首先要保证两者之间时钟SCLK要一致,互相要商量好了,要匹配,否则,就没法正常通讯了,即保证时序上的一致才可正常讯。 而这里的SPI中的时钟和相位,指的就是SCLk时钟的特性,即保证主从设备两者的时钟的特性一致了,以保证两者可以正常实现SPI通讯。 【SPI相关的缩写或说法】 先简单说一下,关于SPI中一些常见的说法: SPI的极性Polarity和相位Phase,最常见的写法是CPOL和CPHA,不过也有一些其他写法,简单总结如下: (1)CKPOL(ClockPolarity)=CPOL=POL=Polarity=(时钟)极性 (2)CKPHA(ClockPhase)=CPHA=PHA=Phase=(时钟)相位 (3)SCK=SCLK=SPI的时钟 (4)Edge=边沿,即时钟电平变化的时刻,即上升沿(risingedge)或者下降沿(fallingedge) 对于一个时钟周期内,有两个edge,分别称为: Leadingedge=前一个边沿=第一个边沿,对于开始电压是1,那么就是1变成0的时候,对于开始电压是0,那么就是0变成1的时候; Trailingedge=后一个边沿=第二个边沿,对于开始电压是1,那么就是0变成1的时候(即在第一次1变成0之后,才可能有后面的0变成1),对于开始电压是0,那么就是1变成0的时候;

STM32时钟系统与软件配置

STM32时钟系统与软件配置 在STM32中,有五个时钟源,为HSI、HSE、LSI、LSE、PLL。 ①HSI是高速内部时钟,RC振荡器,频率为8MHz。 ②HSE是高速外部时钟,可接石英/陶瓷谐振器,或者接外部时钟源,频率范围为4MHz~16MHz。 ③LSI是低速内部时钟,RC振荡器,频率为40kHz。 ④LSE是低速外部时钟,接频率为32.768kHz的石英晶体。 ⑤PLL为锁相环倍频输出,其时钟输入源可选择为HSI/2、HSE或者HSE/2。倍频可选择为2~16倍,但是其输出频率最大不得超过72MHz。

在STM32上如果不使用外部晶振,OSC_IN和OSC_OUT的接法 如果使用内部RC振荡器而不使用外部晶振,请按照下面方法处理: 1)对于100脚或144脚的产品,OSC_IN应接地,OSC_OUT应悬空。 2)对于少于100脚的产品,有2种接法: 2.1)OSC_IN和OSC_OUT分别通过10K电阻接地。此方法可提高EMC性能。 2.2)分别重映射OSC_IN和OSC_OUT至PD0和PD1,再配置PD0和PD1为推挽输出并输出'0'。此方法可以减小功耗并(相对上面2.1)节省2个外部电阻。 使用HSE时钟,程序设置时钟参数流程: 1、将RCC寄存器重新设置为默认值RCC_DeInit; 2、打开外部高速时钟晶振HSE RCC_HSEConfig(RCC_HSE_ON); 3、等待外部高速时钟晶振工作 HSEStartUpStatus = RCC_WaitForHSEStartUp(); 4、设置AHB时钟RCC_HCLKConfig; 5、设置高速AHB时钟RCC_PCLK2Config; 6、设置低速速AHB时钟RCC_PCLK1Config;

锁相环配置时钟

锁相环配置时钟 锁相环作为一个提供系统时钟的模块,是一个基本的模块,几乎每次编程序都得用到。下面记一下怎样配置锁相环来设定想要的系统时钟。 锁相环PLL、自时钟模式和前面说的实时中断RTI、看门狗COP都属于系统时钟与复位CRG中的模块,固前面用到的寄存器,这里有些会再用到。 在程序中配置锁相环的步骤如下: 第一、禁止总中断; 第二、寄存器CLKSEL的第七位置0,即CLKSEL_PLLSEL=0。选择时钟源为外部晶振OSCCLK,在PLL程序执行前,内部总线频率为OSCCLK/2。 CLKSEL_PLLSEL=0时,系统时钟由外部晶振直接提供,系统内部总线频率=OSCCLK/2(OSCCLK为外部晶振频率)。CLKSEL_PLLSEL=1时,系统时钟由锁相环提供,此时系统内部总线频率=PLLCLK/2 (PLLCLK为锁相环倍频后的频率)。 第三、禁止锁相环PLL,即PLLCTL_PLLON=0。 当PLLCTL_PLLON=0时,关闭PLL电路。当PLLCTL_PLLON=1时,打开PLL电路。 第四、根据想要的时钟频率设置SYNR和REFDV两个寄存器。 SYNR和REFDV两个寄存器专用于锁相环时钟PLLCLK的频率计算,计算公式是: PLLCLK=2*OSCCLK*(SYNR+1)/(REFDV+1) 其中,PLLCLK为PLL模块输出的时钟频率;OSCCLK为晶振频率;SYNR、REFDV 分别为寄存器SYNR、REFDV中的值。这两个寄存器只有在PLLSEL=0时才能

够写入(这里就是第二步的设置原因所在了)。 第五、打开PLL,即PLLCTL_PLLON=1。 第六、CRGFLG_LOCK位,确定PLL是否稳定。 当锁相环PLL电路输出的频率达到目标频率的足够小的误差范围内时,LOCK位置1,此时说明PLLCLK已经稳定,可以作为系统的时钟了。该位在正常情况下为只读位。 第七、PLLCLK稳定后,允许锁相环时钟源PLLCLK为系统提供时钟,即CLKSEL_PLLSEL=1。 到这里,锁相环的设置就完毕了。

stm32f030时钟配置工具AN4055

May 2012Doc ID 022837 Rev 11/17 AN4055 Application note Clock configuration tool for STM32F0xx microcontrollers Introduction This application note presents the clock system configuration tool for the STM32F0xx microcontroller family. The purpose of this tool is to help the user configure the microcontroller clocks, taking into consideration product parameters such as power supply and Flash access mode. The configuration tool is implemented in the “STM32F0xx_Clock_Configuration_VX.Y .Z.xls” file which is supplied with the STM32F0xx Standard Peripherals Library and can be downloaded from https://www.wendangku.net/doc/9f14061763.html, . This tool supports the following functionalities for the STM32F0xx: ● Configuration of the system clock, HCLK source and output frequency ● Configuration of the Flash latency (number of wait states depending on the HCLK frequency)● Setting of the PCLK1, PCLK2, TIMCLK (timer clocks) and I2SCLK frequencies ●Generation of a ready-to-use system_stm32f0xx.c file with all the above settings (STM32F0xx CMSIS Cortex-M0 Device Peripheral Access Layer System Source File)The STM32F0xx_Clock_Configuration_VX.Y .Z.xls is referred to as “clock tool” throughout this document. Before using the clock tool, it is essential to read the STM32F0xx microcontroller reference manual (RM0091). This application note is not a substitute for the reference manual.This tool supports only the STM32F0xx devices. For VX.Y .Z, please refer to the tool version, example V1.0.0 https://www.wendangku.net/doc/9f14061763.html,

配置时钟

配置时钟 介绍如何配置时钟数据,包括配置参考源、时钟板和线路时钟源。 前提条件 设备已正确配置机框和单板。 时钟系统 时钟系统为UMG8900设备提供内部系统所必要的时钟信号,通过接入外部各种标准的参考时钟信号,提供电信网络设备所需要的2/3级精度时钟。 时钟系统的核心处理单元为独立的时钟单板CLK或者位于TNC单板上的时钟扣板。采用独立CLK 时钟单板时,系统可以提供2/3级精度时钟;采用TNC时钟扣板时,只能提供3级精度时钟。CLK 板或者TNC板上的时钟扣板通过跟踪外部基准信号、过滤外基准的抖动、漂移等,使其本身输出的时钟信号具有高频率准确度和稳定度,为系统提供一个优良的时钟源。 采用独立CLK时钟单板时,时钟系统支持2Mbit/s、1.5Mbit/s、2MHz、64kHz、8kHz线路时钟、GPS(Global Positioning System)/GLONASS(Global Navigation Satellite System)时钟参考源;采用时钟扣板方式时,时钟系统支持2Mbit/s、2MHz、8kHz线路时钟参考源。 时钟系统同时提供BITS时钟输出接口,可以与下级设备连接,为下级设备提供BITS时钟信号参考源。 系统支持通过软件灵活选择外部时钟参考源和输出时钟等级。 SSM简介 SSM (Synchronization Status Message) 同步状态信息,是指示时钟等级的一个信息,对于E1信号,G.704中定义用奇数帧0时隙(TS0)的Sa4~Sa8来传递SSM,对于T1信号,G.704中定义用复帧中奇数帧第一个bit组成的4kbit/s数据链路来传递SSM。 对于E1信号传递SSM信息的位置如图1所示。

STM32系统时钟配置

STM32系统时钟配置 STM32 在使用不同时钟晶振时,需要对系统时钟进行配置。下面以16MHz晶振产生72MHz时钟为例进行说明。 由于STM32可进行整数倍倍频,及可选是否2分频。因而选用16MHz 晶振时,先2分频,再倍频9倍,即可倍频为72MHz。 ①查找SystemInit() 函数,即系统时钟设置: 图1

②进入 SetSysClockTo72() 函数,如果要设置其他频率,进入对应的频率即可,如SetSysClockTo48()。 ③参考 STM32中文参考手册的6.3.2时钟配置寄存器(RCC_CFGR)。如“位17PLLXTPRE ” 所述: HSE分频器作为PLL输入(HSE divider for PLL entry) 由软件置’1’或清’0’来分频HSE后作为PLL输入时钟。只能在关闭PLL时 才能写入此位。 0:HSE不分频 1:HSE 2分频 因而,RCC_CFGR 寄存器的位17 应置“1”。 ④如图2红色框中所示, RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_PLLSRC | RCC_CFGR_PLLXTPRE | RCC_CFGR_PLLMULL)); RCC->CFGR |= (uint32_t)(RCC_CFGR_PLLSRC | RCC_CFGR_PLLMULL9|RCC_CFGR_PLLXTPRE); 添加红色字部分即可完成2分频,则可将16MHz的时钟分频为 8MHz。其实,查找RCC_CFGR_PLLXTPRE宏定义可知: #define RCC_CFGR_PLLXTPRE ((uint32_t)0x00020000) 实际上就是将位 17置1。 而RCC_CFGR_PLLMULL9中的9即是倍频倍数。(8*9=72 MHz)

时钟配置概述

时钟配置概述 时钟同步是一个容易忽视的问题,由于某方面的原因,由于时钟不配置也不会影响业务的正常开通,有时在新开站点的时候很容易就忽略对时钟的配置。造成SDH网络长期处于时钟不健康运行的状态。很容易造成SDH网络性能的下降,误码增加,基站通话质量下降,甚至引起基站掉话,严重会引起基站中断。对整个SDH网络性能将会造成极大的影响。 今天我们就简单的讨论一下时钟的跟踪原理以及我们目前所使用的成熟的时钟跟踪技术。 SDH网络,众所周知,是一个全网同步的网络。要求SDH 整个大网必须跟踪同一个时钟源。那么,如果全网不跟踪同一个BITS时钟会有什么结果呢。 结果是,刚开始网络性能各方面能够正常运行,但经过一段时间后。如48小时后,网络会逐渐出现性能劣化,通过网管可以发现大量的指针调整。 那么,既然全网跟踪同一个时钟那么重要,那么我们就全网都跟踪同一个时钟嘛,但是不是跟踪了同一个时钟,实现了全网的同步,时钟这块就算配置完了,网络性能就能达到要求了? 答案是肯定的。SDH网络时钟很简单,只要保障的全网跟踪同一个时钟,即全网同步(我们常说的主从同步)就完全没有问题。 下面以图为例说明时钟跟踪全网同步的配置模型及配置步

骤。 这里以一个相交环下挂一个链的组网方式来介绍时钟的配置步骤。组网拓扑图如下所示: 其中5-1指的是5槽位1光口,其它以些类推。A点跟踪BITS时钟。D点跟踪11光口和8光口来的时钟,为了防止时钟成环,需启用扩展SSM协议。B、C、E、F、G、均跟踪环路的两个方向,并启用扩展SSM协议。这里需要指出,B、C两个点由于在两个环上。这里就只跟踪离BITS时钟最近的两个方向,实际上就是跟踪两个2.5G光口的时钟信号。 配置完成后,时钟跟踪的方向如图所示:

STM32芯片时钟配置

对STM32进行软件开发时,最基本的就是对STM32芯片进行时钟和端口配置,然后是对项目所用到的片上资源进行配置并驱动,下面给出时钟和端口配置代码,该代码几乎涵盖了片上所有时钟和端口配置项目,可根据自己需要进行删除不必要的配置项: /****************************************************************** * Function Name :RCC_Configuration 复位时钟控制配置 * Description : Configures the different system clocks. * Input : None * Output : None * Return : None *******************************************************************/ void RCC_Configuration(void) { /* system clocks configuration -----系统时钟配置----*/ /* RCC system reset(for debug purpose) */ RCC_DeInit(); //将外设RCC寄存器重设为缺省值 /* Enable HSE */ RCC_HSEConfig(RCC_HSE_ON);//开启外部高速晶振(HSE) /* Wait till HSE is ready */ HSEStartUpStatus = RCC_WaitForHSEStartUp();//等待HSE起振 if(HSEStartUpStatus == SUCCESS) //若成功起振,(下面为系统总线时钟设置) { /* Enable Prefetch Buffer */

STM32时钟详细配置

STM32时钟配置 STM32时钟配置步骤// 开启HSI时钟寄存器操作 1).开启高速时钟HSE // 设置时钟控制寄存器RCC_CR 位16 置1使能 RCC->CR|= 0x00010000; 位16 :HSEON:外部高速时钟使能 当进入待机和停止模式时,该位由硬件清零,关闭4-16MHz外部振荡器。当外部4-16MHz 振荡器被用作或被选择将要作为系统时钟时,该位不能被清零。 2).等待高速时钟就绪// 读取时钟控制寄存器RCC_CR位17为1就位 while(!(RCC-> CR>>17)); 位17:HSERDY:外部高速时钟就绪标志 由硬件置’1’来指示外部4-16MHz振荡器已经稳定。在HSEON位清零后,该位需要6个外部4-25MHz振荡器周期清零。 3).设置APB1,APB2,AHB分频系数// 设置时钟配置寄存器RCC_CFGR RCC_CFGR=0x00000400; (AHB :位4-7, (低速)APB1 :位8-10, (高速)APB2 :位11-13) 位7:4:HPRE[3:0]:AHB预分频(AHB Prescaler)0xxx:SYSCLK不分频 位10:8:PPRE1[2:0]:低速APB预分频(APB1) 100:HCLK 2分频 位13:11:PPRE2[2:0]:高速APB预分频(APB2) 0xx:HCLK不分频 4).设置PLL倍频// 配置时钟配置寄存器RCC_CFGR 位18-21 RCC_CFGR|=7<<18; 位21:18:PLLMUL:PLL倍频系数0111:PLL 9倍频输出 5).PLL输入时钟源选择// 配置时钟配置寄存器RCC_CFGR 位16 RCC_CFGR|=1<<16; 位16:PLLSRC:PLL输入时钟源(PLL entry clock source) 1:HSE时钟作为PLL输入时钟。由软件置’1’或清’0’来选择PLL输入时钟源。只能在关闭PLL时才能写入此位6).设置FLASH延时周期//48ACR|=0x32; 7).PLL使能// 设置时钟控制寄存器RCC_CR 位24 RCC_CR|=0X01000000; 位24:PLLON:PLL使能1:PLL使能当进入待机和停止模式时,该位由硬件清零。当PLL时钟被用作或被选择将要作为系统时钟时,该位不能被清零。 8).等待PLL就绪// 设置时钟控制寄存器RCC_CR 位25置1锁定 while(!(RCC_CR>>24)); 位25:PLLRDY:PLL时钟就绪标志1:PLL锁定PLL锁定后由硬件置’1’。 9).设置PLL作为system时钟// 配置时钟配置寄存器RCC_CFGR 位0-1 :10 RCC_CFGR|=0X00000002; 位1:0 SW[1:0]:系统时钟切换10:PLL输出作为系统时钟 在从停止或待机模式中返回时或直接或间接作为系统时钟的HSE出现故障时,由硬件强制选择HSI作为系统时钟(如果时钟安全系统已经启动) 10).等待system时钟稳定// 查看时钟配置寄存器RCC_CFGR位2-3 :10 while((RCC->CFGR & (uint32_t)0x0c) != (uint32_t)0x08) 位3:2:SWS[1:0]:系统时钟切换状态10:PLL输出作为系统时钟; 由硬件置’1’或清’0’来指示哪一个时钟源被作为系统时钟

37x时钟配置

September 2012Doc ID 023352 Rev 11/16 AN4132Application note Clock configuration tool for STM32F37x/STM32F38x microcontrollers Introduction This application note presents the clock system configuration tool for the STM32F37x and STM32F38x microcontroller families. The purpose of this tool is to help the user to configure the microcontroller clocks, taking into consideration product parameters such as power supply and Flash access mode. Note:The clock configuration tool for STM32F37xx and STM32F38xx microcontrollers will be referred to as “STM32F37x clock configuration tool“ throughout the document. “STM32F37x“ will refer to STM32F37xx and STM32F38x. The configuration tool is implemented in the “STM32F37x_Clock_Configuration_VX.Y .Z.xls” file which is supplied with the STM32F37x Standard Peripherals Library and can be downloaded from https://www.wendangku.net/doc/9f14061763.html, . This tool supports the following functions for the STM32F37x: ● Configuration of the system clock, HCLK source and output frequency ● Configuration of the Flash latency (number of wait states depending on the HCLK frequency)● Setting of the PCLK1, PCLK2, TIMCLK (timer clocks) and I2SCLK frequencies ●Generation of a ready-to-use system_stm32f37x.c file with all the above settings (STM32F37x CMSIS Cortex-M4 Device Peripheral Access Layer System Source File)The STM32F37x_Clock_Configuration_VX.Y .Z.xls is referred to as “clock tool” throughout this document. Before using the clock tool, it is essential to read the STM32F37x microcontroller reference manual (RM0313). This application note is not a substitute for the reference manual.This tool supports only the STM32F37x devices. For VX.Y .Z, please refer to the tool version, example V1.0.0. Table 1 lists the microcontrollers concerned by this application note. Table 1.Applicable products Type Applicable products Microcontrollers STM32F37x STM32F38x https://www.wendangku.net/doc/9f14061763.html,

STM32时钟配置方法详解

一、在STM32中,有五个时钟源,为HSI、HSE、LSI、LSE、PLL。 ①HSI是高速内部时钟,RC振荡器,频率为8MHz。 ②HSE是高速外部时钟,可接石英/陶瓷谐振器,或者接外部时钟源,频率范围为4MHz~16MHz。 ③LSI是低速内部时钟,RC振荡器,频率为40kHz。 ④LSE是低速外部时钟,接频率为32.768kHz的石英晶体。 ⑤PLL为锁相环倍频输出,其时钟输入源可选择为HSI/2、HSE或者HSE/2。倍频可选择为2~16倍,但是其输出频率最大不得超过72MHz。 二、在STM32上如果不使用外部晶振,OSC_IN和OSC_OUT的接法:如果使用内部RC振荡器而不使用外部晶振,请按照下面方法处理: ①对于100脚或144脚的产品,OSC_IN应接地,OSC_OUT应悬空。 ②对于少于100脚的产品,有2种接法:第1种:OSC_IN和OSC_OUT分别通过10K电阻接地。此方法可提高EMC性能;第2种:分别重映射OSC_IN 和OSC_OUT至PD0和PD1,再配置PD0和PD1为推挽输出并输出'0'。此方法可以减小功耗并(相对上面)节省2个外部电阻。 三、用HSE时钟,程序设置时钟参数流程: 01、将RCC寄存器重新设置为默认值RCC_DeInit; 02、打开外部高速时钟晶振HSE RCC_HSEConfig(RCC_HSE_ON); 03、等待外部高速时钟晶振工 作HSEStartUpStatus = RCC_WaitForHSEStartUp(); 04、设置AHB时钟RCC_HCLKConfig; 05、设置高速AHB时钟RCC_PCLK2Config; 06、设置低速速AHB时钟RCC_PCLK1Config; 07、设置PLL RCC_PLLConfig; 08、打开PLL RCC_PLLCmd(ENABLE); 09、等待PLL工 作while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET) 10、设置系统时钟RCC_SYSCLKConfig; 11、判断是否PLL是系统时钟while(RCC_GetSYSCLKSource() != 0x08) 12、打开要使用的外设时 钟RCC_APB2PeriphClockCmd()/RCC_APB1PeriphClockCmd() 四、下面是STM32软件固件库的程序中对RCC的配置函数(使用外部8MHz晶振) /******************************************************************************* * Function Name : RCC_Configuration

路由器DCE为什么配置时钟频率

对于路由器的串口来说是有DCE和DTE之分的。在DCE端是要配置clock rate的。因为串行通信是要同一时钟的,否则这边开始发送了,那边还没开始收。关于查看一条链路的哪一 端是DCE,哪一端是DTE,可以使用命令show controllers s0/0来查看。 路由器DCE为什么配置时钟频率 DCE数据通信设备/DTE数据终端设备 区别嘛!DTE :数据终端设备。如指一般的终端或是计算机。可能是大、中、小型计算机,也可能是一台只接收数据的打印机。DCE :数据通讯设备,如modem DCE 是data Circuit-terminating equipment 的意思,即数据通信设备 DTE是data terminal equipment的意思,即数据终端设备 路由器通常是DTE设备,modem、GV转换器等等传输设备通常被规定为DCE 比如一台路由器,它处于网络的边缘,它有一个SO 口需要从另一台路由器中学习到一些参 数,具体实施时,我们就不需在这个S0 口配时钟速率”它从对方学到。这时它就是DTE,而对方就是DCE 当路由器作为DCE用来提供时钟频率时是需要设置的 做路由器的背靠背实验时两个路由器一个做为DCE 一个做为DTE,做DCE的需要配置clock rate ISDN用64000,或是分时隙的用64000,只有普通拨号串口用56000,设定好DTE,DCE,DTE,DCE的时钟速率要一致 如果不能确定哪台路由器拥有这条线缆的DTE 端,哪台路由器拥有DCE 端,可以利用show controller serial 0 来确定 DCE 一方提供时钟,DTE不提供时钟,但它依靠DCE提供的时钟工作。比如PC机和MODEM 之间的连接。PC机就是一个DTE,MODEM是一个DCE 同步通信都要有时钟进行同步的,配置时钟频率就要告诉这个端口是以自身的时钟为准,还是取线路时钟,或者取外部的DTE时钟。只有确立的同步方式,串口才可以好好的工作, 否则不是不通,就是乱码,用不了的! 在同步通信里,都必须有的,而异步通信就以校验,停止位为特点进行数据传输。 现在IP接口的路由器大为应用,这样通过串口进行联网的都很少了

STM32学习笔记(关于时钟)

STM32学习----时钟(转载) 在STM32中,有五个时钟源,为HSI、HSE、LSI、LSE、PLL。 ①、HSI是高速内部时钟,RC振荡器,频率为8MHz。 ②、HSE是高速外部时钟,可接石英/陶瓷谐振器,或者接外部时钟源,频率范围为4MHz~16MHz。 HSE/LSE时钟源 ③、LSI是低速内部时钟,RC振荡器,频率为40kHz。 ④、LSE是低速外部时钟,接频率为32.768kHz的石英晶体。 ⑤、PLL为锁相环倍频输出,其时钟输入源可选择为HSI/2、HSE或者HSE/2。倍频可选择为2~16倍,但是其输出频率最大不得超过72MHz。 其中40kHz的LSI供独立看门狗IWDG使用,另外它还可以被选择为实时时钟RTC的时钟源。另外,实时时钟RTC的时钟源还可以选择LSE,或者是HSE的128分频。RTC的时钟源通过RTCSEL[1:0]来选择。 STM32中有一个全速功能的USB模块,其串行接口引擎需要一个频率为48MHz 的时钟源。该时钟源只能从PLL输出端获取,可以选择为1.5分频或者1分频,也就是,当需要使用USB模块时,PLL必须使能,并且时钟频率配置为48MHz或72MHz。 另外,STM32还可以选择一个时钟信号输出到MCO脚(PA8)上,可以选择为PLL输出的2分频、HSI、HSE、或者系统时钟。 系统时钟SYSCLK,它是供STM32中绝大部分部件工作的时钟源。系统时钟可选择为PLL输出、HSI或者HSE。系统时钟最大频率为72MHz,它通过AHB分频器分频后送给各模块使用,AHB分频器可选择1、2、4、8、16、64、128、256、512分频。其中AHB分频器输出的时钟送给5大模块使用: ①、送给AHB总线、内核、内存和DMA使用的HCLK时钟。 ②、通过8分频后送给Cortex的系统定时器时钟。 ③、直接送给Cortex的空闲运行时钟FCLK。 ④、送给APB1分频器。APB1分频器可选择1、2、4、8、16分频,其输出一路供APB1外设使用(PCLK1,最大频率36MHz),另一路送给定时器(Timer)2、3、4倍频器使用。该倍频器可选择1或者2倍频,时钟输出供定时器2、3、4使用。

相关文档