5.1 2声道音量控制芯片PT2257工作原理 5.1.1概述与特点 PT2257 是由CMOS 技术制造而成的2 声道音量控制芯片,只有8 个脚位,采用I2C 总线控制接口,具备0~-79dB 的衰减范围,低噪声,高立体声分离度及使用极少的周边元件,是21世纪AV 视听产品必备的极佳音量控制元件。 特色: 衰减率:0~-79dB,1dB/每级。 工作电压范围4~9V。 低噪声,S/N>100dB(A-Weighting)。 高立体声分离度>88dB。 需求极少的周边元件。 二声道输出。 DIP 与SOP 型式包装。 应用: AV 环绕视呼音响、汽车音响、mini-compo电脑周边多媒体喇叭、其他音响相关的应用。 ;****************************************************************** ;Project : ;Client : ;Create : ;Data :2007-12-13 ;Version :V0.0; ;Description: ;****************************************************************** ;=============>>>>>>>><<<<<<<<================= INCLUDE "F:ProjectInclude FileEM78P156.INC" ;Defined the TEMP register VOL_MAIN EQU 0X10; VOL_FRO EQU 0X11; VOL_CEN EQU 0X12; VOL_SUB EQU 0X13; VOL_SUR EQU 0X14; ;----------------------------------------------- STATE EQU 0X15; F_POWER EQU 0; F_MUTE EQU 1; F_ERROR EQU 3; F_REML EQU 4; ADJ EQU 0X16; F_FRO EQU 0; F_CEN EQU 1; F_SUR EQU 2; F_SUB EQU 3; F_MAIN EQU 4; NEW_KEY EQU 0X17; OLD_KEY EQU 0X18; LST_KEY EQU 0X19;
KREM EQU 0X1A; K_MASU EQU 0; K_MASD EQU 1; KCOM EQU 0X1B; K_MUTE EQU 0; K_AUX EQU 1; K_FM EQU 2; K_RESET EQU 3; K_INPUT EQU 4; K_SCAN EQU 5; T_8MS EQU 0X1E; T_120MS EQU 0X1F; C_WIDTH EQU 0X20; T_REML EQU 0X21;
T_3S EQU 0X23;
X0 EQU 0X24; X1 EQU 0X25; Y0 EQU 0X26; Y1 EQU 0X27; I EQU 0X29; J EQU 0X2A; STATE_BUF EQU 0X2B; ACC_BUF EQU 0X2C;
TIME EQU 0X2D; F_120MS EQU 0; F_500MS EQU 1; F_DISP EQU 2; F_SCAN EQU 3; F_FLASH EQU 4; F_END EQU 5;
R_BIT EQU 0X2E; T_FLASH EQU 0X30; B_FLASH0 EQU 3; B_FLASH1 EQU 6; B_FLASH2 EQU 7; T_PRES EQU 0X31; BAK_KEY0 EQU 0X32; BAK_KEY1 EQU 0X33;
DSP_BUF0 EQU 0X34; L_PLAY EQU 1; L_STBY EQU 0; R_INPUT EQU 0X35; B_AUX EQU 0; B_FM EQU 1; T_TRIGGER EQU 0X36 ;=============>>>>>>>><<<<<<<<================= ;Defined the I/O Port PCON EQU 6; P_4052A EQU 2; P_4052B EQU 3; PPT EQU 5; P_SCL EQU 2; P_SDA EQU 3; PFM EQU 6; P_SCAN EQU 0; P_REST EQU 1; PRMT EQU 6; P_REC EQU 7; PKEY EQU 6; PLED EQU 5; ;=============>>>>>>>><<<<<<<<================= ;Defined the TEMP data
INI_P5 EQU 0B00000000; INI_P6 EQU 0B11111100; IO_P5 EQU 0B00000000; IO_P6 EQU 0B11110000; ;****************************************** ;PT2257 channels address ;PT2257 Channel Number ADDR_2257 EQU 0X88;
CH_LH EQU 0xB0; CH_LL EQU 0xA0; CH_RH EQU 0x30;0X00;0XA0;0X20; CH_RL EQU 0x20;0X10;0XB0;0X30; CH_MH EQU 0XE0;0x00; CH_ML EQU 0XD0;0x10; INI_VOL EQU 39;24;34 MIN_MAIN EQU 79; MIN_VOL EQU 79; INI_MAIN EQU 34;
V_120MS EQU 15; V_3S EQU 100; V_NONEKEY EQU 0XFF; V_TRIGGER EQU 35; ;---------------------------------------------- ;IR Remote Code
CHECK_CODEL EQU 0X03; CHECK_CODEH EQU 0XFC;
VALUE_AUX EQU 0XFF VALUE_FM EQU 0XF1 VALUE_MUTE EQU 0XFE; VALUE_MASU EQU 0XF3; VALUE_MASD EQU 0XF6; VALUE_RESET EQU 0XF9; VALUE_SCAN EQU 0XEB;
;-------------------------------- VPLAN_MUTE EQU 0B01111111; VPLAN_INPUT EQU 0B11011111; VPLAN_VOLU EQU 0B11101111; VPLAN_VOLD EQU 0B10111111; ;=============>>>>>>>><<<<<<<<================= ORG 0X3FF; JMP START; ORG 0X000; JMP START; NOP; NOP; NOP; NOP; NOP; NOP; NOP; ORG 0X008; MOV ACC_BUF,A; SWAP ACC_BUF; SWAPA STATUS; MOV STATE_BUF,A; JMP INTERRUPT; ;=============>>>>>>>><<<<<<<<================= INI_RAM: MOV A, @0X10; MOV FSR, A; L_CLEAR: CLR INDF; INC FSR; MOV A, FSR; AND A, @0X3F; XOR A, @0X3F; JBS STATUS, Z; JMP L_CLEAR; ;--------------------------------- ;Ram loading the initial value MOV A, @INI_MAIN; MOV VOL_MAIN, A; BS R_INPUT, B_AUX;; BS STATE, F_POWER; RET; ;=============>>>>>>>><<<<<<<<================= INI_PORT: MOV A, @INI_P5; MOV PORT5, A; MOV A, @INI_P6; MOV PORT6, A; MOV A, @IO_P5; IOW PORT5; MOV A, @IO_P6; IOW PORT6; MOV A, @0X80 IOW IOCE; ;--------------------------------- ;Set I/O Port Initial state BC PCON, P_4052A; BC PCON, P_4052B; RET; ;=============>>>>>>>><<<<<<<<================= INI_INT: DISI; CLR INTF; MOV A, @0X05; CONTW; 1:64 To TCC MOV A, @0X01; IOW INTC; Enable the TCC interrupt; ENI; RET; ;=============>>>>>>>><<<<<<<<================= INI_PT2257: CALL DLY05S; MOV A, @0XFF;; MOV Y0, A; MOV A, @0X78; MOV Y1,A; CALL PT2257; JBS STATE, F_ERROR; JMP PT_NEXT; CALL DLY05S; MOV A, @0XFF; MOV Y0, A; MOV A, @0X78; MOV Y1,A; CALL PT2257; PT_NEXT: CALL LOAD_MAIN; RET; ;=============>>>>>>>><<<<<<<<================= ;=============>>>>>>>><<<<<<<<================= START: WDTC; CALL INI_RAM; CALL INI_PORT; CALL INI_INT; CALL INI_PT2257; CALL DLY05S; CALL DLY05S; MAIN: WDTC; CALL REMOTE; CALL DISPLAY; CALL KEY_SCAN; JBS STATE, F_POWER; JMP MAIN; CALL COMM_MUTE; JBC STATE, F_MUTE; JMP MAIN; CALL COMM_INPUT CALL COMM_AUX; CALL COMM_FM CALL COMM_SCAN CALL COMM_RESET CALL COMM_MU; CALL COMM_MD; JMP MAIN; ;=============>>>>>>>><<<<<<<<================= COMM_MUTE: JBS KCOM, K_MUTE; RET; BC KCOM, K_MUTE; JBS STATE, F_MUTE; JMP MUTE_ON; MUTE_OFF: BC STATE, F_MUTE; CLR KCOM; CLR KREM; MOV A, @0X78; MOV Y0,A; CLR Y1; CALL PT2257; RET; ;================================================= MUTE_ON: BS STATE, F_MUTE; CLR T_FLASH; MOV A, @0X79; MOV Y0,A; CLR Y1; CALL PT2257; RET; ;=============>>>>>>>><<<<<<<<================= COMM_INPUT: JBS KCOM, K_INPUT; RET; BC KCOM, K_INPUT; ;---------------------------------------------- BC STATUS, C; RLC R_INPUT; MOV A,@0X03 AND R_INPUT,A JBC STATUS, Z; BS R_INPUT,B_AUX; INPUT_SELECT: JBC R_INPUT, B_FM; JMP SHIFT_FM; JMP SHIFT_AUX ;************************************** COMM_AUX: JBS KCOM, K_AUX; RET; BC KCOM, K_AUX; CLR R_INPUT; BS R_INPUT,B_AUX; SHIFT_AUX: BC PCON,P_4052A; BC PCON,P_4052B; RET; ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< COMM_FM: JBS KCOM, K_FM; RET; BC KCOM, K_FM; CLR R_INPUT; BS R_INPUT,B_FM; SHIFT_FM: BS PCON,P_4052A; BS PCON,P_4052B; RET; ;===========>>>>>>>>>>>>>><<<<<<<<<<<<============ COMM_SCAN: JBS KCOM, K_SCAN; RET; BC KCOM, K_SCAN; JBC R_INPUT,B_AUX; RET; CLR T_TRIGGER; BS PFM, P_SCAN; BC PFM, P_REST; RET; ;===========>>>>>>>>>>>>>><<<<<<<<<<<<============ COMM_RESET: JBS KCOM, K_RESET; RET; BC KCOM, K_RESET; JBC R_INPUT,B_AUX; RET; CLR T_TRIGGER; BC PFM, P_SCAN; BS PFM, P_REST; RET; ;=================>>>>>>>>>>>>>>>>>>>================ COMM_MU: JBS KREM, K_MASU; RET; BC KREM, K_MASU; CALL CLEAR_FLAG; BS ADJ,F_MAIN; A_MU: MOV A, VOL_MAIN; JBS STATUS, Z; DEC VOL_MAIN; JBC STATUS, Z; BS TIME, F_END; LOAD_MAIN: MOV A, VOL_MAIN;; CALL HTD; MOV A, X0; AND A, @0XF; OR A, @CH_LL; MOV Y1,A; SWAPA X0; AND A, @0XF; OR A, @CH_LH; MOV Y0,A; CALL PT2257; MOV A,X0; AND A, @0XF; OR A, @CH_RL; MOV Y1,A; SWAPA X0; AND A, @0XF; OR A, @CH_RH; MOV Y0,A; CALL PT2257; RET; ;================================================ CLEAR_FLAG: CLR T_3S; CLR ADJ; BS TIME, F_FLASH; BC TIME, F_END; RET; ;=============>>>>>>>><<<<<<<<================= COMM_MD: JBS KREM, K_MASD; RET; BC KREM, K_MASD; CALL CLEAR_FLAG; BS ADJ,F_MAIN; A_MD: INC VOL_MAIN; MOV A, VOL_MAIN; SUB A, @MIN_VOL; MOV A, @MIN_VOL; JBS STATUS, C; MOV VOL_MAIN, A; ;================================================ JBS STATUS, C; BS TIME, F_END; JMP LOAD_MAIN; ;=============>>>>>>>><<<<<<<<================= REMOTE: JBS PRMT, P_REC; JMP START_REC; ;---------------------------- JBS TIME, F_120MS; RET; BC TIME, F_120MS; BC STATE,F_REML; BC TIME, F_500MS; RET; ;------------------------------------------------- START_REC: WDTC; CLR C_WIDTH; L_REC_LOW: JBC PRMT, P_REC; JMP REC_NEXT_LOW; CALL DLY01MS; INC C_WIDTH; MOV A, @120; SUB A, C_WIDTH; JBS STATUS, C; JMP L_REC_LOW; CLR C_WIDTH; RET; ;----------------------------- REC_NEXT_LOW: MOV A, @60; SUB A, C_WIDTH; JBC STATUS,C; JMP REC_HIG; CLR C_WIDTH; RET; REC_HIG: CLR C_WIDTH; L_REC_HIG: JBS PRMT,P_REC; JMP START_CODE; CALL DLY01MS; INC C_WIDTH; MOV A, @55; SUB A, C_WIDTH; JBS STATUS,C; JMP L_REC_HIG; CLR C_WIDTH; RET; ;------------------------------------------- START_CODE: MOV A, @35; SUB A, C_WIDTH; JBC STATUS,C; JMP REC_DATA; MOV A, @15; SUB A, C_WIDTH; JBC STATUS,C; JMP REC_END; CLR C_WIDTH; RET; ;---------------RECEIVED DATA---------------- REC_DATA: CLR C_WIDTH; MOV A,@32; MOV J,A; L_REC_DATA_LOW: JBC PRMT,P_REC; JMP REC_DATA_HIG; CALL DLY01MS; INC C_WIDTH; MOV A,@10; SUB A,C_WIDTH; JBS STATUS,C; JMP L_REC_DATA_LOW; CLR C_WIDTH; RET; ;-------------------------- REC_DATA_HIG: CLR C_WIDTH; L_REC_DATA_HIG: JBS PRMT,P_REC; JMP REC_NEXT_BIT; CALL DLY01MS; INC C_WIDTH; MOV A,@23; SUB A,C_WIDTH; JBS STATUS,C; JMP L_REC_DATA_HIG; CLR C_WIDTH; RET; ;--------------------------- REC_NEXT_BIT: MOV A, @12; SUB A, C_WIDTH; RRC X0; RRC X1; RRC Y0; RRC Y1; CLR C_WIDTH; DJZ J; JMP L_REC_DATA_LOW; ;---------------Remote Code check----------------- MOV A, @CHECK_CODEL; XOR A,Y1; JBS STATUS,Z; RET; MOV A, @CHECK_CODEH;; XOR A,Y0; JBS STATUS,Z; RET; COMA X1; XOR A,X0; JBS STATUS,Z; RET; ;-------------------------------------------------; MOV A, @VALUE_MUTE; XOR A, X0; JBC STATUS, Z; BS KCOM, K_MUTE; MOV A, @VALUE_RESET; XOR A, X0; JBC STATUS, Z; BS KCOM, K_RESET;
MOV A, @VALUE_SCAN; XOR A, X0; JBC STATUS,Z; BS KCOM, K_SCAN; MOV A, @VALUE_MASU; XOR A, X0; JBC STATUS, Z; BS KREM, K_MASU; MOV A, @VALUE_MASD; XOR A, X0; JBC STATUS, Z; BS KREM, K_MASD; MOV A, @VALUE_AUX; XOR A, X0; JBC STATUS, Z; BS KCOM, K_AUX; MOV A,@VALUE_FM; XOR A, X0; JBC STATUS, Z; BS KCOM, K_FM; MOV A, KREM; MOV BAK_KEY0, A; MOV A, KCOM; AND A, @0B11000000; MOV BAK_KEY1, A; BS STATE, F_REML; BC TIME, F_120MS; CLR T_120MS; CLR T_REML; RET; ;------------------------------------------- REC_END: CLR T_120MS; BC TIME, F_120MS; JBS STATE, F_REML; RET; JBC TIME, F_500MS; JMP REC_L; INC T_REML; JBS T_REML, 3; RET; BS TIME, F_500MS;
REC_L: MOV A, BAK_KEY0; MOV KREM, A; MOV A, BAK_KEY1; MOV KCOM, A; RET; ;=============>>>>>>>><<<<<<<<================= DLY01MS: WDTC; MOV A, @50 MOV I, A L_DLY01MS: NOP; DJZ I; JMP L_DLY01MS RET ;=============>>>>>>>><<<<<<<<================= DLY05S: MOV A, @200; MOV I, A; L_DLY0: WDTC; MOV A, @250; MOV J, A; L_DLY1: JMP $+1; JMP $+1; JMP $+1; JMP $+1; JMP $+1; JMP $+1; JMP $+1; JMP $+1; NOP DJZ J; JMP L_DLY1; DJZ I; JMP L_DLY0; RET; ;=============>>>>>>>><<<<<<<<================= DLY15US: MOV A, @5; MOV I, A; L_15US: JMP $+1; JMP $+1; JMP $+1; DJZ I; JMP L_15US; RET; ;=============>>>>>>>><<<<<<<<================= PT2257: BS PPT, P_SCL; BS PPT, P_SDA; CALL DLY15US; BC PPT, P_SDA; CALL DLY15US; BC PPT, P_SCL; MOV A, @ADDR_2257; MOV X1, A; CALL SEND_DATA; MOV A, Y0; MOV X1, A; CALL SEND_DATA; MOV A, Y1; JBC STATUS, Z; JMP STOPBIT; MOV X1, A; CALL SEND_DATA; STOPBIT: BC PPT, P_SDA; CALL DLY15US; BS PPT, P_SCL; CALL DLY15US; BS PPT, P_SDA; RET;
SEND_DATA: MOV A, @8; MOV I, A; L_SEND: BC PPT, P_SCL; RLC X1; JBS STATUS, C; BC PPT, P_SDA; JBC STATUS, C; BS PPT, P_SDA; JMP $+1; JMP $+1; BS PPT, P_SCL; JMP $+1; JMP $+1; DJZ I; JMP L_SEND;
BC PPT, P_SCL IOR PPT; MOV R_BIT, A; BS R_BIT, P_SDA; MOV A, R_BIT; IOW PPT; ; BC PPT, P_SCL; JMP $+1; JMP $+1; BS PPT, P_SCL; BC STATE,F_ERROR; JBC PPT, P_SDA; BS STATE,F_ERROR; BC PPT, P_SCL; BC PPT, P_SDA; BC R_BIT, P_SDA; MOV A, R_BIT; IOW PPT; RET; ;----------->>>>>>>>><<<<<<<<--------------- HTD: MOV Y0, A; CLR X0; L_HTD: MOV A, @10; SUB A, Y0; JBS STATUS, C; JMP HTD_EXIT; INC X0; MOV Y0, A; JMP L_HTD; HTD_EXIT: SWAP X0; MOV A, Y0; OR A, X0; MOV X0, A; RET; ;==============>>>>>>>><<<<<<<<================== ;------------------------------------------------- ;==============>>>>>>>><<<<<<<<================== DISPLAY: JBS TIME, F_DISP; RET; BC TIME, F_DISP; ;------------------------------------------------- DISP_INTI:
MOV A,@0XFC; AND PLED,A; MOV A,@0X00; MOV DSP_BUF0,A; ;------------------------------------------------- DISP_START: JBC STATE, F_POWER; JMP DISP_POWON; DISP_POWOFF: JBC T_FLASH,B_FLASH2; BS DSP_BUF0,L_STBY; JMP DISP_LOAD; DISP_POWON: BS DSP_BUF0,L_PLAY; JBS STATE, F_MUTE; JMP DISP_ADJUST; JBC T_FLASH,B_FLASH1; BS DSP_BUF0,L_STBY; ;------------------------------------------------- DISP_ADJUST: JBC TIME, F_END; JMP DISP_LOAD JBS TIME, F_FLASH; JMP DISP_LOAD JBS T_FLASH,B_FLASH0; BC DSP_BUF0,L_PLAY; ;*************************************************** DISP_LOAD: MOV A, DSP_BUF0; OR PLED, A; RET ;------------------------------------------------ ;------------------------------------------------ KEY_SCAN: JBS TIME, F_SCAN; RET; BC TIME, F_S |