新手請(qǐng)教CH555使用RGB LED三色控制器 com口動(dòng)態(tài)掃描的問(wèn)題

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


//P4.0~P4.6---PWM_R1~PWM_R7

//P2.0~P2.6---PWM_G1~PWM_G7

//P1.0~P1.6---PWM_B1~PWM_B7

//P0.0~P0.7---COM3~COM10

//P3.0~3.6---COM11~COM17

//P7.0---COM1

//P7.1---COM2



你好,有兩個(gè)注意事項(xiàng)需要注意下:

1、P7.1是CH555的硬件復(fù)位引腳,所以在下載程序時(shí)需要關(guān)閉芯片的復(fù)位功能。ISP工具中有關(guān)閉復(fù)位功能的選項(xiàng),如下圖:

image.png

2、CH555的RGB鍵盤(pán)驅(qū)動(dòng)例程默認(rèn)是16COM掃描,不包含P7.0和P7.1,如果想增加這兩個(gè)引腳對(duì)應(yīng)的COM引腳,即COM14、COM15,在程序中需要修改對(duì)應(yīng)的宏。默認(rèn)16,改成18即可。如下圖所示:

image.png

CH555RGB鍵盤(pán)例程附件:

icon_rar.gifCH555RGB鍵盤(pán)資料.zip



好的 十分感謝!


只有登錄才能回復(fù),可以選擇微信賬號(hào)登錄

国产91精品新入口,国产成人综合网在线播放,九热这里只有精品,本道在线观看,美女视频a美女视频,韩国美女激情视频,日本美女pvp视频