CH555使用RGB LED三色控制器。com口掃描從COM3開(kāi)始掃描沒(méi)有問(wèn)題,但是從com1開(kāi)始掃描就出現(xiàn)只有com1和com2有掃描波形,但是顏色什么的都不對(duì),com3-com17沒(méi)有掃描波形。請(qǐng)問(wèn)一下可能是哪里出現(xiàn)的問(wèn)題?
//RGB的初始化
void InitRGBLED(void)
{?
P7 |= ( bP7_1_DIR | bP7_0_DIR );?
P7 |= 0x03;
/* LED驅(qū)動(dòng)相關(guān)初始化 */
P4 = P2 = P1 = 0xFF;? ???? /* R/G/B PWM pins invert output, low action for sink current */
P0 = P3 = 0xFF;? ???????????? /* COMMON pin invert output, low action for drive external PMOS */
// P7 =0x00;
P4_MOD_OC = P2_MOD_OC = P1_MOD_OC = 0;? ???? /* R/G/B PWM pins push-pull output */
P0_MOD_OC = P3_MOD_OC = 0; ???? /* COMMON pins push-pull output */
LED_CTRL = bLED_EN;
LED_CYCLE = 0x60; ???? /* PWM_128@color,PWM_128@intenisy,1x bLED_COLOR_CYC|? MASK_LED_INT_CYC */
LED_FRAME = bLED_INH_TMR2 | bLED_INH_TMR0;? /* 101->8 intenisy PWM cycles, same PWM data repeat 1 time */
LED_DMA = BufferAddr = (UINT16)( &RGBdataBuffer[ 0 ] );? ???? /* buffer start address? */
IsCode = 0;? ? ? ? ? ? ???????????? /* indicate data@xRAM (1=data@flash ROM) */
LED_INT_ADJ = 0x00;? ???? /* adjust: increase intenisy */
LED_PWM_OE = 0xFF;
LED_COMMON = 0x1E;? ???? /* preset COMMON selection, next is 0, start @interrupt */
LED_CTRL = bLED_IE_INHIB | bLED_BLUE_EN | bLED_GREEN_EN | bLED_RED_EN | bLED_COM_AHEAD | bLED_PWM_INHIB | bLED_EN;
LED_STATUS |= bLED_IF_SET;????????? /* force bLED_IF to enter interrupt service */?
IE_PWM_I2C = 1;
? ? LED_RED_ADJ = 0;
? ? LED_GRE_ADJ = 0;
? ? LED_BLU_ADJ = 0;
/* 將RGB LED中斷優(yōu)先級(jí)設(shè)置為高優(yōu)先級(jí) */
IP_EX |= bIP_PWM_I2C;
}
//---------------------------------------------------------------------------------------------------
RGB的中斷服務(wù)函數(shù)
; RGB PWM LED interrupt
;
$NOMOD51
#include "CH555.INC"
;
NAME REGINT
;
CSEG AT INT_ADDR_PWM_I2C ;RGB LED interrupt
JMP? ? ?LED_INT
;
;
?PR?LED_INT?REGINT SEGMENT CODE
;
EXTRN BIT (IsCode)
EXTRN DATA (BufferAddr)
;PUBLIC LED_INT
;
RSEG ?PR?LED_INT?REGINT
LED_INT:
PUSH? PSW
PUSH? ACC
; MOV? ?A,I2CX_INT
; JNB? ?ACC.1,SKIP_LED_INT ????????????????;check interrupt request, not RGB LED
INC? ?LED_COMMON ???????????????????????? ;switch COMMON, clear interrupt flag
MOV? ?A,LED_COMMON
CJNE? A, #0x1F, LED_INT_COM ???????? ; 如果A等于0x1F,不跳轉(zhuǎn), 在這里修改開(kāi)始掃描的端口
MOV? ?LED_COMMON,#0EH ???????????? ;restart? 修改為com1端口
MOV? ?LED_DMA_L,BufferAddr+1 ?????;reset buffer start address
MOV? ?LED_DMA_H,BufferAddr
LED_INT_COM: JB? ? IsCode,LED_INT_CODE ;load data from ROM
; MOV? ?A,R7 ;load data from XRAM
; PUSH? ACC
; MOV? ?R7,#32/8 ;total 32bytes, PWM pins[0~7]*4(intensity,R,G,B)
SETB? E_DIS ;disable global interrupt for RGB LED DMA
SETB? P ;copy LED_DMA into DPTR1
LED_INT_XRAM:
MOVX? A,@DPTR ;load 1 byte for PWM pin[0] intensity
MOVX? A,@DPTR ;load 1 byte for PWM pin[0] R
MOVX? A,@DPTR ;load 1 byte for PWM pin[0] G
MOVX? A,@DPTR ;load 1 byte for PWM pin[0] B
MOVX? A,@DPTR
MOVX? A,@DPTR
MOVX? A,@DPTR
MOVX? A,@DPTR
NOP? ? ? ? ? ? ? ? ;reserved for DMA? ? ? ?
MOVX? A,@DPTR
MOVX? A,@DPTR
MOVX? A,@DPTR
MOVX? A,@DPTR
MOVX? A,@DPTR
MOVX? A,@DPTR
MOVX? A,@DPTR
MOVX? A,@DPTR
NOP? ? ? ? ? ? ? ? ;reserved for DMA?
MOVX? A,@DPTR
MOVX? A,@DPTR
MOVX? A,@DPTR
MOVX? A,@DPTR
MOVX? A,@DPTR
MOVX? A,@DPTR
MOVX? A,@DPTR
MOVX? A,@DPTR
NOP? ? ? ? ? ? ? ? ;reserved for DMA?
MOVX? A,@DPTR
MOVX? A,@DPTR
MOVX? A,@DPTR
MOVX? A,@DPTR
MOVX? A,@DPTR ;load 1 byte for PWM pin[7] intensity
MOVX? A,@DPTR
MOVX? A,@DPTR
MOVX? A,@DPTR
; DJNZ? R7,LED_INT_XRAM
CLR? ?E_DIS
MOV? ?LED_PWM_OE,#0FFH ;enable PWM output
; POP? ?ACC
; MOV? ?R7,A
SKIP_LED_INT: POP? ?ACC
POP? ?PSW
RETI
LED_INT_CODE:
CLR? ?A ;for MOVC only
SETB? E_DIS ;disable global interrupt for RGB LED DMA
SETB? P ;copy LED_DMA into DPTR1
MOVC? A,@A+DPTR ;load 4 bytes (intensity,R,G,B) for PWM pin[0]
MOVC? A,@A+DPTR ;load 4 bytes
MOVC? A,@A+DPTR ;load 4 bytes
MOVC? A,@A+DPTR ;load 4 bytes
MOVC? A,@A+DPTR ;load 4 bytes
MOVC? A,@A+DPTR ;load 4 bytes
MOVC? A,@A+DPTR ;load 4 bytes
MOVC? A,@A+DPTR ;load 4 bytes for PWM pin[7]
CLR? ?E_DIS
MOV? ?LED_PWM_OE,#0FFH ;enable PWM output
POP? ?ACC
POP? ?PSW
RETI
;
END