Program counter f2 (PC)
The program counter gives the 2048x12 ROM address on the chip. The program counters of different models and their two-level stacks are 9-11 bits wide, as shown in Table 1.
Keywords:PIC16C5X
Reference address:PIC16C5X microcontroller data memory
The program counter gives the 2048x12 ROM address on the chip. The program counters of different models and their two-level stacks are 9-11 bits wide, as shown in Table 1.
Table 1 Program counter PC and stack size | |||
model | PC width/bit | Stack width/bits | |
PIC16C54/55 | 9 | 9 | |
PIC16C56 | 10 | 10 | |
PIC16C57 | 11 | 11 |
After the system is reset, PC is all "1". The PC automatically increases by "1" for each instruction executed by the program, unless the program instruction itself changes the content of PC (such as program jump, interrupt service, etc.). The following instructions will change the value of PC. [1]. "GOTO" instruction: allows the lower 8 bits of the program counter to be loaded directly. For PIC16C56/57/58, the highest bit of PC is determined by the two page select bits PA0 and PA1 (that is, bits 5 and 6 of the status register). This instruction allows jumping to any position on any page. [2]. "CALL" instruction: first push the current PC value into the stack, then clear the 9th bit to "0", and load the lower 8 bits into the program counter PC. For PIC16C56/57/58, the upper two bits of PC are loaded into the page select bits PA0 and PA1. [3]. "RETLW" instruction: This return instruction directly reloads the top of the stack into the PC. [4]. The program counter can be changed by a certain instruction (such as MOVWF f2, ADDWF f2 or BSF f2,5). The calculation result will be loaded into the lower 8 bits of PC, and the 9th bit will be cleared to "0". For PIC16C56/57/58, the upper two bits of PC are loaded into the page select bits PA0 and PA1. It should be noted that: when executing "CALL" or other instructions that change the PC value, the 9th bit will be cleared to "0". When all subroutine call instructions and jump instructions that need to be calculated, the branch program should be placed in the first 256 units of any page (512 bytes) (addresses are 000-0FFH, 200-2FFH, 400-4FFH, 600-6FFH respectively). In the case of multiple program memory page selection (valid for PIC16C56/57/58), when the program counter points to the last address of the storage page, it can still add 1 and continue to execute to the next page, but the PA0, PA1 page selection bits will not change. Subsequent "GOTO", "CALL", "ADDWF f2", "MOVWFf2" and other instructions will return to the original page unless the page selection bits are changed in the program. For example, the NOP instruction is located at 1FFH (page 0), and the PC adds 1 to 200 (page 1). A "GOTO XXX" instruction at 200 will return to the XXX address of page 0 (if the page preselection bit of f3 is "0"). In the RESET state, PA0 and PA1 are cleared to "0", and page 0 will become the preselected page. At the same time, the program counter PC will address the last unit of the last page. Therefore, the "GOTO" instruction at this position will automatically return to page 0 for execution. |
Previous article:PIC16C5X microcontroller status register
Next article:PIC16C5X microcontroller program memory
- Popular Resources
- Popular amplifiers
- Virtualization Technology Practice Guide - High-efficiency and low-cost solutions for small and medium-sized enterprises (Wang Chunhai)
- Multi-port and shared memory architecture for high-performance ADAS SoCs
- Practical Development of Automotive FlexRay Bus System (Written by Wu Baoxin, Guo Yonghong, Cao Yi, Zhao Dongyang, etc.)
- Introduction to Deep Learning 2: Homemade Framework (Yasuki Saito)
Recommended Content
Latest Microcontroller Articles
He Limin Column
Microcontroller and Embedded Systems Bible
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
MoreSelected Circuit Diagrams
MorePopular Articles
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
MoreDaily News
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
Guess you like
- [ESP32-Audio-Kit Audio Development Board Review] Display Driver for Color OLED Screen
- 【EVK-NINA-B400 Evaluation Kit】+Hardware
- The impact of single-ended and differential outputs of isolated op amps on sampling performance in motor drive applications
- 5G is not used yet, but 4G is getting slower and slower?
- Download gift | Keysight Technologies e-book "Increase yield and reduce risk by understanding the basics of test accuracy"
- Analysis of conducted and radiated interference of power modules
- Regarding STM32 domestic alternatives, I would like to recommend some
- Introduction to MCU ISP, IAP, ICP, JTAG, SWD programming technology
- Why do we need derivatives to determine the internal resistance of voltage and current sources?
- I found that several posts I replied to yesterday were gone.