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

📄 demo2nd.asm

📁 八核心MCU 之FPPA 80Cxx 原廠範例程序
💻 ASM
📖 第 1 页 / 共 4 页
字号:
//***************************************************************************
//***** 	FPPA(tm) PDK80Cxx  Application Example Project 		*************
//***************************************************************************
//	Example Name :: OTP Tools 1_8					Version 1.00		
//	Module Name  :: OTPTools.ASM
//	Abstract:
//        	2nd Version Demonstration kit application  
//	Environment:
//        	PADAUK FPPA(TM) IDE Tool Version : 0.510 Beta
//
//	Revision History:
//        	Sept. 15, 2006        Chamber C.P. Ling  Created                 
/////////////////////////////////////////////////////////////////////////
// Copyright (C) 2006 by PADAUK Technology Co. Ltd. All rights reserved.
//
// This code is free for personal and commercial use, providing this 
// notice remains intact in the source files and all eventual changes are
// clearly marked with comments.
//
// No warrantee of any kind, express or implied, is included with this
// software; use at your own risk, responsibility for damages (if any) to
// anyone resulting from the use of this software rests entirely with the
// user.
//
// See the official site at www.padauk.com.tw for documentation and
// the latest news.
//
// Send bug reports, bug fixes, enhancements, requests, flames, etc. to
// service@padauk.com.tw or post them at the message board at the site.
/////////////////////////////////////////////////////////////////////////
// Description:
//	OTPTools.ASM is a tool code for duplicating to 8 OTP chips from a source chip.  
//   
//  This Demo code include a UART Debug function!
//=======================================================================
//--- I/O Pin define
BuzzerIO	equ	pb.2;	// Output
//-- Infra-red
IR_rxIO		equ	pb.1;	// Input
IR_txIO		equ	pb.0;	// Output
//-- UART
UART0_tx	equ	pc.7;	// Output
UART0_rx	equ	pc.5;	// Input	
UART1_tx	equ	pc.6;	// Output
UART1_rx	equ	pc.4;	// Input	
//---
Tx0Bset		equ	0x2E;	// Tx0 Baudrate setting , 9600 based on 500kHz
Tx1Bset		equ	0x08;	// Tx0 Baudrate setting , 38400 based on 500kHz
//-- PWM LED
LEDr		equ	pd.0;	// Output
LEDb		equ	pd.1;	// Output
LEDg		equ	pd.2;	// Output
//--- Stepper Motor --
SMotorA		equ	pa.1;	// Output
SMotorB		equ	pa.2;	// Output
SMotorA_	equ	pa.3;	// Output
SMotorB_	equ	pa.4;	// Output
//--- LCM ---
LCMd4		equ	pb.4;	// bi-direct
LCMd5		equ	pb.5;	// bi-direct
LCMd6		equ	pb.6;	// bi-direct
LCMd7		equ	pb.7;	// bi-direct
LCMrw		equ	pb.3;	// output
LCMen		equ	pe.7;	// output
LCMrs		equ	pe.6;	// output
//-- PS/2 Keyboard --
KBclk		equ	pe.2;	// bi-direct
KBdat		equ	pe.1;	// bi-direct
//-- PS/2 Mouse --
PS2DAT		equ	pe.0;	// bi-direct
PS2CLK		equ	pe.3;	// bi-direct
//-- Hotkey --
KeySW1		equ	pa.0;	// input
KeySW2		equ	pc.2;	// input
//-- Servo Motor (PWM) --
SMTpwm1		equ	pc.3;	// output
SMTpwm2		equ	pe.5;	// output
SMTpwm3		equ	pe.4;	// output
SMTpwm4		equ	pc.0;	// output
SMTpwm5		equ	pc.1;	// output
SMTpwm6		equ	pd.3;	// output
//--
//--- Macro define
//---
PS2DAT_Input	macro	
		set0	pec.0;
		endm
PS2DAT_Output	macro	
		set1	pec.0;
		endm
PS2CLK_Input	macro	
		set0	pec.3;
		endm
PS2CLK_Output	macro	
		set1	pec.3;
		endm
//---

//.define   IR_Debug;
//==================================
//--- Internal Memory Define ---
//==================================
word	RAMindex;
//----parameters definitions of UART TX function  --
word	TxStrPt ;
//--
int		UARTCt;		// bit0	: 1: Enable TX0 , 0:Inhibit TX0 !!
					// bit1	: 1: Enable RX0 , 0:Inhibit RX0!!
					// bit2	: 1: Enable TX1 , 0:Inhibit TX1!!
					// bit3	: 1: Enable RX1 , 0:Inhibit RX1!!
					// bit4	: Reserved
					// bit5	: Reserved
					// bit6	: Reserved
					// bit7	: Reserved
int		UARTSt;		// bit0	: 1: TX0 Busy , 0:TX0 Free!!
					// bit1	: 1: RX0 Busy , 0:RX0 Free!!
					// bit2	: 1: TX1 Busy , 0:TX1 Free!!
					// bit3	: 1: RX1 Busy , 0:RX1 Free!!
					// bit4	: Reserved!
					// bit5	: Reserved					
					// bit6	: Reserved
					// bit7	: Reserved					
//-------Tx0/Rx0 --- 
//----- UART1 Tx0 Function Debug for Infra-Red ----- 
int		Tx0Buf ;		// Tx0 Buffer
int		Tx0Shiftbit;	// Tx0 Shift bit, if protocol is 8bit, then it is 8 
int 	Tx0Baud;		// Tx0 Baudrate Time Base, see the detail as followed
int		Tx0HEX;			// register for call function
//-- receive Function  (No used)-----
int 	Rx0Buf;			// Rx0 Buffer
int		Rx0Shiftbit; 	// Rx0 Shift bit, if protocol is 8bit, then it is 8
int 	Rx0Baud;		// Rx0 Baudrate Time Base, see the detail as followed
int		FIFO0Buf;		// One FIFO for UART1, based on your applications,
int 	Rx0BaudOffset;	// Offset Time clock for Rx Sample pointer(TxBaudrate/2)
//
//-------Tx1/Rx1 --- 
//----- UART2 Tx1 Function Debug for Infra-Red ----- 
int		Tx1Buf ;		// Tx1 Buffer
int		Tx1Shiftbit;	// Tx1 Shift bit, if protocol is 8bit, then it is 8 
int 	Tx1Baud;		// Tx1 Baudrate Time Base, see the detail as followed
int		Tx1HEX;			// register for call function
//-- receive Function  (No used)-----
int 	Rx1Buf;			// Rx1 Buffer
int		Rx1Shiftbit; 	// Rx1 Shift bit, if protocol is 8bit, then it is 8
int 	Rx1Baud;		// Rx1 Baudrate Time Base, see the detail as followed
int		FIFO1Buf;		// One FIFO for UART1, based on your applications,
int 	Rx1BaudOffset;	// Offset Time clock for Rx Sample pointer(TxBaudrate/2)
//---Processor 1 Application parameters definition block
//	R-G-B LED Sequencer flasher (PWM Control)
//word	LEDTabPtr;
int		LED_PWMBase;
int		LED_Rpwm;		// LED R PWM
int		LED_Gpwm;;		// LED G PWM
int		LED_Bpwm;;		// LED B PWM
//----
//--
//--
//---Processor 3 Application parameters definition block
//	 Infra-Red Receiver Module
.ramadr	0x20
//---IR parameters
int		IRData_ID0;	
int		IRData_ID1;	
int		IRData_ID2;	
int		IRData_ID3;	
int		IRData_Code;
int		IRData_CodeInv;		
int		IRHighDuty;
int		IRSerialBit;
word	RAMPtr;
//--
int		IRdt1;
int		IRdt2;
//--
//---Processor 2 Application parameters definition block
//	LCM Dsiplay Module
word	LCMStrPt ;
int		LCMArgu ;
int		u10Sec ;
int		u100Sec;
int		s1Sec;
int		s10Sec;
int		m1Min;
int		m10Min;
int		h1Hour;
int		h10Hour;
int		ClockDelayT0;		// LED Delay duration 0
//--
int		FirstRowPos;
int		Nextpoint;
//---Processor 3 Application parameters definition block
//	 PS2 Keyboard Control Module
//	 PS2 Mouse Control Module
int		PS2HostCommand;
int		PS2DeviceData;
int		PS2Shiftbit;
int		PS2Ctrl;
int		PS2TimeOutCLK;
//--
int		PS2_Ack;			// PS2 Ack 
int		PS2_BAT;			// BAT(Basic Assurance Test)
int		PS2_DeviceID;		// PS2 Device ID (Mouse)
int		PS2_MouseB1;		// Mouse movement Data
int		PS2_MouseB2;		// Mouse movement Data
int		PS2_MouseB3;		// Mouse movement Data
int		PS2_MouseB4;		// Mouse movement Data
//--
int		PS2DT0;
int		PS2DT1;
// 

