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

📄 demo2nd.asm

📁 八核心MCU 之FPPA 80Cxx 原廠範例程序
💻 ASM
📖 第 1 页 / 共 4 页
字号:
	goto	LEDPWM_CheckLoop;	
	set0	pd.7;		// debug
	goto	LEDPWM_BeginLoop;	
	goto	fpp0MainLoop;	//	goto Motor Begin;
	
	//*************************************************************
	//------ End of Processor-0 Program routine  ------------------
	//*************************************************************
	//*************************************************************
	//------ Processor-1 Program routine  ------------------
	//*************************************************************
	//	Processor 1 Demo is handle the receiver from Infra-Red module 
	//-- This IR Command will dominate this demo kit ! 
	//--- and debug this IR Code to UART
	//---- Processor 1 Running in 500KHz ----
fpp1boot:
	// SP Setting for Processor 1
	mov	a, 0xD8 ;
	mov	sp, a ;
	//	
	// enable another Processors
	mov		a, 0x07;
	mov		fppen, a;		// enable processor 2
fpp1MainLoop:
//---
IR_ReceiverLoop:
	//--- Phase 0, lock in High, wait for going low ---
	//--				
	//--- Phase 1, Identify to Header ---
	//--- Panasonic header is 
	set1	pd.4; //debug	
	// IR Low !!	
IR_WaitIO2Low:	
	wait1	IR_rxIO;		// make sure IO is high first !!
	wait0	IR_rxIO;		// Wait the IR IO low, Header Low phase
	delay	0xC0;			// delay some duration for debounce the Input, 
							// this Duration should wide more normal Data !!
	t0sn	IR_rxIO;		// Wait the IR IO low
	goto	IR_WaitIO2Low;	// Noise maybe !!
	// -- IR is Low really!!
	set0	pd.4; //debug		
IR_PassID_High:	
	wait1	IR_rxIO;			// Wait the IR IO High, pass the ID, Header High phase 
//	set1	pb.3;
	mov		a, 0x08;		// 
	mov		IRSerialBit, a;		// 8 bit serial data in
	mov		a, 0x20;
	mov		lb@RAMPtr, a;	
	//---------------
IR_DataSerialLow:
	wait0	IR_rxIO;			// Wait the IR IO low, then go next phase wait high and calculate High duty
	// IR is low !
IR_DataSerialHigh:			// Next phase !!
	// wait high for calculate the Duty --
	wait1	IR_rxIO;			// Wait the IR IO High!!
	//--- Monitor the High Duty -- Here ---
	// -- IR data is High now !!
	clear	IRHighDuty;	
IR_PollingHighDuty:
	t1sn	IR_rxIO;			// calcultae High duty until IR Data is low
	goto	IRFromHigh2Low;				
	nop;	// increament the counter length, avoid overflow persistently		
	nop;	// increament the counter length, avoid overflow persistently		
	izsn	IRHighDuty;
	goto 	IR_PollingHighDuty;	
	//---- Time-Out, Error Correction --
	goto	IR_ReadDataTimeOutError;
	//---pd.0 is low now, here ---
IRFromHigh2Low:
	mov		a, IRHighDuty;
	sub		a, 0x40;	
	t0sn	flag.1	;		// data is 1 or 0 ?	
	goto	IR_ReadSerialDataHighBit;
	set1	flag.1	;	// set Flag.c = 1
	nop
	goto	IR_ReadSerialnextBit;
IR_ReadSerialDataHighBit:	
	nop
	set0	flag.1	;	// set Flag.c = 0
IR_ReadSerialnextBit:	
	idxm	a, RAMPtr;
	src		a;
	idxm	RAMPtr, a;
	dzsn	IRSerialBit;	
	goto	IR_DataSerialHigh;	
	//--
//	tog	pb.3;
	inc		lb@RAMPtr;
	mov		a, lb@RAMPtr;
//	mov	pc, a;
	ceqsn	a, 0x26 ;
	goto	IR_NextBytesLoop ;
	goto	IR_ReadDataSuccessEnd;
IR_NextBytesLoop:	
//	tog	pb.3;			//debug
	mov		a, 0x08;		// 
	mov		IRSerialBit, a;		// 8 bit serial data in	
	goto	IR_DataSerialHigh;
	
