📄 demo2nd.asm
字号:
mov lb@MotorPt, a ;
mov a, lb@MotorPt;
add a, MotorPhase;
mov lb@MotorPt, a;
ldtabl MotorPt ;
mov MotorTmp, a;
mov a, pa;
and a, 0xe1;
or a, MotorTmp;
mov pa, a;
//--- Speed Control Setting
delay 0xFF; // Highest Speed delay !
delay 0xFF; //
delay 0xFF; //
delay 0xFF; // Highest Speed delay !
delay 0xFF; // Highest Speed delay !
delay 0xFF; // Highest Speed delay !
delay 0x80; // Highest Speed delay !
t1sn MotorSpeed.7;
goto MotoroNextSpeed6;
goto StepperMotorBegin; // goto Motor Begin;
MotoroNextSpeed6:
delay 0xFF;
delay 0xFF;
delay 0xFF;
t1sn MotorSpeed.6;
goto MotoroNextSpeed5;
goto StepperMotorBegin; // goto Motor Begin;
MotoroNextSpeed5:
delay 0xFF;
delay 0xFF;
delay 0xFF;
t1sn MotorSpeed.5;
goto MotoroNextSpeed4;
goto StepperMotorBegin; // goto Motor Begin;
MotoroNextSpeed4:
delay 0xFF;
delay 0xFF;
delay 0xFF;
t1sn MotorSpeed.4;
goto MotoroNextSpeed3;
goto StepperMotorBegin; // goto Motor Begin;
MotoroNextSpeed3:
delay 0xF0;
delay 0xF0;
delay 0xF0;
t1sn MotorSpeed.3;
goto MotoroNextSpeed2;
goto StepperMotorBegin; // goto Motor Begin;
MotoroNextSpeed2:
delay 0xF0;
delay 0xF0;
delay 0xF0;
t1sn MotorSpeed.2;
goto MotoroNextSpeed1;
goto StepperMotorBegin; // goto Motor Begin;
MotoroNextSpeed1:
delay 0xF0;
delay 0xF0;
delay 0xF0;
t1sn MotorSpeed.1;
goto MotoroNextSpeed0;
goto StepperMotorBegin; // goto Motor Begin;
MotoroNextSpeed0:
delay 0xFF;
delay 0xFF;
delay 0xFF;
delay 0xFF;
delay 0xFF;
delay 0xFF;
delay 0xFF;
goto StepperMotorBegin; // goto Motor Begin;
// goto fpp4MainLoop; // goto Motor Begin;
//*************************************************************
//------ Processor-5 Program routine ------------------
//*************************************************************
// Processor Demo is the Melody Player Demonstration Kits
// Processor 5 is dominate the Tempo, Processor 6 is the
// Frenquency controller
//---- Processor 5 Running in 500KHz ----
fpp5boot:
// SP Setting for Processor 5
mov a, 0xF0 ;
mov sp, a ;
// enable another Processors
mov a, 0x7F;
mov fppen, a; // enable processor 6
//--
fpp5MainLoop:
clear MusicCtrl;
MelodyPlayerBegin:
mov a, la@MusicTab ; // Music String table
mov lb@MusicPt, a ;
mov a, ha@MusicTab ;
mov hb@MusicPt, a ;
//-- Tempo Table --
ldtabl MusicPt ;
MusicToneLoop:
mov MusicFr, a;
ceqsn a, 0xFF;
goto NoMuteFrequency;
//-- Fr= 0xFF;
set0 fppen.6 ; // Disable Processor.6
set0 BuzzerIO;
goto NextToneTable;
NoMuteFrequency:
t0sn MusicCtrl.0; // check IR Command again !
set1 fppen.6 ; // Enable Processor.6
NextToneTable:
ldtabh MusicPt ;
mov MusicTone, a;
//--- Fixed as 187 mSec;
D187MSecTempoLoop:
t1sn MusicCtrl.0;
goto D187MSecTempoLoop;
// mov a, 0x80 ; // based on 500KHz
mov a, 0xC0 ; // based on 500KHz
mov D187ms, a ;
DelayTempo:
// delay 0xB3 ;
delay 0xB3 ;
dzsn D187ms ;
goto DelayTempo ;
dzsn MusicTone ;
goto D187MSecTempoLoop;
inc lb@MusicPt;
ldtabl MusicPt ;
ceqsn a, 0 ;
goto MusicToneLoop;
call DelayNoAcc;
call DelayNoAcc;
goto MelodyPlayerBegin ;
// goto fpp5MainLoop; // goto Motor Begin;
//========== end of MCU5 program ===========//
//========== start of MCU6 program =========//
//*************************************************************
//------ Processor-6 Program routine ------------------
//*************************************************************
// Processor Demo is the Melody Player Demonstration Kits
// Processor 5 is dominate the Tempo, Processor 6 is the
// Frenquency controller
//---- Processor 6 Running in 500KHz ----
fpp6boot:
// SP Setting for Processor 6
mov a, 0xF8 ;
mov sp, a ;
// enable another Processors
mov a, 0xFF;
mov fppen, a; // enable processor 6
fpp6MainLoop:
//--- buzzer
WaitPlayCommand:
t1sn MusicCtrl.0;
goto WaitPlayCommand;
//
set0 BuzzerIO;
MusicHoldFrequency: // frenquencey generate
tog BuzzerIO;
delay MusicFr;
goto MusicHoldFrequency ;
// goto fpp6MainLoop; // goto Motor Begin;
//========== end of MCU6 program ===========//
//========== start of MCU7 program =========//
//*************************************************************
//------ Processor-7 Program routine ------------------
//*************************************************************
// Processor Demo is handle a Servo Motor control -PWM
//---- Processor 7 Running in 250KHz ----
fpp7boot:
// SP Setting for Processor 7
mov a, 0xFC ;
mov sp, a ;
//
fpp7MainLoop:
mov a, 0x79;
sub a, PWMSet;
mov PWMSet_, a;
nop;
// tog pd.4; // Debug
clear PWMBase;
//---PWM Control
set1 SMTpwm5;
call PWMDutyBaseDelay;
mov a, PWMBase;
PWM_InceasementLoop:
ceqsn a, PWMSet;
goto ActivePWMSet;
goto Match_PWMSet;
ActivePWMSet:
inc PWMBase;
mov a, PWMBase;
goto PWM_InceasementLoop;
Match_PWMSet:
set0 SMTpwm5;
ComplementPWMLoop:
delay 0x02;
dzsn PWMSet_;
goto ComplementPWMLoop;
//
PWM_Control_Exit:
call PWMCycleDelay; // 19840 + 2
goto fpp7MainLoop; // 19840 uSec + 8T*2 ~ 19.870 mSec
//========== end of MCU7 program ===========//
PWMCycleDelay: //
mov a, 0x3A ; // 1T
mov PWMBaseDT1, a ; // 1T
PWMCycleloop:
delay 0x99 ; // 153T
dzsn PWMBaseDT1 ; // 1T
goto PWMCycleloop ; // 1T ----> 155*64*2uSec = 19.840 mSec
ret // 1T
//---
PWMDutyBaseDelay: //
delay 0xff ; // 256T
delay 0xc0; // 192T
ret // 1T+call(1T) = 450 T = 900 us
//========== end of MCU7 program ===========//
//--------------------------------------------------
//-------------------------------------------
//---- Debug Utility Routine (UART Tx)-------
//--------------------------------------------
//---- putc is the basic routine for UART's TX
//---- You can use the oscilloscope to fine tune
//---- needed delay clock...
//--------------------------------------------
Tx0putc:
mov a, 0x08 ;
mov Tx0Shiftbit, a;
set0 UART0_tx ; // start bit
delay Tx0Baud;
nop;
// there are 3 cycle to finish I/O toggle as bellow:
Tx0putc_loop:
src Tx0Buf ;
swapc UART0_tx ;
delay Tx0Baud;
dzsn Tx0Shiftbit;
goto Tx0putc_loop;
nop;
set1 UART0_tx ; // stop bit
delay Tx0Baud;
ret
///
//----
//--------- byte conveter to HEX String-----------
//----
Tx0putc_hex:
//-----
mov Tx0HEX, a; // save the argument
//----- you can ignor the "0x" characters
mov a, 0x30; // "0"
mov Tx0Buf, a ;
call Tx0putc;
mov a, 0x58; // "X"
mov Tx0Buf, a ;
call Tx0putc;
//----- End of "0x" characters Tx macro
mov a, Tx0HEX;
sr a; // get the High Nibble
sr a;
sr a;
sr a;
comp a, 0x0a; //a > 10?
t1sn flag.1; //
goto Tx0HexIsNumberString_High;
or a, 0x30;
goto Tx0Hex2StringHighNibbleEnd;
Tx0HexIsNumberString_High:
add a, 0x37;
Tx0Hex2StringHighNibbleEnd:
mov Tx0Buf, a ;
call Tx0putc;
//--- Low Nibble ---
mov a, Tx0HEX;
and a, 0x0f; // get the Low Nibble
//--
comp a, 0x0a; //a > 10?
t1sn flag.1;
goto Tx0HexIsNumberString_Low;
or a, 0x30;
goto Tx0Hex2StringLowNibbleEnd;
Tx0HexIsNumberString_Low:
add a, 0x37;
Tx0Hex2StringLowNibbleEnd:
mov Tx0Buf, a ;
call Tx0putc;
ret
//---------------------------------------
Tx0Printf_LFCR:
mov a, 0x0A; // Line feed(LF)
mov Tx0Buf, a;
call Tx0putc;
mov a, 0x0D; // character return(CR)
mov Tx0Buf, a;
call Tx0putc;
ret
//--
//--------------------------------------------
//---- putc is the basic routine for UART's TX
//---- You can use the oscilloscope to fine tune
//---- needed delay clock...
//--------------------------------------------
Tx1putc:
mov a, 0x08 ;
mov Tx1Shiftbit, a;
set0 UART1_tx ; // start bit
delay Tx1Baud;
nop;
// there are 3 cycle to finish I/O toggle as bellow:
Tx1putc_loop:
src Tx1Buf ;
swapc UART1_tx ;
delay Tx1Baud;
dzsn Tx1Shiftbit;
goto Tx1putc_loop;
nop;
set1 UART1_tx ; // stop bit
delay Tx1Baud;
ret
///
//----
//--------- byte conveter to HEX String-----------
//----
Tx1putc_hex:
//-----
mov Tx1HEX, a; // save the argument
//----- you can ignor the "0x" characters
mov a, 0x30; // "0"
mov Tx1Buf, a ;
call Tx1putc;
mov a, 0x58; // "X"
mov Tx1Buf, a ;
call Tx1putc;
//----- End of "0x" characters Tx macro
mov a, Tx1HEX;
sr a; // get the High Nibble
sr a;
sr a;
sr a;
comp a, 0x0a; //a > 10?
t1sn flag.1; //
goto Tx1HexIsNumberString_High;
or a, 0x30;
goto Tx1Hex2StringHighNibbleEnd;
Tx1HexIsNumberString_High:
add a, 0x37;
Tx1Hex2StringHighNibbleEnd:
mov Tx1Buf, a ;
call Tx1putc;
//--- Low Nibble ---
mov a, Tx1HEX;
and a, 0x0f; // get the Low Nibble
//--
comp a, 0x0a; //a > 10?
t1sn flag.1;
goto Tx1HexIsNumberString_Low;
or a, 0x30;
goto Tx1Hex2StringLowNibbleEnd;
Tx1HexIsNumberString_Low:
add a, 0x37;
Tx1Hex2StringLowNibbleEnd:
mov Tx1Buf, a ;
call Tx1putc;
ret
//---------------------------------------
Tx1Printf_LFCR:
mov a, 0x0A; // Line feed(LF)
mov Tx1Buf, a;
call Tx1putc;
mov a, 0x0D; // character return(CR)
mov Tx1Buf, a;
call Tx1putc;
ret
//--
IR_DelaySometime: // ~ 256*256*15*1us
mov a, 0x40 ;
mov IRdt1, a ;
mov a, 0x03 ;
mov IRdt2, a ;
IR_DelayIntLoop:
delay 0x60 ;
dzsn IRdt1 ;
goto IR_DelayIntLoop ;
dzsn IRdt2 ;
goto IR_DelayIntLoop ;
ret
//--
//--
PS2_DelaySometime: // ~ 256*256*15*1us
mov a, 0x40 ;
mov PS2DT0, a ;
mov a, 0x03 ;
mov PS2DT1, a ;
PS2_DelayIntLoop:
delay 0x60 ;
dzsn PS2DT1 ;
goto PS2_DelayIntLoop ;
dzsn PS2DT0 ;
goto PS2_DelayIntLoop ;
ret
//--
DelayNoAcc: //
clear DT0;
// mov a, 0x80;
// mov DT0, a;
NoAcc_loop6:
clear DT1;
NoAcc_loop7:
dzsn DT1 ; // 2*255 us = 510us + 2us = 512 us
goto NoAcc_loop7 ; //
dzsn DT0 ; // 512 * (255*2us) + 2 us = 261.122 ms
goto NoAcc_loop6 ;
ret
//--
//--
.romadr 0x480
//-- bootup logo string table ---
ASCIITab: dc 0x000A, 0x000D, 0x0057, 0x0065, 0x006C, 0x0063, 0x006F \
0x006D, 0x0065, 0x0020, 0x0074, 0x006F, 0x0020, 0x0050 \
0x0041, 0x0044, 0x0041, 0x0055, 0x004B, 0x0027, 0x0073 \
0x0020, 0x0046, 0x0050, 0x0050, 0x0041, 0x0028, 0x0074 \
0x006D, 0x0029, 0x0020, 0x0057, 0x006F, 0x0072, 0x006C \
0x0064, 0x002E, 0x0020, 0x000A, 0x000D, 0x0000; // ""
LEDTab: dc 0x0081, 0x0042, 0x0024, 0x0018, 0x0024, 0x0042, 0x0000 ;
LCMLOGOTab: dc 0x0020, 0x0046, 0x0050, 0x0050, 0x0041, 0x0020, 0x0044 \
0x0065, 0x006D, 0x006F, 0x0020, 0x004B, 0x0069, 0x0074 \
0x0073, 0x0020, 0x0000;
// 0x002D, 0x002D, 0x0020, 0x0041, 0x0020, 0x006D, 0x0075 \
// 0x006C, 0x0074, 0x0069, 0x002D, 0x0063, 0x006F, 0x0072 \
// 0x0065, 0x0020, 0x004D, 0x0043, 0x0055, 0x0021, 0x0000 ; // "Padauk Demo Kits"
ClockTab: dc 0x0054, 0x0069, 0x006D, 0x0065, 0x002D, 0x0030, 0x0030, 0x003A, 0x0030, 0x0030, 0x003A, 0x0030, 0x0030, 0x002E, 0x0030, 0x0030, 0x0000 ; // "Padauk Demo Kits"
MusicTab: dc 0x049A, 0x02FF, 0x029A, 0x0888, 0x089A, 0x0872, 0x0878, 0x08FF \
0x049A, 0x02FF, 0x029A, 0x0888, 0x089A, 0x0864, 0x0872, 0x08FF \
0x049A, 0x02FF, 0x029A, 0x084A, 0x0858, 0x0872, 0x0878, 0x0888 \
0x0454, 0x02FF, 0x0254, 0x0858, 0x0872, 0x0864, 0x0872, 0x08FF, 0x0000;
MOTORTab: dc 0x0012, 0x000A, 0x000c, 0x0014;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -