给个DEMO给你们看一下吧....只用了两核...还有6个 processors在睡觉...但算这样简单的东西...用普通单片机忙累你,还达不到perfect效果!!!
;*************************************************************************** ;Project Name: ;File Name : LED ;Content : ;Environment: PADAUK FPPA(TM) IDE Tool Version : 0.552 Beta ;Notes: PB1 ---> KEY IN , PB6 ---> Controling output. ;****************************************************************************
.ramadr 0x00 int DELAY_UP int PWM_DELAYTIME int FLAG int PWM_SPEED int DIRECTION int DOWN_DELAY int DOWN_DELAY1 int MODE int DELAY4MS int DELAY4MS1
PWM_BEGINFG equ 0 PWM_LOTOPFG equ 2 PWM_HITOPFG equ 3 KEYPIN equ 4
.romadr 0x00 ;---------------------ROM start--------------------- ;--- Program Begin goto sys_reset ;Processor #0 entry vector goto fpp1boot ;Processor #1 entry vector goto fpp2boot ;Processor #2 entry vector goto fpp3boot ;Processor #3 entry s goto fpp4boot ;Processor #4 entry vector goto fpp5boot ;Processor #5 entry vector goto fpp6boot ;Processor #6 entry vector goto fpp7boot ;Processor #7 entry vector .romadr 0x10 reti ;--- Boot-up the chip use Processor-0 here! sys_reset: set0 clkmd.1 ; turn-off watchdog //------Low clock switch to High clock--------------------------------------- mov a, 0 //内部RC 8M mov eoscr, a; delay 0xFF; delay 0xFF; delay 0xFF; delay 0xFF; delay 0xFF; delay 0xFF; mov a, 0x54 mov clkmd, a // Internal HIGH SPEED RC, Watch Dog disable, delay 254 mov a, 0xd0 mov sp, a mov a, 0xff mov pac, a mov a, 0xff mov pa, a mov a, 0xf0 mov pbc, a mov a, 0x0f mov pb, a pmode 0x02 delay 250 mov a, 0x03; mov fppen, a; // enable processor 1 disgint //engint ;*********fppa 0 program******************** ;KEY ;******************************************* fpp0boot: clear MODE clear FLAG clear DIRECTION clear PWM_SPEED fpp0_loop: mov a,0 ceqsn MODE,a goto MODE_CHECK goto MODE_0 MODE_CHECK: mov a,1 ceqsn MODE,a goto MODE_CHECK1 goto MODE_1 MODE_CHECK1: mov a,2 ceqsn MODE,a goto TASK_END goto MODE_2 MODE_0: set0 pb.6 goto TASK_END MODE_1: set1 pb.6 mov a,254 mov DELAY_UP,a set0 FLAG.2 set0 FLAG.3 set1 FLAG.0 clear DIRECTION goto TASK_END MODE_2: set1 pb.6 mov a,DELAY_UP call PWM_DELAY mov a,253 sub a,DELAY_UP t0sn flag.1 goto TASK_END set0 pb.6 mov a,0xff sub a,DELAY_UP call PWM_DELAY TASK_END: goto fpp0_loop ;*********fppa 1 program******************** ; PWM ;******************************************* fpp1boot: mov a, 0xd8 mov sp, a mov a, 0x07; mov fppen, a; // enable processor 2 fpp1loop: t1sn FLAG.0 inc PWM_SPEED mov a,5 ceqsn PWM_SPEED,a goto SWITCH_DEAL clear PWM_SPEED t0sn DIRECTION.0 goto ANATHERDIR dec DELAY_UP mov a,6 sub a,DELAY_UP t0sn flag.1 goto SWITCH_DEAL set1 FLAG.2 mov a,6 mov DELAY_UP,a goto SWITCH_DEAL ANATHERDIR: inc DELAY_UP mov a,253 sub a,DELAY_UP //ceqsn DELAY_UP,a t1sn flag.1 goto SWITCH_DEAL set1 FLAG.3 mov a,254 mov DELAY_UP,a //goto SWITCH_DEAL SWITCH_DEAL: t0sn pb.1 goto RELEASE inc DOWN_DELAY mov a,200 ;250 sub a,DOWN_DELAY t1sn flag.1 goto func_end clear DOWN_DELAY inc DOWN_DELAY1 mov a,1 ;2 sub a,DOWN_DELAY1 t1sn flag.1 goto func_end DOWN_1: mov a,2 mov DOWN_DELAY1,a mov a,0 ceqsn MODE,a goto MODE2TO2 goto func_end MODE2TO2: mov a,2 mov MODE,a t0sn DIRECTION.0 goto ADDPWM t1sn FLAG.2 goto OPENPWM set0 FLAG.0 goto func_end ADDPWM: t1sn FLAG.3 goto OPENPWM_1 set0 FLAG.0 goto func_end OPENPWM_1: set1 FLAG.0 goto func_end OPENPWM: set1 FLAG.0 goto func_end RELEASE: mov a,2 ceqsn DOWN_DELAY1,a goto NEXT50MS mov a,0 ceqsn MODE,a goto NEXT2STEST mov a,1 mov MODE,a clear DOWN_DELAY1 clear DOWN_DELAY goto func_end NEXT2STEST: mov a,2 ceqsn MODE,a goto MODE2_2SOUT set0 FLAG.0 t0sn DIRECTION.0 goto CHECKANOTHER t1sn FLAG.2 goto MODE2_2SOUT set0 FLAG.2 goto MODE2_2SOUT CHECKANOTHER: t0sn FLAG.3 set0 FLAG.3 MODE2_2SOUT: not DIRECTION clear DOWN_DELAY1 clear DOWN_DELAY goto func_end NEXT50MS: mov a,0 ceqsn DOWN_DELAY1,a goto NEXT2STO50MS mov a,15 sub a,DOWN_DELAY t0sn flag.1 goto NEXT2STO50MS clear DOWN_DELAY clear DOWN_DELAY1 goto func_end NEXT2STO50MS: mov a,0 ceqsn MODE,a goto NEXTMODE mov a,1 mov MODE,a clear DOWN_DELAY clear DOWN_DELAY1 goto func_end NEXTMODE: mov a,1 ceqsn MODE,a goto NEXTMODE_1 clear MODE clear DOWN_DELAY clear DOWN_DELAY1 goto func_end NEXTMODE_1: mov a,2 ceqsn MODE,a goto func_end clear MODE clear DOWN_DELAY clear DOWN_DELAY1 set0 FLAG.2 set0 FLAG.3 func_end: mov a,5 ;0x6 mov DELAY4MS,a mov DELAY4MS1,a D1: dzsn DELAY4MS goto D1 dzsn DELAY4MS1 goto D1 goto fpp1loop ;*********fppa 2 program******************** fpp2boot: mov a, 0xe0 mov sp, a fpp2loop: goto fpp2loop ;*********fppa 3 program******************** fpp3boot: mov a, 0xe8 mov sp, a mov a,0x1f mov fppen,a fpp3loop:
goto fpp3loop ;*********fppa 4 program******************** fpp4boot: mov a, 0xec mov sp, a mov a,0x3f mov fppen,a fpp4loop:
goto fpp4loop ;*********fppa 5 program******************* fpp5boot: mov a,0xf0 mov sp, a mov a,0x7f mov fppen,a fpp5loop: goto fpp5loop ;*********fppa 6 program****************** fpp6boot: mov a, 0xf8 mov sp, a mov a,0xff mov fppen,a fpp6loop: goto fpp6loop ;*********fppa 7 program***************** fpp7boot: mov a, 0xfc mov sp, a fpp7loop: goto fpp7loop
//*************************************** PWM_DELAY: xor a,0 t0sn flag.0 goto DELAY1END mov PWM_DELAYTIME,a DELAY1: nop nop dzsn PWM_DELAYTIME goto DELAY1 DELAY1END: ret |