//---Processor 4 & 5 Application parameters definition block
//	 Melody Music player Module
word	MusicPt ;
int		MusicTone ;
int		MusicFr;
int		D187ms ;		// Music tempo delay, 187mSec
int		MusicCtrl;
//--
//---Processor 6 Application parameters definition block
//	 Stepper Motor Control Module
word	MotorPt ;
int		MotorTmp;
int		MotorCtrl;
int		MotorSpeed;
int		MotorPhase;
//--
//---Processor 7 Application parameters definition block
//	 Servo Motor Control Module
int		PWMBaseDT0;
int		PWMBaseDT1;
//--
int		PWM_MSB;
int		PWM_LSB;
//--
int		PWMBase;	// 0~255
int		PWMSet;		// 0~255
int		PWMSet_;
//
//
int		GR0;		// general Register #0
int		GR1;		// general Register #1
int		GR2;		// general Register #2
int		GR3;		// general Register #3
int		GR4;		// general Register #4
int		GR5;		// general Register #5
int		GR6;		// general Register #6
int		GR7;		// general Register #7
//
//--
int		DT0;
int		DT1;
int		DT2;
int		DT3;
//
//===============================================================
	// Program Begin
	goto	fpp0boot ;
	goto	fpp1boot ;
	goto	fpp2boot ;
	goto	fpp3boot ;
	goto	fpp4boot ;
	goto	fpp5boot ;
	goto	fpp6boot ;
	goto	fpp7boot ;

//========= start MCU0 program ============//
fpp0boot:
	set0	clkmd.1;		// turn-off watchdog
//------Low clock switch to High clock---------------------------------------
	mov		a, 0xD0;
	mov		eoscr, a;	//External OSCillator Register
						// bit-0:	1=Enable XTAL Smith trigger strong mode
						//			0=Disable XTAL Smith trigger strong mode
						// bit-1:	1=Enable XTAL Smith trigger
						//			0=Disable XTAL Smith trigger
						// bit4-2:	Option of driving strength in crystal oscillator
						// bit6-5:	00=External RC oscillator
						//			01=32KHz crystal oscillator
						//			10=4Mhz crystal oscillator
						//			11=20MHz crystal oscillator
						// bit7:	1=Enable external RC oscillator or crystal oscillator
						//			0=Disable external RC oscillator or crystal oscillator
	delay	0xFF;		// internal 32KHz need delay 30m/S
	delay	0xFF;		// internal 32KHz need delay 30m/S
	delay	0xFF;		// internal 32KHz need delay 30m/S
	delay	0xFF;		// internal 32KHz need delay 30m/S
	delay	0xFF;		// internal 32KHz need delay 30m/S
	delay	0xFF;		// internal 32KHz need delay 30m/S
						// external 20MHz need delay 1m/S
	//--						
	mov		a, 0xA4;	// select External 4MHz Crystal Clock!
	mov		clkmd, a; 	// Internal Low RC, Watch Dog disable,
						// bit-0:	Reset Function
						// bit-1:	1=Enable Watch Dog (default)
						//			0=Disable Watch Dog
						// bit-2:	1=Enable Internal Low RC (default)
						//			0=Disable Internal Low RC
						// bit-3:	No Used
						// bit-4:	1=Enable Internal High RC (default)
						//			0=Disable Internal High RC 
						// bit-7~5:	000=internal high RC/4
						//			001=internal high RC/2
						//			010=internal high RC
						//			011=external OSC/4
						//			100=external OSC/2
						//			101=external OSC
						//			110=internal low RC/4
						//			111=internal low RC (default)
//------Low clock switch to High clock End-----------------------------------
	delay	0x40 ;		//
	// Stack Pointer Setting for Processor-0
	mov		a, 0xD0 ;
	mov		sp, a ;	
	//---	
	//-- Clear Internal RAM ---	
	mov		a, 0x7f;
	mov		lb@RAMindex, a;	
	mov		a, 0x00;
	mov		hb@RAMindex, a;
ClearRAMLoop:
	wdreset;
	idxm	RAMindex, a;
	dzsn	lb@RAMindex;	
	goto	ClearRAMLoop;	 		
	//--- initial the I/O Pin
	//---- ALL of PORT A assign as Output port, for debug using!
	//---Assign PA.1 is Infra-Red Input
	mov	a, 0x1e;		// 
	mov	pac, a ;		// PA output,beside the PA.1 
	mov	a, 0xff ;
	mov	pa, a ;
	//---- ALL of PORT B assign as Output port
	mov	a, 0xfd ;		// pb.1:IR input, 
	mov	pbc, a ;		// PB output, beside PB.0 is input(SDI), 
	mov	a, 0x00 ;		// assign PB port initial status, PB.1 is Tx
	mov	pb, a ;			// 
	//---- ALL of PORT C assign as Output port, for debug using!
	mov	a, 0xcb ;		// pc.4:Rx1, pc.5:Rx0, pc.2:Key SW2,
	mov	pcc, a ;		// 
	mov	a, 0xf4 ;		// pc.3/pc.1/pc.0 default are low for servo Motor control
	mov	pc, a ;
	//---- ALL of PORT D assign as Motor Control and PS2 
	mov	a, 0xff ;		// 
	mov	pdc, a ;		// PD output, all LEDs off
	mov	a, 0x00 ;
	mov	pd, a ;
	//---- ALL of PORT E assign as LCM Nibble Bus 
	mov	a, 0xff ;		// Low Nibble as Motor Control High Nibble as PS2 input
	mov	pec, a ;		// PD output, all LEDs off
	mov	a, 0x09 ;
	mov	pe, a ;
	
	//--
	//---- ALL of PORT D assign as Output port, for debug using!
	//---- PORT D assign as Output port, exception PD.0
	//----PD.0: IR input, PD.1: R/W, PD.2: En, PD3: RS
	//----PD.4~PD.7: Data 0~3 (Processor #2)
