Mobile wallpaper 1Mobile wallpaper 2Mobile wallpaper 3Mobile wallpaper 4Mobile wallpaper 5Mobile wallpaper 6Mobile wallpaper 7Mobile wallpaper 8
508 words
3 minutes
HCS12 Register Summary Sheet

🧭 HCS12 Register Summary Sheet#


⚡ Analog-to-Digital Converter (ATD)#


ATDCTL2 — Control Register 2#

Full Name: ATD Control Register 2
Purpose: Controls ADC power, fast flag clearing, external trigger, and interrupt enable.

BitNameFunction
7ADPU1 = Power up ATD (must set before use)
6AFFCFast flag clear; 1 = read result clears flag
5-4ETRIGLE / ETRIGPSelect edge/level for external trigger:
00 falling, 01 rising, 10 low, 11 high
3ETRIGEEnable external trigger
2ASCIEEnable ATD sequence complete interrupt
1ASCIFATD sequence complete flag

Controls: Power, interrupt, and trigger behavior.

Example:

LDAA #%10000000 ; ADPU=1 → power up ATD
STAA ATDCTL2

ATDCTL3 — Control Register 3#

Full Name: ATD Control Register 3
Purpose: Sets conversion sequence length and result register mode.

BitsNameFunction
7-4S8C–S1CSequence length (0000=8 conv, 0001=1 conv …)
3FIFO1 = FIFO mode (wrap results), 0 = normal
2-0Unused

Controls: Number of conversions per sequence + how results are stored.

Example:

LDAA #%00000001 ; 1 conversion, normal mode
STAA ATDCTL3

ATDCTL4 — Control Register 4#

Full Name: ATD Control Register 4
Purpose: Sets resolution, sample time, and ADC clock speed (prescaler).

BitNameFunction
7SRES80=10-bit, 1=8-bit resolution
6-5SMP1Sample time (00=2, 01=4, 10=8, 11=16 ATD clocks)
4-0PRS4–PRS0Prescaler (00101=÷12, 01101=÷24, 10111=÷48)

Controls: Conversion precision and timing.

Example:

LDAA #%00010101 ; 10-bit, sample=2, prescaler=÷12
STAA ATDCTL4

ATDCTL5 — Control Register 5#

Full Name: ATD Control Register 5
Purpose: Starts a new conversion and selects channel/mode.

BitNameFunction
7DJM0=left-justified, 1=right-justified result
6DSGN0=unsigned, 1=signed
5SCAN0=single sequence, 1=continuous mode
4MULT0=single channel, 1=multi-channel
2-0CC:CBChannel select (000=AN0 → 111=AN7)

Controls: Channel selection, scan mode, justification, data format.

Example:

LDAA #%10000000 ; right-justified, single conv., channel AN0
STAA ATDCTL5

⏱️ Timer System Registers#


TSCR1 — Timer System Control Register 1#

Full Name: Timer System Control Register 1
Purpose: Enables the timer module and manages flag clearing.

BitNameFunction
7TEN1 = enable timer
6TFFCA1 = fast flag clear mode
5-0Unused

Controls: Turns the timer on/off, sets flag behavior.

Example:

BSET TSCR1,%10000000 ; enable timer

TSCR2 — Timer System Control Register 2#

Full Name: Timer System Control Register 2
Purpose: Controls prescaler and overflow interrupt behavior.

BitNameFunction
7TOIEnable timer overflow interrupt
5TCRE1 = reset TCNT after OC7 event
2-0PR2–PR0Prescaler (000=÷1, 001=÷2 … 111=÷128)

Controls: Timer speed and overflow interrupt enable.

Example:

LDAA #%00000111 ; prescaler ÷128
STAA TSCR2

TFLG2 — Timer Flag Register 2#

Full Name: Timer Flag Register 2
Purpose: Indicates if the timer has overflowed.

BitNameFunction
7TOF1 = timer overflow flag

Controls: Overflow event tracking.

Example:

BRCLR TFLG2,$80,Wait ; loop until overflow flag set
BSET TFLG2,$80 ; clear overflow flag

TIOS — Timer Input Capture / Output Compare Select#

Full Name: Timer I/O Select Register
Purpose: Chooses whether each timer channel acts as input capture or output compare.

BitNameFunction
7-0IOS7–IOS00 = input capture, 1 = output compare

Controls: Capture/compare mode for 8 timer channels.

Example:

BSET TIOS,%00000001 ; make channel 0 output compare

⚙️ Combined Example: Blinking LED using Timer#

BSET DDRP,%11111111 ; Port P as output
BSET TSCR1,%10000000 ; Enable timer
LDAA #%00000111
STAA TSCR2 ; Prescaler ÷128 for slower timing
Loop:
BRCLR TFLG2,$80,Loop ; Wait for overflow
BSET TFLG2,$80 ; Clear overflow flag
EORA #%10000000 ; Toggle LED on PP7
STAA PTP
BRA Loop

💡 How it works:
Timer counts up → when it overflows, TOF flag is set → loop detects overflow, clears flag, toggles LED → repeats.


✅ Quick Summary Table#

RegisterFull NameControls / Purpose
ATDCTL2ATD Control Reg 2Power, trigger, interrupts
ATDCTL3ATD Control Reg 3Sequence length, FIFO mode
ATDCTL4ATD Control Reg 4Resolution, sample time, prescaler
ATDCTL5ATD Control Reg 5Channel, justification, scan, start conversion
TSCR1Timer System Control Reg 1Enable timer, fast flag clear
TSCR2Timer System Control Reg 2Prescaler, overflow interrupt
TFLG2Timer Flag Reg 2Overflow flag (TOF)
TIOSTimer I/O SelectCapture vs compare mode
HCS12 Register Summary Sheet
https://mizuki.mysqil.com/posts/hcs12-summary/
Author
Oscar Wang
Published at
2025-10-21
License
Unlicensed

Some information may be outdated

封面
示例歌曲
示例艺术家
封面
示例歌曲
示例艺术家
0:00 / 0:00