IR_ReadDataSuccessEnd:	
//---
//======== IR Command Code parser and decode command ===
//---	
	mov		a, IRData_Code;
	//---- Command #1 ?!
	ceqsn	a, 0x05;			// KINYO RC-1220
	goto	IRParseCommandCode1;
	//-- IR Code = 0x14, Motor Play command
	//==== if Motor is running now, then pause motor 
	//------  and reset speed to the default setting
	t1sn	MotorCtrl.0;	// motor is running  ?!
	goto 	IRMotorCommandParser0;
	//--- Motor Pause ---	
	clear	MotorSpeed;		// reset Motor Speed, default speed;
	set0	MotorCtrl.0;	// inhitbit Motor
	mov		a, pa;			// release the motor phase 
	and		a, 0x0f;
	mov		pa, a;
	goto 	IRCommandParserEnd;	// end of IR Command Parser
IRMotorCommandParser0:	
	//--- Motor startup ---
	set1	MotorCtrl.0;	// Enable Motor
	goto 	IRCommandParserEnd;	// end of IR Command Parser
IRParseCommandCode1:
	//---- Command #2 ?!
	ceqsn	a, 0x34;		// // KINYO RC-1220
	goto	IRParseCommandCode2;
	//-- IR Code = 0x05, Motor Speed Up command
	t0sn	MotorSpeed.7;
	goto 	IRCommandParserEnd;	// limited Speed, invalid Command
	set1	flag.1	;	// set Flag.c = 1
	mov		a, MotorSpeed;
	slc		a;
	mov		MotorSpeed, a;
	goto 	IRCommandParserEnd;	// end of IR Command Parser
IRParseCommandCode2:
	//---- Command #3 ?!
	ceqsn	a, 0x35;		// // KINYO RC-1220
	goto	IRParseCommandCode3;
	//-- IR Code = 0x02, Motor Speed Down command
	t1sn	MotorSpeed.0;
	goto 	IRCommandParserEnd;	// limited Speed, invalid Command
	set0	flag.1	;	// set Flag.c = 0	
	mov		a, MotorSpeed;
	src		a;
	mov		MotorSpeed, a;	
IRParseCommandCode3:
	//---- Command #4 ?!
	ceqsn	a, 0x32;		// // KINYO RC-1220
	goto	IRSMotorCommandCode0;
	//-- IR Code = 0x0c, Music On/Off ---
	t1sn	MusicCtrl.0;	// Melody is playing  ?!
	goto 	IRMusicCommandParser0;
	//--- Melody Pause ---	
	set0	MusicCtrl.0;	// inhitbit Music
	mov		a, 0xFF;
	mov		MusicFr, a;	// invalid Frequency 
	set0	fppen.6 ;	// Disable Processor.5
	set0	BuzzerIO;	
	goto 	IRCommandParserEnd;	// end of IR Command Parser
IRMusicCommandParser0:	
	set1	MusicCtrl.0;	// enable Music
	goto 	IRCommandParserEnd;	// end of IR Command Parser
IRSMotorCommandCode0:	
	//---- Servo Motor Command  ?!
	ceqsn	a, 0x21;		// // KINYO RC-1220
	goto	IRSMotorCommandCode1;
	mov		a, PWMSet;
	ceqsn	a, 0x78;	// PWM Maxinum ?
	goto	ServoPWMInc;
	goto 	IRCommandParserEnd;	// No Active, end of IR Command Parser
ServoPWMInc:	
	mov		a, 0x0A;
	add		a, PWMSet;
	mov		PWMSet, a;
	goto 	IRCommandParserEnd;	// No Active, end of IR Command Parser
IRSMotorCommandCode1:
	ceqsn	a, 0x20;		// // KINYO RC-1220
	goto	IRSMotorCommandCode2;
	mov		a, PWMSet;
	ceqsn	a, 0x00;	// PWM Mininum ?
	goto	ServoPWMDec;
	goto 	IRCommandParserEnd;	// No Active, end of IR Command Parser
ServoPWMDec:	
	mov		a, PWMSet;
	sub		a, 0x0A;
	mov		PWMSet, a;
	goto 	IRCommandParserEnd;	// No Active, end of IR Command Parser
IRSMotorCommandCode2:
	ceqsn	a, 0x47;		// // KINYO RC-1220
	goto	IRSMotorCommandCode3;
	mov		a, 0x78;
	mov		PWMSet, a;
	goto 	IRCommandParserEnd;	// No Active, end of IR Command Parser
IRSMotorCommandCode3:
	ceqsn	a, 0x46;		// // KINYO RC-1220
//	goto	IRSMotorCommandCode3;
	goto 	IRCommandParserEnd;	// No Active, end of IR Command Parser
	mov		a, 0x00;
	mov		PWMSet, a;
//	goto 	IRCommandParserEnd;	// No Active, end of IR Command Parser
///============== For Debug using the UART ===========
IRCommandParserEnd:
	//--- Tx out the UART(RS232) to Host PC---
	//------ Reset FIFO Buffer pointer
	mov		a, 0x20;			// 
	mov		lb@RAMPtr, a;	// reset the FIFO Pointer	
IR_ReceiveUARTOut:				// UART Rx FIFO to Host PC
	idxm	a, RAMPtr;
	call	Tx0putc_hex;
	mov		a, 0x20;			// blank
	mov		Tx0Buf, a;
	call	Tx0putc;
	inc		lb@RAMPtr;
	mov		a, lb@RAMPtr;
	ceqsn	a, 0x26;		// End of Slave Rx
	goto	IR_ReceiveUARTOut;

	call	Tx0Printf_LFCR;		// 
IR_ReadDataTimeOutError:
	call	IR_DelaySometime;
//====== End of Debug for UART ===========================
	set1	pd.4; //debug	
	goto	IR_ReceiverLoop;		
	goto	fpp1MainLoop;	//	goto Motor Begin;
	//--

//========== start of MCU2 program =========//
	//*************************************************************
	//------ Processor-2 Program routine  ------------------
	//*************************************************************
	//	Processor Demo is handle the LCM Display Module 
	//  and Demonstration a look alike Stopwatch!! 
	//---- Processor 2 Running in 250KHz ----
fpp2boot:
	// SP Setting for Processor 2
	mov	a, 0xE0 ;
	mov	sp, a ;
	//	
	//---
	set0	LCMen;
	set0	LCMrw;
	set0	LCMrs;
	//--
	set0	LCMd4;
	set0	LCMd5;
	set0	LCMd6;
	set0	LCMd7;
fpp2MainLoop:	
InitialLCMLOOP:	
	//--
	//---Initial LCM ---
	//--
	set0	LCMen;		// clear En
	delay	0x80;
	delay	0x40;
	//-- write 0x30 for High Nibble --
	set1	LCMd4;
	set1	LCMd5;
	call	LCM_EnTrigger;
	delay	0xff;		// delay more than 4.1 ms
	delay	0xff;	
	delay	0x40;
	//-- write 0x30 for High Nibble --
	set1	LCMd4;
	set1	LCMd5;
	call	LCM_EnTrigger;
	delay	0xC0;		// delay more than 100us	
	delay	0x40;
	//-- write 0x30 for High Nibble --
	set1	LCMd4;
	set1	LCMd5;
	call	LCM_EnTrigger;
	delay	0x80;		
	delay	0x40;
	//-- write 0x20 for High Nibble -- // 4-Bit Data Mode
	set0	LCMd4;
	set1	LCMd5;
	call	LCM_EnTrigger;
	//---
	mov		a, 0x28;	// two Row display module and 5x7 segments
	call	LCM_WriteCommandData;	
	delay	0xC0;		
	delay	0x40;
	mov		a, 0x0C;	// Display On, Cursor Off , and No blinking
	call	LCM_WriteCommandData;	
	delay	0xA0;		
	delay	0x40;
	mov		a, 0x06;	// Entry Mode 
	call	LCM_WriteCommandData;		
	delay	0xA0;		
	delay	0x40;
	///----------
	///------End of Initial LCM ------
	///----------
	mov		a, 0x01;	// Clear Display
	call	LCM_WriteCommandData;		
	delay	0x60;		
	delay	0x40;
	mov		a, 0x02;	// Cursor go Home 
	call	LCM_WriteCommandData;		
	delay	0xff;		
	delay	0x40;
	//	
	mov		a, 0x80;			// Cursor move to First Row
	call	LCM_WriteCommandData;		
	delay	0xA0;	
	delay	0x40;
	//-- Initialize the display : Show LEGO and Display Form ----
	//--
LCM_Initialize:	
	//--- Row # 1
	mov		a, la@LCMLOGOTab ;		// ASCII String table 
	mov		lb@LCMStrPt, a ;
	mov		a, ha@LCMLOGOTab ;
	mov		hb@LCMStrPt, a ;
	clear	FirstRowPos;	
	mov		a, 0x80;			// Cursor move to First Row
	call	LCM_WriteCommandData;		
	delay	0xB0;
	delay	0x60;
LCMShowLogoString:	
	set1	LCMrs;		// RS high
//	set1	pb.2;		// RS high, 
	ldtabl  LCMStrPt ;
	call	LCM_WriteCommandData;		
//	set0	pb.2;		// RS low
	set0	LCMrs;		// RS low
	inc		FirstRowPos;
	mov		a, FirstRowPos;
	ceqsn	a, 0x0F;
	goto	LCMShowFisrtRowNext;
	goto	LCMShowFirstRowExit;	
