ATMEL AT89C51 -> STC89C52RC-40I-PDIP

Flash

8k bytes

RAM

512 bytes

I

-40C~+85C

12 clocks = 1 machine cycle

AMTEL AT89C52 PORT Pin

AT89C52

Port Pin Alternate Functions
P1.0 T2 (external count input to Timer/Counter 2), clock-out
P1.1 T2EX (Timer/Counter 2 capture/reload trigger and direction control)
P1.5 MOSI (used for In-System Programming)
P1.6 MISO (used for In-System Programming)
P1.7 SCK (used for In-System Programming)
P3.0 RXD(serial input port)
P3.1 TXD(serial output port)
P3.2 INT0(external interrupt 0)
P3.3 INT1(external interrupt 1)
P3.4 T0(timer 0 external input)
P3.5 T1(timer 1 external input)
P3.6 WR(external data memory write strobe)
P3.7 RD(external data memory read strobe)

I/O Port programming

All port pin on STC89xx series may be independently configured to one of four modes: quasi-bidirectional(standard 8051 port output), push-pull output, input-only or open-drain output

Block diagram

AT89C52

Onboard Peripheral Schemas

I/O Port

P0.0~P0.7, P1.0~P1.7, P2.0~P2.7, P3.0~P3.7 All port pins on STC89xx series may be independently configured to one of four modes : quasi-bidirectional (standard 8051 port output), push-pull output, input-only or open-drain output. All port pins default to quasi-bidirectional after reset. Each one has a Schmitt-triggered input for improved input noise rejection.

Special Function Registers

A map of the on-chip memory area called the Special Function Register (SFR)

STC89xx SFR

Addressing Modes

The CPU can access data in various ways, which are called addressing modes, Addressing modes are an integral part of each computer's instruction set. They allow specifying the source or destingation of data in different ways, depending on the programming situation. There eight modes available:

Memory Space

Program (CODE) memory

Program memory

Data memory

Data memory

On-chip Scratch-Pad RAM

Auxiliary RAM

External RAM

Memory Type

Memory Type Description (Size)
code Code memory (64 Kbytes)
data Directly addressable internal data memory (128 bytes)
idata Indirectly addressable internal data memory (256 bytes)
bdata Bit-addressable internal data memory (16 bytes)
xdata External data memory (64 Kbytes)
pdata Paged external data memory (256 bytes)

Memory model

Memory Model Description
Small Variables default to the internal data memory (data)
Compact Variables default to the first 256 bytes of external data memory (pdata)
Large Variables default to external data memory (xdata)

Bit addressable RAM

Data types

Data Type Size in Bits Data Range/Usuage
unsigned char 8-bit 0~255
(signed) char 8-bit -128~+127
unsigned int 16-bit 0 ~ 65535
(signed) int 16-bit -32768~+32767
sbit 1-bit SFR bit-addressable only
bit 1-bit RAM bit-addressalbe only
sfr 8-bit RAM addresses 80H-FFH only

Power-on Reset

Upon applying a high pulse to REST(Pin 9), the microcontroller will reset and terminate all activites, this is often referred to as a power-on reset

Register Reset Value
PC 0000
DPTR 0000
ACC 00
PSW 00
SP 07
B 00
P0-P3 FF

Power on reset

Interrupt

ISR

Interrupt system diagram of STC89xx series

ATMEL 80C51 CPU Timing

Fetch/Execute Sequences

A machine cycle consists of 6 states (12 oscillator periods). Each state is divided into a Phase 1 half, during which the Phase 1 clock is active, and a Phase 2 half, during which the Phase 2 clock is active. Thus, a machine cycle consists of 12 oscillator periods, numbered S1P1 (State 1, Phase 1), through S6P2 (State 6, Phase 2). Each phase lasts for one oscillator period. Each state lasts for two oscillator periods. Typically, arithmetic and logical operations take place during Phase 1 and internal register-to-register transfers take place during Phase 2. The diagrams above show the fetch/execute timing referenced to the internal states and phases. Since these internal clock signals are not user accessible, the XTAL2 oscillator signal and the ALE (Address Latch Enable) signal are shown for external reference. ALE is normally activated twice during each machine cycle: once during S1P2 and S2P1, and again during S4P2 and S5P1. Execution of one-cycle instruction begins at S1P2, when the opcode is latched into the Instruction Register. If it is a two-byte instruction, the second byte is read during S4 of the same machine cycle. If it is one-byte instruction, there is still a fetch at S4, but the byte read (which would be the next opcode), is ignored, and the Program Counter is not incremented. In any case, execution is complete at the end of S6P2. Figure A and Figure B show the timing for a 1-byte, 1-cycle instruction and for a 2-byte, 1-cycle instruction. Most 80C51 instructions execute in one cycle. MUL (multiply) and DIV (divide) are the only instructions that take more than two cycles to complete. They take four cycles. Separately, two codes bytes are fetched from Program Memory during every machine cycle. The only exception to this is when a MOVX instruction is executed. MOVX is a 1- byte 2-cycle instruction that accesses external Data Memory. During a MOVX, two fetches are skipped while the external Data Memory is being addressed and strobed. Figure C and Figure D show the timing for a normal 1-byte, 2-cycle instruction and for a MOVX instruction.

Development

STC-ISP

Checking target MCU ...
  MCU type: STC89C52RC/LE52RC
  F/W version: 6.6.4C

Current H/W Option:
  . Current clock frequency: 11.030MHz
  . System use 12T mode
  . Oscillator gain is HIGH
  . Any reset source can stop WatchDog if WatchDog timer is running
  . Internal XRAM is ENABLE
  . ALE pin behaves as ALE function pin
  . Do not detect the level of P1.0 and P1.1 next download
  . Do not erase user EEPROM area at next download

  MCU type: STC89C52RC/LE52RC
  F/W version: 6.6.4C


Re-handshaking ... Successful           [0.594"]
Current Baudrate: 115200
Erasing MCU flash ...  OK !     [0.313"]
Programming user code ... OK !      [0.734"]


  Complete !(2023-01-21 10:51:43)

Header file

Sample codes

Expirements


  1. include
  2. sample
  3. sensors
  4. io
  5. peripherals
  6. scon
  7. tmod

Page Source