PIC16-bit MCU CAN (2) Thoroughly understand the clock

Publisher:SereneNatureLatest update time:2016-08-28 Source: eefocusKeywords:PIC Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
I have always been reading reference materials and books when writing programs. This time, I don't have any information about the 16-bit single-chip dsPIC33EP32GP502. So I took the opportunity to study it in depth! First, let's look at the choice of oscillator.
First look at the clock block diagram:PIC16-bit MCU CAN (2) Thoroughly understand the clock - zmurder - Qidian's blog
 
We are using an external crystal oscillator, so the configuration is HS, FCY is the CPU clock, FP is the peripheral clock, FCY=FP (except for doze mode). FCY=Fosc/2. That is, the CPU clock is 1/2 of the crystal frequency. There is also frequency division below. DOZE<2:0>: 011 = FCY is divided by 8 (default) Processor clock division ratio selection bit.
Therefore, the actual FCY = 0.5MHz (using an 8M external crystal oscillator and dividing it by eight 8/2/8 = 0.5MHz).
 
Take a look at the description of the oscillator selection configuration bits:
PIC16-bit MCU CAN (2) Thoroughly understand the clock - zmurder - Qidian's blog
  What we need to see here is the second column of the FOSCSEL configuration bit, which is the register address. What needs to be set is IESO<7> and FNOSC<2:0>
Take a look at the description in the header file p33EP32GP502.h:
 
/* Register FOSCSEL (0x57f8) */
 
extern __attribute__((space(prog))) int _FOSCSEL;
#define _FOSCSEL(x) __attribute__((section("__FOSCSEL.sec"),space(prog))) int _FOSCSEL = (x);
 
/*
** Only one invocation of FOSCSEL should appear in a project,
** at the top of a C source file (outside of any function).
**
** The following constants can be used to set FOSCSEL.
** Multiple options may be combined, as shown:
**
** _FOSCSEL( OPT1_ON & OPT2_OFF & OPT3_PLL )
**
** Oscillator Source Selection:
** FNOSC_FRC Internal Fast RC (FRC)
** FNOSC_FRCPLL Fast RC Oscillator with divide-by-N with PLL module (FRCPLL)
** FNOSC_PRI Primary Oscillator (XT, HS, EC)
** FNOSC_PRIPLL Primary Oscillator with PLL module (XT + PLL, HS + PLL, EC + PLL)
** FNOSC_LPRC Low-Power RC Oscillator (LPRC)
** FNOSC_FRCDIVN Internal Fast RC (FRC) Oscillator with postscaler
**
** Two-speed Oscillator Start-up Enable bit:
** IESO_OFF Start up with user-selected oscillator source
** IESO_ON Start up device with FRC, then switch to user-selected oscillator source
**
*/
 
#define FNOSC_FRC 0xFFF8
#define FNOSC_FRCPLL 0xFFF9
#define FNOSC_PRI 0xFFFA
#define FNOSC_PRIPLL 0xFFFB
#define FNOSC_LPRC 0xFFFD
#define FNOSC_FRCDIVN 0xFFFF
 
#define IESO_OFF 0xFF7F
#define IESO_ON 0xFFFF
From the header file
1: Register FOSCSEL (0x57f8), that is, the register address is 0x57f8, which is consistent with the table.
2: _FOSCSEL(FNOSC_PRI&IESO_OFF); We declare our configuration bits as 0XFFFA&0XFF7F=0XFF7A at the beginning of the program.
 That is, FOSCSEL = 0XFF7A. According to the register description, our configuration is an external HS oscillator and uses the user-selected oscillator source to start the device.
3: The configuration bit only indicates the oscillator to be used, and does not set the division ratio DOZE. Therefore, DOZE is still the default division ratio of 8.
 
Summary: There are several aspects to configuring the clock:
1: Configure the corresponding configuration bits to select the clock source as internal clock or external crystal oscillator, etc.
2: Configure the corresponding register to select the division ratio.
Keywords:PIC Reference address:PIC16-bit MCU CAN (2) Thoroughly understand the clock

Previous article:PIC16-bit microcontroller CAN (3) Serial port detailed explanation (232)
Next article:PIC16-bit MCU CAN (1) New project test

Recommended ReadingLatest update time:2024-11-16 13:55

PIC single chip timer initial value calculation method and several period summary
PIC timers are also used quite a lot. It is said that there are powerful software on the Internet to calculate the initial value, but I still calculate it manually. Summary————2013.8.27 PIC microcontroller timer initial value calculation method The instruction cycle of PIC is 4 oscillation cycles. Without using a fr
[Microcontroller]
PIC single chip timer initial value calculation method and several period summary
Design of stepper motor driver based on PIC16C621A and A3955
introduction Stepper motors are widely used in motion control systems with high precision requirements, such as robots, printers, floppy disk drives, plotters, mechanical valve controllers, etc. At present, the control of stepper motors mainly includes annular pulse distributors composed of dispersed devices, s
[Microcontroller]
Design of stepper motor driver based on PIC16C621A and A3955
Introduction to the input and output operation methods of PIC microcontroller
PIC microcontroller is a device that people who study microcontrollers must come into contact with, so everyone has a certain understanding of PIC microcontrollers. In the process of learning PIC microcontrollers, the internal hardware resource interface of PIC microcontrollers is one of the basic contents that everyo
[Microcontroller]
Introduction to the input and output operation methods of PIC microcontroller
Analysis of some experiences and techniques in PIC microcontroller development
PIC microcontrollers are becoming increasingly popular in China. This article introduces some experiences and techniques in software and hardware design during the development of MicroChipPIC series microcontrollers. The PIC series of microcontrollers produced by Microchip Corporation of the United States have been
[Microcontroller]
Analysis of some experiences and techniques in PIC microcontroller development
The electronic clock I wrote using a single chip microcomputer
  I have been studying microcontrollers for half a month, and I have learned almost everything. Today I will write a program to practice. Haha It has the same functions as an electronic watch, can be set, and has a very high accuracy. It uses a 1602 model LCD display. You only need to simply modify the port to
[Microcontroller]
The electronic clock I wrote using a single chip microcomputer
STM32 clock system clock setting
In STM32, there are five clock sources: HSI, HSE, LSI, LSE, and PLL. ①HSI is a high-speed internal clock, RC oscillator, with a frequency of 8MHz. ②HSE is a high-speed external clock that can be connected to a quartz/ceramic resonator or an external clock source with a frequency range of 4MHz~16MHz. ③LSI is a low-spee
[Microcontroller]
Research on clock interrupt technology in ucos ii
1 System interrupts and clock beats   1.1 System Interrupts   An interrupt is a hardware mechanism used to notify the CPU that an asynchronous event has occurred. Once the interrupt is recognized by the system, the CPU saves part (or all) of the context, that is, the value of part (or all) of the registers, and jump
[Microcontroller]
Design of automotive lighting system based on PIC16F873A and LT3476
Introduction Compared with the traditional halogen low-voltage lighting mode, the use of high-brightness LED as the lighting equipment of the automotive lighting system can bring many benefits. High-brightness LED can provide higher brightness with relatively small power consumption, and can obtain a wide dimmin
[Microcontroller]
Design of automotive lighting system based on PIC16F873A and LT3476
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
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号