Timer/Counter 0 0BH 1
External interrupt 1 13H 2
Timer/Counter 1 1BH 3
Serial port 23H 4
ADC/SPI 2BH 5
LVD 33H 6
PCA 3BH 7
The PCA, RXD, T1, and T0 output pins can be configured as external interrupts via the WAKE_CLK0 register.
5. Timer
There are two 16-bit dedicated timers T0 and T1; PCA can also be used as a timer; there is also a watchdog timer;
Timer 0 and Timer 1 are fully compatible with traditional 8051; the timer count clock source can be selected as 1/12 of the system clock or the system clock, which is set by AUXR.T0x12 and AUXR.T1x12 (when it is 0, it is the same as the traditional 51, and when it is 1, there is no frequency division).
The watchdog is controlled by the register WDT_CONTR. Setting WDT_CONTR.CLR_WDT will restart the watchdog count.
Watchdog overflow time = (12*division value*32768)/system clock
6.Serial port
2 full-duplex serial ports, with the same functions as standard 51;
Serial port 2 uses an independent baud rate generator, and serial port 1 can choose to use timer 1 or an independent baud rate generator (when AUXR.S1BRS is 0, timer 1 is used, and when it is 1, the independent baud rate generator is shared); the counting clock source of the independent baud rate generator is 1/12 of the system clock or the system clock (when AUXR.BRTx12 is 0, 1/12 of the system clock is used, and when it is 1, the system clock is used); when both serial ports use independent baud rate generators, their baud rates are the same.
The independent baud rate generator is disabled after reset and needs to be enabled by AUXR.BRTR = 1. It has an 8-bit independent baud rate counter BRT.
Serial port 2 baud rate calculation formula: Mode 0 baud rate = system clock/12 or system clock/2 (when AUXR.UART_M0x6 is 0, the same as standard 51)
Mode 1, 3 baud rate = f/(256-BRT), f is the baud rate generator counter clock source frequency
Mode 2 baud rate = 2S2SMOD*system clock/64
7. PCA (Programmable Counter Array)
Contains an independent 16-bit timer, 2/4 16-bit capture/compare modules connected to it, each module can be programmed to work in 4 operating modes: rising/falling edge capture, software timer, high-speed output, modulated pulse output.
The clock source of the PCA timer is set by CMOD and controlled by the PCA control register CCON.
The working mode of each PCA module is set by the register CCAPMn:
1) Capture mode
CCAPMn = 0x20 or 0x10 or 0x30,
The transitions of the module's external CEXn input are sampled. When a valid transition is sampled, the PCA hardware loads the values of the PCA count arrays CH, CL into the module's capture registers CCAPnH, CCAPnL.
2) Software timer mode
CCAPMn=0X48,
3) High-speed output mode
CCAPMn=0X4C,
4) Pulse Width Modulation (PWM) Mode
CCAPMn = 0x42,
Since all PCA modules share the same PCA timer, their output frequencies are the same, and the output duty cycle of each module changes independently. When the value of CL is less than (EPCnL, CCAPnL), the output is low, otherwise the output is high. The output frequency of PWM = PCA clock frequency/256.
8.A/D conversion
There are 8-channel 10-bit high-precision ADC, the speed of which can reach 100KHZ; 8-channel voltage input A/D, which can be used for temperature detection, battery voltage detection, key scanning, and spectrum detection.
The port to be used as A/D must be set to open-drain output or input-only mode.
The A/D conversion is controlled by the register ADC_CONTR, and the conversion result is stored in ADC_DATA (upper 8 bits) and ADC_LOW2 (lower 2 bits)
9. EEPROM usage
The chip integrates a data FLASH area, which can be read, written and erased through IAP.
Related registers IAP_CONTR, IAP_CMD, IAP_TRIG, IAP_DATA, IAP_ADDRH, IAP_ADDRL
1) Erase operationIAP_CMD=0x03;
IAP_TRIG=0X5A;
IAP_TRIG=0XA5;
IAP_ADDRL=addrl;
IAP_CONTR=0X81;
IAP_CMD=READ;
IAP_TRIG=0X5A;
IAP_TRIG=0XA5;
_nop_();
_nop_();
*rdata=IAP_DATA;
3) Write operation
Previous article:51 Notes on MEGAWIN
Next article:51 Notes on Winbond (Part 2)
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Detailed explanation of intelligent car body perception system
- How to solve the problem that the servo drive is not enabled
- Why does the servo drive not power on?
- What point should I connect to when the servo is turned on?
- How to turn on the internal enable of Panasonic servo drive?
- What is the rigidity setting of Panasonic servo drive?
- How to change the inertia ratio of Panasonic servo drive
- What is the inertia ratio of the servo motor?
- Is it better for the motor to have a large or small moment of inertia?
- What is the difference between low inertia and high inertia of servo motors?
- How to choose FPGA development board
- Let’s discuss: When you make PPT, do you make the template yourself or download it from the Internet?
- TI points exchanged for E coins, but not received
- EEWORLD University Hall ---- Data Structure and Algorithm Peking University Zhang Ming
- NUCLEO_G431RB Review: Get G431
- Thank you for having you +EE @【chat, laugh, make noise】
- Op amp basics: DC biasing of active circuits
- Two Application Examples of EPROM in Single Chip Microcomputer Development
- How to write C/C++ code in DSP? + Data types in c6000
- What role does power supply potting glue play in power supplies, and why do power supplies need potting?