//	mov	a, 0xfe ;		// PD.0 reserved for InfraRed input(Processor #3)
//	mov	pdc, a ;		// PD output, all LEDs off
//	mov	a, 0x00 ;
//	mov	pd, a ;	
	//Each Processor(MCU) Enable/Disable and Operational mode selection
	//---- Select the resource share between of MCUs
	pmode	0x02;		// Use MCU0 and MCU1 as prime function demonstrations
						//Mode:	MCU0 MCU1 MCU2 MCU3 MCU4 MCU5 MCU6 MCU7 Bandwidth sharing
						//  0	 /2   /8   /16  /16  /16  /16  /16  /16 
						//  1    /4   /4   /8   /8   /16  /16  /16  /16
						//  2    /8   /8   /8   /8   /8   /8   /8   /8
						//  3    /2   /8   /8   /8   /8    X    X    X
						//  4    /4   /4   /4   /8   /8    X    X    X
						//  5    /4   /4   /4   /4	  X	   X	X	 X	
						//  6    /16  /2   /8   /16  /16  /16  /16  /16 
						//  7    /8   /2   /8   /8   /8	   X	X	 X	
	mov		a, Tx0Bset;	// adjument the I/O delay clock for match required Baudrate
	mov		Tx0Baud, a;	// 
	//--
	mov		a, Tx1Bset;	// adjument the I/O delay clock for match required Baudrate
	mov		Tx1Baud, a;	// 
	//--
	clear	UARTCt;		// initail UART Control flag
	clear	UARTSt;		// initail UART Status flag
	//		
	//---	
Show_WelcomString:	
	mov		a, la@ASCIITab ;		// ASCII String table 
	mov		lb@TxStrPt, a ;
	mov		a, ha@ASCIITab ;
	mov		hb@TxStrPt, a ;
	//
	//-- TX Code Bank Strings--
	ldtabl  TxStrPt ;		// read character from String Table 
TxNextByteDataLoop:
	mov		GR0, a;
	mov		Tx0Buf, a ;
	call	Tx0putc;
	mov		a, GR0;
	mov		Tx1Buf, a ;
	call	Tx1putc;
	inc		lb@TxStrPt;
	ldtabl  TxStrPt ;
	ceqsn   a, 0 ;		// End of String table ?
	goto	TxNextByteDataLoop ;
	//--- 
	call	Tx0Printf_LFCR;		// 
	call	Tx1Printf_LFCR;		// 
	// enable another Processors
	mov		a, 0x03;
	mov		fppen, a;		// enable processor 1
	//----	Add other application code for Processor 0
	//*************************************************************
	//------ Processor-0 Program routine  ------------------
	//*************************************************************
	//	Processor Demo is handle the LED sequencer Flasher 
	//  the LED Sequence is based on the definition of Table !
	//---- Processor 1 Running in 500KHz ----
	//--
//int		LED_PWMBase;
	mov		a, 0x80;
	mov		LED_Rpwm, a;		// LED R PWM
	mov		LED_Gpwm, a;		// LED G PWM
	mov 	LED_Bpwm, a;		// LED B PWM
fpp0MainLoop:	
	clear	LED_PWMBase;
	//---PWM Control
LEDPWM_BeginLoop:	
	set1	pd.7;		// debug
	//-- R Segment --
	set1	LEDr;		// LED R PWM
	set1	LEDg;		// LED G PWM
	set1	LEDb;		// LED B PWM
	mov		a, LED_PWMBase;
LEDPWM_CheckLoop:	
	ceqsn	a, LED_Rpwm;
	goto	GreenPWMCheck;
	// R LED Match --
	set0	LEDr;
GreenPWMCheck:
	ceqsn	a, LED_Gpwm;
	goto	BluePWMCheck;
	// G LED Match --
	set0	LEDg;
BluePWMCheck:
	ceqsn	a, LED_Bpwm;
	goto	AllPWMChecked;
	// B LED Match --
	set0	LEDb;
AllPWMChecked:
	delay	0x1A;
	inc		LED_PWMBase;
	mov		a, LED_PWMBase;
	ceqsn	a, 0x00;

⌨️ 快捷键说明

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