📄 atmega16test.lst
字号:
(0347) {GBASE,KIND2|DIR0|SPEED0},{GBASE,KIND2|DIR0|SPEED1},{GBASE,KIND2|DIR0|SPEED2},{GBASE,KIND2|DIR1|SPEED0},
(0348) //76
(0349) {GBASE,KIND2|DIR1|SPEED1},{GBBASE,KIND2|DIR0|SPEED0},{GBBASE,KIND2|DIR0|SPEED1},{GBBASE,KIND2|DIR0|SPEED2},
(0350) //80
(0351) {GBBASE,KIND2|DIR1|SPEED0},{GBBASE,KIND2|DIR1|SPEED1},{BBASE,KIND2|DIR0|SPEED0},{BBASE,KIND2|DIR0|SPEED1},
(0352) //84
(0353) {BBASE,KIND2|DIR0|SPEED2},{BBASE,KIND2|DIR1|SPEED0},{BBASE,KIND2|DIR1|SPEED1},{RBASE,KIND2|DIR0|SPEED0},
(0354) //88
(0355) {RBASE,KIND2|DIR0|SPEED1},{RBASE,KIND2|DIR0|SPEED2},{RBASE,KIND2|DIR1|SPEED0},{RBASE,KIND2|DIR1|SPEED1},
(0356) //92
(0357) {RBBASE,KIND2|DIR0|SPEED0},{RBBASE,KIND2|DIR0|SPEED1},{RBBASE,KIND2|DIR0|SPEED2},{RBBASE,KIND2|DIR1|SPEED0},
(0358) //96
(0359) {RBBASE,KIND2|DIR1|SPEED1},{GBASE,KIND2|DIR0|SPEED0},{GBASE,KIND2|DIR0|SPEED1},{GBASE,KIND2|DIR0|SPEED2},
(0360) //100
(0361) {GBASE,KIND2|DIR1|SPEED0},{GBASE,KIND2|DIR1|SPEED1},{RBASE,KIND2|DIR0|SPEED0},{RBASE,KIND2|DIR0|SPEED1},
(0362) //104
(0363) {RBASE,KIND2|DIR0|SPEED2},{RBASE,KIND2|DIR1|SPEED0},{RBASE,KIND2|DIR1|SPEED1},{BBASE,KIND2|DIR0|SPEED0},
(0364) //108
(0365) {BBASE,KIND2|DIR0|SPEED1},{BBASE,KIND2|DIR0|SPEED2},{BBASE,KIND2|DIR1|SPEED0},{BBASE,KIND2|DIR1|SPEED1}
(0366) };
(0367)
(0368)
(0369) #define SIZE 20
(0370) unsigned char SPI_rx_buff[SIZE];
(0371) unsigned char SPI_tx_buff[SIZE];
(0372) unsigned char rx_wr_index,rx_rd_index,rx_counter,rx_buffer_overflow;
(0373) unsigned char tx_wr_index,tx_rd_index,tx_counter;
(0374)
(0375) char DispBuffer[6];
(0376) const char CharFont[20]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x98,0x88,0x83,0xc6,0xa1,0x86,0x8e,0xbf,0xc7,0x8c,0xa1};
(0377) // 0 1 2 3 4 5 6 7 8 9 a b c d e f - L P d
(0378) long val;
(0379) unsigned char KeyCode;
(0380) void Display(void);
(0381) void Display_Fast(void);
(0382) char PressKeyProcess(void);
(0383) void spi_init(void);
(0384) void putSPIchar(char c);
(0385) unsigned char getSPIchar(void);
(0386) void spi_stc_isr(void);
(0387) void WatchDog(char tim);
(0388) unsigned char SendKindData(char kind);
(0389) void EepromICnumberWr(void);
(0390) void EepromICnumberRd(void);
(0391) void FactorySetup(void);
(0392) void EepromViewModeWr(void);
(0393) void EepromViewModeRd(void);
(0394) void EepromPasswordRd(void);
(0395) void EepromPasswordWr(void);
(0396) void EepromDateValueRd(void);
(0397) void EepromDateValueWr(void);
(0398) void EepromDayDataRd(void);
(0399) void EepromDayDataWr(void);
(0400) int CompareDate(void);
(0401) int CalMonthDay(uchar month,uchar day);
(0402) uchar ProcessEdgeToMiddle(char data,uchar mode,uchar BC,uchar class);
(0403) uchar ProcessMiddleToEdge(char data,uchar mode,uchar BC,uchar class );
(0404) void AllClearICBuffer(void);
(0405) void DelayNs(char tim);
(0406) uchar SendFirstToEnd(uchar kind,uchar mode,uchar si_flag,uchar ss_flag);
(0407) char SpeedDelay(uchar speed);
(0408) void AllStarRight(uchar da1,uchar da2,uchar da3,uchar da4,uint init);
(0409) uchar AllStarMiddleToEdge(uchar da1,uchar da2,uchar da3,uchar da4,uchar mode);
(0410) void timer0_init(void) ;
(0411) void Enable_Time0_Interrupt(void);
(0412) void Disable_Time0_Interrupt(void);
(0413) void FullProcess(uchar fullflag,uchar looplenght,uchar *data);
(0414)
(0415)
(0416)
(0417) void Delay(char tim)
(0418) {
(0419) unsigned char i,j;
(0420) for(j=0;j<tim;j++)
0126 2744 CLR R20
0127 C00B RJMP 0x0133
(0421) {
(0422) for(i=200;i>0;i--)
0128 EC68 LDI R22,0xC8
0129 C004 RJMP 0x012E
(0423) {
(0424) asm("nop");
012A 0000 NOP
(0425) asm("nop");
012B 0000 NOP
(0426) asm("nop");
012C 0000 NOP
012D 956A DEC R22
012E 2422 CLR R2
012F 1626 CP R2,R22
0130 F3C8 BCS 0x012A
(0427) }
(0428) #ifdef VERSION_CONTROL
(0429) /* WDT 复位*/
(0430) _WDR();
0131 95A8 WDR
0132 9543 INC R20
0133 1740 CP R20,R16
0134 F398 BCS 0x0128
0135 940E1BD6 CALL pop_gset2
0137 9508 RET
_DelayNs:
j --> R20
tim --> R16
0138 940E1BEA CALL push_gset1
(0431) #endif
(0432) }
(0433) }
(0434) void DelayNs(char tim)
(0435) {
(0436) unsigned char j;
(0437) for(j=0;j<tim;j++)
013A 2744 CLR R20
013B C004 RJMP 0x0140
(0438) {
(0439) asm("nop");
013C 0000 NOP
(0440) asm("nop");
013D 0000 NOP
(0441) asm("nop");
013E 0000 NOP
013F 9543 INC R20
0140 1740 CP R20,R16
0141 F3D0 BCS 0x013C
(0442) }
(0443) #ifdef VERSION_CONTROL
(0444) /* WDT 复位*/
(0445) _WDR();
0142 95A8 WDR
0143 940E1BED CALL pop_gset1
0145 9508 RET
_SendSS:
loop --> R20
0146 940E1BEA CALL push_gset1
0148 2F40 MOV R20,R16
(0446) #endif
(0447) }
(0448)
(0449) void SendSS(uchar loop )
(0450) {
(0451) if(loop==0) return;
0149 2344 TST R20
014A F409 BNE 0x014C
014B C004 RJMP 0x0150
(0452) PORTB |= 0x10; //SS output high 电平
014C 9AC4 SBI 0x18,4
(0453) DelayNs(20);
014D E104 LDI R16,0x14
014E DFE9 RCALL _DelayNs
(0454) PORTB &=(~0x10); //SS output low 电平
014F 98C4 CBI 0x18,4
0150 940E1BED CALL pop_gset1
0152 9508 RET
_SendSI:
i --> R20
loop --> R22
0153 940E1BE8 CALL push_gset2
0155 2F60 MOV R22,R16
(0455) }
(0456)
(0457) void SendSI(uchar loop)
(0458) {
(0459) uchar i;
(0460) if(loop==0) return;
0156 2366 TST R22
0157 F409 BNE 0x0159
0158 C009 RJMP 0x0162
(0461) for(i=0;i<loop;i++)
0159 2744 CLR R20
015A C005 RJMP 0x0160
(0462) {
(0463) PORTB |= 0x08; //S_I output high 电平
015B 9AC3 SBI 0x18,3
(0464) Display_Fast();
015C D6B4 RCALL _Display_Fast
(0465) PORTB &=(~0x08); //S_I output low 电平
015D 98C3 CBI 0x18,3
(0466) Display_Fast();
015E D6B2 RCALL _Display_Fast
015F 9543 INC R20
0160 1746 CP R20,R22
0161 F3C8 BCS 0x015B
0162 940E1BD6 CALL pop_gset2
0164 9508 RET
_hmod:
i --> R20
src --> R22
dest --> R18
source --> R16
0165 940E1BE8 CALL push_gset2
(0467) }
(0468) }
(0469) uint hmod(uint source,uint dest)
(0470) {
(0471) uchar i,src;
(0472) src=source;
0167 2F60 MOV R22,R16
(0473) if(src<dest) return src;
0168 2E26 MOV R2,R22
0169 2433 CLR R3
016A 1622 CP R2,R18
016B 0633 CPC R3,R19
016C F410 BCC 0x016F
016D 2711 CLR R17
016E C014 RJMP 0x0183
(0474) for(i=0;i<source;i++)
016F 2744 CLR R20
0170 C00B RJMP 0x017C
(0475) {
(0476) src=src-dest;
0171 2E26 MOV R2,R22
0172 2433 CLR R3
0173 1A22 SUB R2,R18
0174 0A33 SBC R3,R19
0175 2D62 MOV R22,R2
(0477) if(src<dest) break;
0176 2433 CLR R3
0177 1622 CP R2,R18
0178 0633 CPC R3,R19
0179 F408 BCC 0x017B
017A C006 RJMP 0x0181
017B 9543 INC R20
017C 2E24 MOV R2,R20
017D 2433 CLR R3
017E 1620 CP R2,R16
017F 0631 CPC R3,R17
0180 F380 BCS 0x0171
(0478) }
(0479) return src;
0181 2F06 MOV R16,R22
0182 2711 CLR R17
0183 940E1BD6 CALL pop_gset2
0185 9508 RET
_Send_Data:
i --> R20
loop --> R22
dat --> R10
0186 940E1BE6 CALL push_gset3
0188 2F62 MOV R22,R18
0189 2EA0 MOV R10,R16
(0480) }
(0481)
(0482) void Send_Data(uchar dat,uchar loop )
(0483) {
(0484) uchar i;
(0485) for(i=0;i<loop;i++)
018A 2744 CLR R20
018B C005 RJMP 0x0191
(0486) {
(0487) putSPIchar(dat);
018C 2D0A MOV R16,R10
018D D71F RCALL _putSPIchar
(0488) DelayNs(50);
018E E302 LDI R16,0x32
018F DFA8 RCALL _DelayNs
0190 9543 INC R20
0191 1746 CP R20,R22
0192 F3C8 BCS 0x018C
0193 940E1BD9 CALL pop_gset3
0195 9508 RET
(0489) }
(0490) }
(0491)
(0492) void PasswordCannel(void)
(0493) {
(0494) PasswordData[0]=PASS_DISABLE;
_PasswordCannel:
0196 EF8F LDI R24,0xFF
0197 938000B2 STS PasswordData,R24
(0495) PasswordData[1]=PASS_DISABLE;
0199 938000B3 STS PasswordData+1,R24
(0496) PasswordData[2]=PASS_DISABLE;
019B 938000B4 STS PasswordData+2,R24
(0497) PasswordData[3]=PASS_DISABLE;
019D 938000B5 STS PasswordData+3,R24
(0498) PasswordData[4]=PASS_DISABLE;
019F 938000B6 STS 0xB6,R24
(0499) PasswordData[5]=0x00;
01A1 2422 CLR R2
01A2 922000B7 STS 0xB7,R2
(0500) Password_alarm=FALSE;
01A4 92200138 STS Password_alarm,R2
(0501) Password_Enable=FALSE;
01A6 92200137 STS Password_Enable,R2
01A8 9508 RET
(0502) }
(0503)
(0504) //mega16 7.3728MHz石英晶体 iccavr6.31a
(0505) /*
(0506) 去掉电池:
(0507) year/mon/day =00/01/01
(0508) hour/min/second=00/00/00
(0509) 去掉芯片:
(0510) year/mon/day =ff/1f/3f
(0511) hour/min/second=3f/7f/7f
(0512) 重新扦入芯片,永远为:
(0513) year/mon/day =00/01/01
(0514) hour/min/second=00/00/00
(0515) */
(0516) //相关定义:
(0517) #define DS1302_RST 2 //pd2
(0518) #define DS1302_SDA 0 //pd0
(0519) #define DS1302_SCLK 1 //pd1
(0520) //ds1302相关
(0521) //DS1302_RST=1
(0522) #define Set_DS1302_RST() PORTD|=1<<DS1302_RST
(0523) //DS1302_RST=0
(0524) #define Clr_DS1302_RST() PORTD&=~(1<<DS1302_RST)
(0525) //DS1302_SDA=1
(0526) #define Set_DS1302_SDA() PORTD|=1<<DS1302_SDA
(0527) //DS1302_SDA=0
(0528) #define Clr_DS1302_SDA() PORTD&=~(1<<DS1302_SDA)
(0529) //DS1302_SCLK=1
(0530) #define Set_DS1302_SCLK() PORTD|=1<<DS1302_SCLK
(0531) //DS1302_SCLK=0
(0532) #define Clr_DS1302_SCLK() PORTD&=~(1<<DS1302_SCLK)
(0533) //DS1302的SDA置为输出脚
(0534) #define Set_DS1302_DDRSDA() DDRD|=1<<DS1302_SDA
(0535) //DS1302的SDA置为输入脚
(0536) #define Clr_DS1302_DDRSDA() DDRD&=~(1<<DS1302_SDA)
(0537) #define DS1302_SEC_Reg 0x80
(0538) #define DS1302_MIN_Reg 0x82
(0539) #define DS1302_HR_Reg 0x84
(0540) #define DS1302_DATE_Reg 0x86
(0541) #define DS1302_MONTH_Reg 0x88
(0542) #define DS1302_DAY_Reg 0x8a
(0543) #define DS1302_YEAR_Reg 0x8c
(0544) #define DS1302_CONTROL_Reg 0x8e
(0545) #define DS1302_CHARGER_Reg 0x90
(0546) #define DS1302_CLKBURST_Reg 0xbe
(0547) //全局变量
(0548) //为了方便,我把个位和十位分开了
(0549) uchar year1=0x88;
(0550) uchar year0=0x88;
(0551) uchar month1=0x88;
(0552) uchar month0=0x88;
(0553) uchar date0=0x88;
(0554) uchar date1=0x88;
(0555) uchar day=0x88;
(0556) uchar hour1=0x88;
(0557) uchar hour0=0x88;
(0558) uchar minute1=0x88;
(0559) uchar minute0=0x88;
(0560) uchar second1=0x88;
(0561) uchar second0=0x88;
(0562) void DS1302_Init(void);
(0563) uchar Check_DS1302(void);
(0564) uchar DS1302_Read(uchar reg);
(0565) void DS1302_Write(uchar reg,uchar data);
(0566) void ReadTime(void);
(0567) //////////////////////////////////////////////
(0568)
(0569) void port_init(void)
(0570) {
(0571) PORTA = 0x00;
_port_init:
01A9 2422 CLR R2
01AA BA2B OUT 0x1B,R2
(0572) DDRA = 0xff;//PORTA0-PORTA7 ==> OUTPUT CHAR DATA
01AB EF8F LDI R24,0xFF
01AC BB8A OUT 0x1A,R24
(0573) PORTB = 0x00;
01AD BA28 OUT 0x18,R2
(0574) DDRB = 0x00;
01AE BA27 OUT 0x17,R2
(0575) PORTC = 0xc3;//PORTC7,PORTC6,PORTC1,PORTC0 ==> key input ,enable_up
01AF EC83 LDI R24,0xC3
01B0 BB85 OUT 0x15,R24
(0576) DDRC = 0x00;//PC7,PC6,PC1,PC0 ==> PRESS KEY INPUT ; PC2PC3PC4PC5 ==>JTAG USE
01B1 BA24 OUT 0x14,R2
(0577) PORTD = 0xf8;//PORTD3-PORTD7 ==> LED CS ,enable_up ;
01B2 EF88 LDI R24,0xF8
01B3 BB82 OUT 0x12,R24
(0578) DDRD = 0xff;//PD3,PD4,PD5,PD6,PD7 ==>LED CS USE ;PD2,PD1,PD0 OUTPUT DS1302 USE
01B4 EF8F LDI R24,0xFF
01B5 BB81 OUT 0x11,R24
01B6 9508 RET
(0579) }
(0580)
(0581) //call this routine to initialize all peripherals
(0582) void init_devices(void)
(0583) {
(0584) //stop errant interrupts until set up
(0585) // CLI(); //disable all interrupts
(0586) port_init();
_init_devices:
01B7 DFF1 RCALL _port_init
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -