📄 aby018.c
字号:
#include "EM78x156xx.h"
#define ENI() _asm{ eni}
#define DISI() _asm{ disi}
#define NOP() _asm{nop }
#define WDTC() _asm{wdtc}
#define off R60
#define charge R61 //GP0//
#define discharge R62
#define key1 R64
#define key2 R65
#define key3 R66
#define key4 R67
#define pwmo1 R52
#define pwmo2 R53
typedef unsigned char uint8;
typedef short uint16;
/********************************************************************************************************/
uint8 manual_pwm=1;
uint8 charge_cout=0;
uint8 light_off_num=0;
uint8 n=0;
uint8 dis_play=0;
/********************************************************************************************************/
void inital()
{
_asm
{
mov a,@0x0f
contw
}
PORT5=0X00;
PORT6=0X00;
P5CR=0X00;
P6CR=0X12;
PDCR=0;
ODCR=0;
PHCR=0;
WDTCR=0x80;
IMR=0X00;
ISR=0X00;
discharge=1;
pwmo2=1;
pwmo1=1;
}
////////////////////////////////////
void delayms(uint16 delay_count){
unsigned char temp;
for(;delay_count>0;delay_count--)
{
for(temp=0;temp<3;temp++)
_asm
{
NOP;
}
_asm
{ wdtc
mov a,@0x0f
contw
}
}
}
/////////////////////////////////////
void main()
{
inital();
delayms(30000);
if(!key1)
dis_play=1;
manual_pwm=0;
discharge=0;
//for(charge_cout=0;charge_cout<10;charge_cout++)
// {;;;;;;;;}
while(!charge)
{ if(manual_pwm!=255)
manual_pwm++;
/* _asm
{
NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;
NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;
NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;
NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;
NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;
NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;
NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;
NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;
NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;
NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;
NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;
NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;
NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;
NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;
NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;
NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;
}*/
delayms(2);
}
//light_off_num=manual_pwm;
_asm
{
wdtc
mov a,@0x0f
contw
}
if(manual_pwm>=183)
light_off_num=10;
else if(manual_pwm>=173)
light_off_num=9;
else if(manual_pwm>=158)
light_off_num=8;
else if(manual_pwm>=141)
light_off_num=7;
else if(manual_pwm>=123)
light_off_num=6;
else if(manual_pwm>=102)
light_off_num=5;
else if(manual_pwm>=76)
light_off_num=4;
else if(manual_pwm>=39)
light_off_num=3;
else if(manual_pwm>=1)
light_off_num=2;
for(n=0;n<light_off_num;n++)
{if(dis_play)
{pwmo1=0;
pwmo2=0;
delayms(19000);
pwmo1=1;
delayms(19000);}
else
{pwmo2=0;
pwmo1=0;
delayms(19000);
pwmo2=1;
delayms(19000);}
}
/* else
{if(manual_pwm<=2)
manual_pwm=manual_pwm1;
else
{if(manual_pwm-5<=manual_pwm1&&manual_pwm1<=manual_pwm+5)
manual_pwm=manual_pwm;
else
manual_pwm=manual_pwm1;
}
begin_sign=1;
discharge=1;
discharge_cout=0;
ch_pwm=manual_pwm;
}*/
while(1)
{
pwmo2=0;
pwmo1=0;
_asm
{
wdtc
mov a,@0x0f
contw
}
}
}
void _intcall interrupt_l(void) @ 0x08:low_int 0
{
_asm
{
//save A --> 0x1F ; R3 --> 0x3E (ram bank 1); R4 --> 0x3F (ram bank 1)
MOV 0X1F,A ;backup A to 0x1F
SWAPA 0X04 ;backup R4 to 0x3F at bank 3
MOV 0X3F,A ;backup R4 to 0x3F at bank 3
SWAPA 0X03
MOV 0X3E,A ;backup R3 to 0x3E at bank 3
}
}
void _intcall interrupt(void) @ int 0
{
//backup C system
/* _asm
{
MOV A,0X10 //Depend on WicePlus reports in information window, Output window
MOV 0X2C+1,A
MOV A,0X11
MOV 0X2B+1,A
MOV A,0X12
MOV 0X2A+1,A
MOV A,0X13
MOV 0X29+1,A
MOV A,0X14
MOV 0X28+1,A
}
*/
// Write your code (inline assembly or C) here
//restore C system
/* _asm
{
MOV A,0X2C+1 //Depend on WicePlus reports in information window, Output window
MOV 0X10,A
MOV A,0X2B+1
MOV 0X11,A
MOV A,0X2A+1
MOV 0X12,A
MOV A,0X29+1
MOV 0X13,A
MOV A,0X28+1
MOV 0X14,A
}
*/
//restore ACC,R3,R4
_asm
{
SWAPA 0X3E ;restore R3
MOV 0X03,A
SWAPA 0X3F ;restore R4
MOV 0X04,A
SWAP 0X1F ;restore A
SWAPA 0X1F
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -