CH555 USB使用碰到点疑问
void USB_DeviceInit(void)
{
    IE_USB = 0; // 禁止USB总中断
    USB_CTRL = 0;

    /*USBD0控制器配置,缓冲区为固定地址(无需配置)*/
    D0_EP0RES = UEP_R_RES_ACK | UEP_T_RES_NAK;
    D0_EP1RES = bUEP_X_AUTO_TOG | UEP_X_RES_ACK;
    D0_EP2RES = bUEP_X_AUTO_TOG | UEP_X_RES_NAK;
    D0_EP3RES = bUEP_X_AUTO_TOG | UEP_X_RES_NAK;
    D0_EP_MOD = bUX_DEV_EN | bUX_EP1O_EN; // 启用USBD0子设备,设置端点1为OUT,设置端点2-3为IN,禁用端点4-6
    D0_ADDR = 0x00; // 复位USBD0设备地址

    /*USBD1控制器配置,缓冲区为固定地址(无需配置)*/
    D1_EP0RES = UEP_R_RES_ACK | UEP_T_RES_NAK;
    D1_EP1RES = bUEP_X_AUTO_TOG | UEP_X_RES_NAK;
    D1_EP2RES = bUEP_X_AUTO_TOG | UEP_X_RES_NAK;
    D1_EP3RES = bUEP_X_AUTO_TOG | UEP_X_RES_NAK;
    D1_EP_MOD = bUX_DEV_EN; // 启用USBD1子设备,设置端点1-3为IN,禁用端点4-6
    D1_ADDR = 0x00; // 复位USBD1设备地址

    HB_ADDR = 0x7F; // 将收到的数据直接转发到D0

    USB_IF = 0xFF; // 清空USB中断标志寄存器
    USB_IE = bUX_IE_SUSPEND | bUX_IE_TRANSFER | bUX_IE_BUS_RST; // 使能<总线挂起&唤醒&复位,数据传输完成>中断
    USB_CTRL = bUX_DP_PU_EN; // 使能USB复合设备,启用DP内部上拉1.5K电阻
    IE_USB = 1; // 使能USB总中断
}


问题一:

    代码段中,单独注释掉USBD0或者USBD1,另一个USB子设备都能正常枚举成功。如果两个都保留,则只有USBD1子设备枚举成功,USBD0没有参与通信过程,照理来说应该两个子设备都能枚举才对。


问题二:

    HB_ADDR=0x7F; 这句代码是从官方提供的实例代码照抄的,它的作用是什么? USBHUB的地址不需要上位机分配吗?

哎,等了一周过去,旧问题没解决,又碰到了新问题.

CH555的LED控制器的工作原理是怎么样的,能否请沁恒的工程师解答下?

我在示例代码内看到在LED帧扫描结束中断函数内有调用"RGBLOAD.ASM"内的汇编函数,实际打开汇编函数发现完全看不懂,里面操作的都是一些通用寄存器,所以搞不懂是为什么在帧扫描结束后需要操作这些寄存器.

希望能够得到解答,另外希望知道是否能用C语言重写这部分汇编代码.


附官方例程资料:

icon_rar.gifCH555_RGB机械键盘资料.zip



to be fair i dont know the ch555 in detail but the header looks like the usual E52 core. Must be a new chip.


check this out:

   SETB  P    ;copy LED_DMA into DPTR1

This is definately wrong the parity bit is read only! How would changing the parity bit help anyway?


Maybe they want to enable bDPTR_AUTO_INC, which would make sense for coping data. AutoInc is potentially dangerous, thats why they disable all interrupts.



Yes, i just can see copy LED_DMA to DPTR1 in asm file, but i don't know why need do that.

I don't know how the LED Scanner work.


I want to know the meaning of the asm function, which may be very helpful for me to write programs.


well i am guessing here..

that movx seems just to eat cycles

same as the movc for code access. (movc is slower therefor just 8 movc)


or possibly that triggers something internally. I cant see anything in the datasheet to support this theory.


further i have no idea how they control DPTR to have the correct value on entry.

The rest of the code seems for keyboard prepare


@Antecer 你好,我的微信号18951773083,可以加我微信详细沟通。


只有登录才能回复,可以选择微信账号登录