CH555使用RGB LED三色控制器。com口扫描从COM3开始扫描没有问题,但是从com1开始扫描就出现只有com1和com2有扫描波形,但是颜色什么的都不对,com3-com17没有扫描波形。请问一下可能是哪里出现的问题?
//RGB的初始化
void InitRGBLED(void)
{
P7 |= ( bP7_1_DIR | bP7_0_DIR );
P7 |= 0x03;
/* LED驱动相关初始化 */
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中断优先级设置为高优先级 */
IP_EX |= bIP_PWM_I2C;
}
//---------------------------------------------------------------------------------------------------
RGB的中断服务函数
; 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,不跳转, 在这里修改开始扫描的端口
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