SN8P2604
8-Bit Micro-Controller
SONiX TECHNOLOGY CO., LTD
Page 104
Version 1.1
11.5.6 PWM DUTY
PWM duty of SN8P2604 is controlled by ALOAD1, TC1OUT bits.
PWM1OUT = 1
ALOAD1 TC1OUT TC1R Boundary PWM duty range
Max PWM
Frequency
(Fcpu = 4M)
Note
0
0
00h to FFh
0/256 ~ 255/256
7.8125K
Overflow per 256 count
0
1
00h to 3Fh
0/64 ~ 63/64
31.25K
Overflow per 64 count
1
0
00h to 1Fh
0/32 ~ 31/32
62.5K
Overflow per 32 count
1
1
00h to 0Fh
0/16 ~ 15/16
125K
Overflow per 16 count
S8KD-2 ICE doesn’t support PWM duty setting function. SONIX provides PWM Duty setting macro. Users can use it to
emulate PWM function and don’t affect other functions. The macro is built in assembler software. Users have to set
ICE_MODE as ICE or real chip.
Syntax: @PWM1_MAX_DUTY Max_Duty
Max_Duty
TC1 Overflow
Boundary
PWM Duty Range
PWM Resolution
256
FFh to 00h
0/256 ~ 255/256
8-bit
64
3Fh to 40h
0/64 ~ 63/64
6-bit
32
1Fh to 20h
0/32 ~ 31/32
5-bit
16
0Fh to 10h
0/16 ~ 15/16
4-bit
Example: Set PWM Max. Duty = 64,Duty = 2:1.
CHIP SN8P2604
.DATA
ICE_MODE
EQU
0
; Set real chip mode.
INCLUDESTD SN8P2X_ICE.H
.CODE
User
program…
@PWM1_MAX_DUTY
64
; Set PWM1 max. duty as 64.
MOV
A,#42
; 42 = 63 (Max. TC1R) / 3 X 2
B0MOV
TC1R,A
B0BSET
FPWM1OUT
B0BSET
FTC1ENB
…