The fifth program of STM8S208R8 --- clock CCO output verification

Publisher:HeavenlyMelodyLatest update time:2016-10-12 Source: eefocusKeywords:STM8S208R8 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
#include

/************************************
Verify the clock output function of PE0 pin, and use an oscilloscope to view the output 24M clock

After connecting to ST-LINK, in DEBUG mode,
select crystal clock source in Option Bytes EXTCLK
Confirm Flash_Wait_States is set to 1
************************************/
void GPIO_INIT() //PE0 pin CCO output enable, according to the manual, it can be set to pull-up input or push-pull output
{
  PE_DDR_DDR0=1;
  PE_CR1_C10=1; //PE push-pull output
}
void CLK_INIT()
{
  CLK_ECKR_HSEEN=1; //Open external
  while(!CLK_ECKR_HSERDY); //Wait for external clock to be ready
  CLK_SWCR_SWEN=1; //Enable clock switching
  CLK_SWR=0XB4; //HSE is the main clock source
  while(!CLK_SWCR_SWIF); //Wait for switching to succeed
  CLK_SWCR_SWEN=0; //Clear switching flag
  CLK_CKDIVR=0; //No frequency division
}
void CCO_INIT()
{
  CLK_CCOR_CCOSEL=2; //Modify it according to the manual and you can see the external clock we want, 24M or 16M 128K, etc.
  CLK_CCOR_CCOEN=1; //Enable clock output
}
void main()
{
  GPIO_INIT();
  CLK_INIT();
  CCO_INIT();
  while(1);
}

/****************************************************************
I have to mention here that in the iostm8s208r8.h file that comes with IAR for STM8S, the O in OPQ is written as zero in CCOBSY.
If you use it, you must pay attention to it. At least the software I installed has such a problem, although it is not important
************************************************************/

Keywords:STM8S208R8 Reference address:The fifth program of STM8S208R8 --- clock CCO output verification

Previous article:The sixth program of STM8S208R8 --- interrupt and navigation key
Next article:The fourth program of STM8S208R8 --- external crystal clock source verification

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号