LCMShowFisrtRowNext:	
	inc		lb@LCMStrPt;
	ldtabl  LCMStrPt ;
	ceqsn   a, 0 ;
	goto	LCMShowLogoString ;	
LCMShowFirstRowExit:	
	//--- initial Clock Parameters
	clear	u10Sec;
	clear	u100Sec;
	clear	s1Sec;
	clear	s10Sec;
	clear	m1Min;
	clear	m10Min;
	clear	h1Hour;
	clear	h10Hour;
	//--- Row # 2
	mov		a, la@ClockTab ;		// ASCII String table 
	mov		lb@LCMStrPt, a ;
	mov		a, ha@ClockTab ;
	mov		hb@LCMStrPt, a ;
	mov		a, 0xc0;	// Second Row
	call	LCM_WriteCommandData;		
	delay	0xB0;
	delay	0x60;
LCMShowClockString:	
//	set1	pb.2;		// RS high, 
	set1	LCMrs;		// RS high
	ldtabl  LCMStrPt ;
	call	LCM_WriteCommandData;		
//	set0	pb.2;		// RS low
	set0	LCMrs;		// RS low
	
	inc		lb@LCMStrPt;
	ldtabl  LCMStrPt ;
	ceqsn   a, 0 ;
	goto	LCMShowClockString ;	
	//--- Re-initial and Set Next Rolling pointer
//	mov		a, la@LCMLOGOTab ;		// ASCII String table 
//	mov		lb@LCMStrPt, a ;
//	add		a, 0x01;
//	mov		Nextpoint, a;
//	mov		a, ha@LCMLOGOTab ;
//	mov		hb@LCMStrPt, a ;	
	// enable another Processors
	mov		a, 0x0F;
	mov		fppen, a;		// enable processor 3
	//--	
	//-- Delay in a while ---
	mov     a, 0xF0 ;
    mov     ClockDelayT0, a ;
InitialClockDelayLoop:
    delay   0xF0 ;
    delay   0xF0 ;
    delay   0xF0 ;
    dzsn    ClockDelayT0 ;
    goto    InitialClockDelayLoop ;
	
//	goto	$;
//	goto	fpp2MainLoop;	//	goto Motor Begin;
ClockDemoLoop:
	//---- 1/100 Sec
	//---- This delay is not based on 1 Sec !!
	///--  This just demonstrate a real running timer instead of real clock!!
	//--
.ifdef 0
//	mov		a, u100Sec ;
	mov		a, s1Sec;
	ceqsn	a, 0x00;
	goto	LCMShowLogoRollingStringExit;

	clear	FirstRowPos;	
	//-- Backup the next pointer
	mov		a, lb@LCMStrPt;
	add		a, 0x01;
	mov		Nextpoint, a;
	ldtabl  LCMStrPt ;
	ceqsn   a, 0x00 ;
	goto	SetNextPointerExit;	
	//--- Reset Table Pointer
//	mov		a, la@ClockTab ;		// ASCII String table 
//	mov		a, la@LCMLOGOTab ;	
	mov		a, la@LCMLOGOTab ;	
	mov		Nextpoint, a;
SetNextPointerExit:	
	ldtabl  LCMStrPt ;	
	mov		a, 0x80;			// Cursor move to First Row
	call	LCM_WriteCommandData;		
	delay	0xB0;
	delay	0x60;
LCMShowLogoRollingString:	
	set1	LCMrs;		// RS high
	ldtabl  LCMStrPt ;
	call	LCM_WriteCommandData;		
	set0	LCMrs;		// RS low
	//-- End of Row
	inc		FirstRowPos;
	mov		a, FirstRowPos;
	ceqsn	a, 0x0F;
	goto	LCMShowRollingNext;
	//-- Reset Table pointer to Next character
	mov		a, Nextpoint;
	mov		lb@LCMStrPt, a ;	
	goto	LCMShowLogoRollingStringExit;
LCMShowRollingNext:	
	inc		lb@LCMStrPt;
	ldtabl  LCMStrPt ;
	ceqsn   a, 0x00 ;
	goto	LCMShowLogoRollingString ;	
	//--- Reset Table Pointer
//	mov		a, la@ClockTab ;		// ASCII String table 
	mov		a, la@LCMLOGOTab ;	
	mov		lb@LCMStrPt, a ;
	ldtabl  LCMStrPt ;
	goto	LCMShowLogoRollingString ;	
LCMShowLogoRollingStringExit:	
	clear	FirstRowPos;	
.endif	
///--	
	//-- Delay in a while ---

⌨️ 快捷键说明

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