⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch452ldriver.lis

📁 ch452的数码管和键盘驱动程序
💻 LIS
📖 第 1 页 / 共 3 页
字号:
                        .module ch452ldriver.c
                        .area text(rom, con, rel)
 0000                   .dbfile G:\CH452L\ch452ldriver.c
 0000                   .dbfunc e Init_Ch452lport _Init_Ch452lport fI
                        .even
 0000           _Init_Ch452lport::
 0000                   .dbline -1
 0000                   .dbline 71
 0000           ; #include<iom8v.h>
 0000           ; #include<macros.h>
 0000           ; #include"delay.h"
 0000           ; 
 0000           ; unsigned flag;
 0000           ; 
 0000           ; /************************************************************************
 0000           ; *说明:运行与CH452L的4线模式,MCU使用ATMEGA8L,MCU与CH452L引脚连接如下:
 0000           ;                    LOAD    PC0      
 0000           ;                                  DCLK    PC1
 0000           ;                                  DIN     PC2
 0000           ;                                  DOUT    PD2()INT0
 0000           ; LOAD,DCLK,DIN都为输出,DOUT为输入,若要使用其它IO口,只需更改如下宏定义即可
 0000           ; *************************************************************************/
 0000           ; #define PC0 0
 0000           ; #define PC1 1
 0000           ; #define PC2 2
 0000           ; #define PD2 2
 0000           ; 
 0000           ; #define LOAD_OUT DDRC |= BIT(PC0)
 0000           ; #define LOAD_OUT0 PORTC &= ~BIT(PC0)
 0000           ; #define LOAD_OUT1 PORTC |= BIT(PC0)
 0000           ; 
 0000           ; #define DCLK_OUT DDRC |= BIT(PC1)
 0000           ; #define DCLK_OUT0 PORTC &= ~BIT(PC1)
 0000           ; #define DCLK_OUT1 PORTC |= BIT(PC1)
 0000           ; 
 0000           ; #define DIN_OUT  DDRC  |= BIT(PC2)
 0000           ; #define DIN_OUT0 PORTC &= ~BIT(PC2)
 0000           ; #define DIN_OUT1 PORTC |= BIT(PC2)
 0000           ; 
 0000           ; #define DOUT_IN DDRD &= ~BIT(PD2)
 0000           ; #define DOUT_OUT0 PORTD &= ~BIT(PD2)
 0000           ; #define DOUT_OUT1 PORTD |= BIT(PD2)
 0000           ; #define DOUT_PIN PIND & 0x04
 0000           ; 
 0000           ; /*************************************************************************
 0000           ; *宏定义CH452L系统命令
 0000           ; *************************************************************************/
 0000           ; #define RESET_CHIP 0x0201
 0000           ; #define OPEN_DISPLAY 0x0401     //开启显示
 0000           ; #define OPEN_KEYBOARD 0x0422    //开启键盘   
 0000           ; #define OPEN_DISPLAY_KEYBOARD 0x0423    //开启显示和键盘
 0000           ; #define DATA_LEFT 0x0300        //数据左移
 0000           ; #define DATA_RIGHT 0x0302       //数据右移
 0000           ; #define LEFT_CIRCLE 0x0301      //数据左循环
 0000           ; #define RIGHT_CIRCLE 0x0303     //数据右循环
 0000           ; #define READ_KEYCODE 0x0700     //读取按键代码
 0000           ; 
 0000           ; 
 0000           ; /*************************************************************************
 0000           ; *宏定义CH452L加载数据DIG7~DIG0
 0000           ; * 说明:若要使用小数点,则只需将第7位置为1即可,例如0x0f80
 0000           ; *************************************************************************/
 0000           ; #define CH452L_DIG7 0x0f00
 0000           ; #define CH452L_DIG6 0x0e00
 0000           ; #define CH452L_DIG5 0x0d00
 0000           ; #define CH452L_DIG4 0x0c00
 0000           ; #define CH452L_DIG3 0x0b00
 0000           ; #define CH452L_DIG2 0x0a00
 0000           ; #define CH452L_DIG1 0x0900
 0000           ; #define CH452L_DIG0 0x0800
 0000           ; 
 0000           ; /**************************************************************************
 0000           ; *函数名:初始化CH452L端口
 0000           ; *函数功能:LOAD,DCLK,DIN都为输出,DOUT为输入
 0000           ; *入口参数:无
 0000           ; *出口参数:无
 0000           ; **************************************************************************/
 0000           ; int Init_Ch452lport(void)
 0000           ; {
 0000                   .dbline 72
 0000           ;     LOAD_OUT;
 0000 A09A              sbi 0x14,0
 0002                   .dbline 73
 0002           ;       LOAD_OUT1;
 0002 A89A              sbi 0x15,0
 0004                   .dbline 75
 0004           ;       
 0004           ;       DCLK_OUT;
 0004 A19A              sbi 0x14,1
 0006                   .dbline 76
 0006           ;       DCLK_OUT1;
 0006 A99A              sbi 0x15,1
 0008                   .dbline 78
 0008           ;       
 0008           ;       DIN_OUT;
 0008 A29A              sbi 0x14,2
 000A                   .dbline 79
 000A           ;       DIN_OUT1;
 000A AA9A              sbi 0x15,2
 000C                   .dbline 81
 000C           ;       
 000C           ;       DOUT_IN;
 000C 8A98              cbi 0x11,2
 000E                   .dbline 82
 000E           ;       DOUT_OUT1;
 000E 929A              sbi 0x12,2
 0010                   .dbline 84
 0010           ;       
 0010           ;       Delay_Nus(30);  //延时
 0010 0EE1              ldi R16,30
 0012 10E0              ldi R17,0
 0014 00D0              rcall _Delay_Nus
 0016                   .dbline 85
 0016           ;     return 0x31;
 0016 01E3              ldi R16,49
 0018 10E0              ldi R17,0
 001A                   .dbline -2
 001A           L1:
 001A                   .dbline 0 ; func end
 001A 0895              ret
 001C                   .dbend
 001C                   .dbfunc e Ch452l_Writecommand _Ch452l_Writecommand fV
 001C           ;              i -> R20
 001C           ;        command -> R22,R23
                        .even
 001C           _Ch452l_Writecommand::
 001C 00D0              rcall push_gset2
 001E B801              movw R22,R16
 0020                   .dbline -1
 0020                   .dbline 95
 0020           ; }
 0020           ; 
 0020           ; /**************************************************************************
 0020           ; *函数名称:向CH452L写入命令函数 
 0020           ; *函数功能:
 0020           ; *入口参数:定义一无符号整型变量存储12字节的命令字。
 0020           ; *出口参数:无
 0020           ; ***************************************************************************/
 0020           ; void Ch452l_Writecommand(unsigned int command)
 0020           ; {
 0020                   .dbline 98
 0020           ;     unsigned char i;
 0020           ;       
 0020           ;       LOAD_OUT0;
 0020 A898              cbi 0x15,0
 0022                   .dbline 99
 0022           ;       Delay_Nus(2);
 0022 02E0              ldi R16,2
 0024 10E0              ldi R17,0
 0026 00D0              rcall _Delay_Nus
 0028                   .dbline 100
 0028           ;     for(i=0;i<12;i++)
 0028 4427              clr R20
 002A 0AC0              rjmp L6
 002C           L3:
 002C                   .dbline 101
 002C           ;       {  
 002C                   .dbline 102
 002C           ;           DCLK_OUT0;
 002C A998              cbi 0x15,1
 002E                   .dbline 103
 002E           ;               if(command&0x0001==0x0001)
 002E 60FF              sbrs R22,0
 0030 02C0              rjmp L7
 0032                   .dbline 104
 0032           ;               {
 0032                   .dbline 105
 0032           ;                   DIN_OUT1;    
 0032 AA9A              sbi 0x15,2
 0034                   .dbline 106
 0034           ;               }
 0034 01C0              rjmp L8
 0036           L7:
 0036                   .dbline 108
 0036           ;               else
 0036           ;               {
 0036                   .dbline 109
 0036           ;                   DIN_OUT0;
 0036 AA98              cbi 0x15,2
 0038                   .dbline 110
 0038           ;               }
 0038           L8:
 0038                   .dbline 111
 0038 7695              lsr R23
 003A 6795              ror R22
 003C                   .dbline 112
 003C A99A              sbi 0x15,1
 003E                   .dbline 113
 003E           L4:
 003E                   .dbline 100
 003E 4395              inc R20
 0040           L6:
 0040                   .dbline 100
 0040 4C30              cpi R20,12
 0042 A0F3              brlo L3
 0044                   .dbline 114
 0044           ;               command=command>>1;
 0044           ;               DCLK_OUT1;
 0044           ;       }
 0044           ;       LOAD_OUT1;       //LOAD上升沿加载一帧数据
 0044 A89A              sbi 0x15,0
 0046                   .dbline 115
 0046           ;       DIN_OUT1;
 0046 AA9A              sbi 0x15,2
 0048                   .dbline 116
 0048           ;       DCLK_OUT1;      
 0048 A99A              sbi 0x15,1
 004A                   .dbline -2
 004A           L2:
 004A 00D0              rcall pop_gset2
 004C                   .dbline 0 ; func end
 004C 0895              ret
 004E                   .dbsym r i 20 c
 004E                   .dbsym r command 22 i
 004E                   .dbend
 004E                   .dbfunc e Init_Ch452lsystem _Init_Ch452lsystem fI
                        .even
 004E           _Init_Ch452lsystem::
 004E                   .dbline -1
 004E                   .dbline 144
 004E           ; }
 004E           ; 
 004E           ; /**************************************************************************
 004E           ; *函数名:Init_Ch452lsystem(void)
 004E           ; *函数功能:初始化CH452L
 004E           ; *命令说明:
 004E           ; *(1)采用BCD译码方式显示设置显示参数命令:
 004E           ; *       命令     显示位数
 004E           ; *      0x0580       8
 004E           ; *      0x0590       1
 004E           ; *      0x05a0       2
 004E           ; *      0x05b0       3     
 004E           ; *      0x05c0       4
 004E           ; *      0x05d0       5
 004E           ; *      0x05e0       6
 004E           ; *      0x05f0       7
 004E           ; *(2)OPEN_DISPLAY_KEYBOARD开启显示和键盘命令
 004E           ; *        命令        开启             输出中断方式
 004E           ; *      0x0401        显示             无(无键盘功能下不考虑)
 004E           ; *      0x0402        键盘             低电平中断(不推荐用于测试)
 004E           ; *      0x0422        键盘             边缘中断
 004E           ; *      0x0403        显示和键盘       低电平中断(不推荐使用)
 004E           ; *      0x0423        显示和键盘       边缘中断
 004E           ; *入口参数:无
 004E           ; *出口参数:无
 004E           ; **************************************************************************/
 004E           ; int Init_Ch452lsystem(void)
 004E           ; {
 004E                   .dbline 145
 004E           ;     Ch452l_Writecommand(RESET_CHIP);//芯片复位
 004E 01E0              ldi R16,513
 0050 12E0              ldi R17,2
 0052 E4DF              rcall _Ch452l_Writecommand
 0054                   .dbline 146
 0054           ;       Delay_Nus(40);
 0054 08E2              ldi R16,40
 0056 10E0              ldi R17,0
 0058 00D0              rcall _Delay_Nus
 005A                   .dbline 148
 005A           ;     
 005A           ;       Ch452l_Writecommand(OPEN_DISPLAY_KEYBOARD);//开启显示和键盘,边缘中断
 005A 03E2              ldi R16,1059
 005C 14E0              ldi R17,4
 005E DEDF              rcall _Ch452l_Writecommand
 0060                   .dbline 149
 0060           ;       Delay_Nus(5);
 0060 05E0              ldi R16,5
 0062 10E0              ldi R17,0
 0064 00D0              rcall _Delay_Nus
 0066                   .dbline 150
 0066           ;       return 0x32;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -