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

📄 linmac.lst

📁 基于philips的932单片机的LIN总线程序开发
💻 LST
📖 第 1 页 / 共 5 页
字号:
MACRO ASSEMBLER LINMAC                                      05/21/02 11:28:48 PAGE     1


WIN32 MACRO ASSEMBLER MA51 V06.04.07OBJECT MODULE PLACED IN F:\DATEN\PROJEKTE\LIN\NEW CONCEPT\MAC\LPC9XX\LINMAC.OBJ
ASSEMBLER INVOKED BY: MA51.EXE F:\DATEN\PROJEKTE\LIN\NEW CONCEPT\MAC\LPC9XX\LINMAC.A51 OJ("F:\DATEN\PROJEKTE\LIN\NEW CONCEPT\MAC\LPC9XX\LINMAC.OBJ") PIN("D:\PRIVATE\PROGRAMME\RIDE\INC") EP LINES SYNTAX(ASM51) PR("F:\DATEN\PROJEKTE\LIN\NEW CONCEPT\MAC\LPC9XX\LINMAC.LST") XR DB POSTOPT PW(80) RB(0) 

LOC     OBJ           LINE    SOURCE
                         1     NAME LINMAC
                         2     
                         3     ;###########################################################################
                         4     ;# LinMac																						#
                         5     ;# Medium Access Control Layer of the Lin bus										#
                         6     ;# Written for the LPC932 using the fractional baudrategenerator and       #
                         7     ;# the break detection.																		#
                         8     ;#																									#
                         9     ;# Used Recources:																			#
                        10     ;# -10Byte Data																				#
                        11     ;# -Registerbank 3																			#
                        12     ;# -Bit addressable RAM Byte 21H, 22H, 23H											#
                        13     ;# -UART with fractional Baudrategenerator											#
                        14     ;# -Timer0																						#
                        15     ;# -optional Timer1 or external Interrupt1											#
                        16     ;#																									#
                        17     ;# Dipl.-Ing. Lutz Pape																		#
                        18     ;# Applications																				#
                        19     ;# Microcontroller Business Line															#
                        20     ;# Philips Semiconductors Hamburg														#
                        21     ;# 04/05/2002																					#
                        22     ;#																									#
                        23     ;# Revision History:																			#
                        24     ;# Current Version: 1.90																	#
                        25     ;# V1.0 	: Version for the LPC1 as presented on the Embedded Systems 2002  #
                        26     ;# V1.90 : implementing new structure with protocol layers						#
                        27     ;###########################################################################
                        28     
                        29     
                        30     $INCLUDE (REGISTER.INC) ; CPU Special Function Registers
                       310     $INCLUDE (LINMAC.INC)   ; Modul includefile
                       346     $INCLUDE (LINMAC.CFG)   ; Modul configuration
                       356     
                       357     ;############################################################################
                       358     ;## Declarations and Definitions                                            #
                       359     ;############################################################################
                       360     
                       361     
                       362     ;SEGMENT DEFINITIONS
                       363     SLINDATA			SEGMENT DATA  ; various Variables for the protocol
                       364     SLINMAC			SEGMENT CODE  ; the code (ISRs and Initroutine)
                       365     
                       366     EXTERN CODE LINMACEVENT ; call-back function
                       367     
                       368     ; Initialisation routine
                       369     PUBLIC INITLINMAC 
                       370     ; public data Bytes
                       371     PUBLIC LINFRAMELENGTH, LINID, LINDATA, LINERROR, LINSTATE
                       372     ; public State-Flags
                       373     PUBLIC LINBREAK, LINSYNCED, LINIDRECEIVED, LINRXDATA, LINTXDATA, LINDATARDY, LINFRAMERDY, LINSLEEPS
                       374     ;public Error-Flags
                       375     PUBLIC LINPARITYERROR, LINVALIDATIONERROR, LINCHECKSUMERROR, LINWAKEEVENT
                       376     
                       377     
                       378     ;Datasegment declaration
------                 379     RSEG SLINDATA
                       380     ;public bytes
0000                   381     LINFRAMELENGTH:  		DS 1
0001                   382     LINID: 					DS 1
0002                   383     LINDATA: 					DS 8
                       384     
------                 385     DSEG AT 18H ; the local Bytes for ISR are stored in Registerbank 3
                       386     ;local bytes
0018                   387     _MISCREG0: 				DS 1  ; R0
0019                   388     _MISCREG1: 				DS 1  ; R1
001A                   389     _MISCREG2: 				DS 1  ; R2
001B                   390     _LINLASTSENT: 			DS 1  ; R3
001C                   391     _SYNCEDGECOUNT: 		DS 1  ; R4
001D                   392     _LASTBYTESENT: 			DS 1  ; R5
001E                   393     _BYTELEFT: 				DS 1  ; R6
001F                   394     _LINCRC: 					DS 1  ; R7
                       395     
------                 396     DSEG AT 21H
0021                   397     LINSTATE:  DS 1
0022                   398     LINERROR:  DS 1
0023                   399     _PARITY:   DS 1
                       400     
                       401     ;State Flags
  0008                 402     LINBREAK				BIT LINSTATE.0  ; '1' when Break was detected
  0009                 403     LINSYNCED			BIT LINSTATE.1  ; '1' when Syncseq was evaluated
  000A                 404     LINIDRECEIVED		BIT LINSTATE.2  ; '1' when LinID was received and checked
  000B                 405     LINRXDATA			BIT LINSTATE.3  ; '1' when Data is coming in
  000C                 406     LINTXDATA			BIT LINSTATE.4  ; '1' when Data is transmitting
  000D                 407     LINDATARDY			BIT LINSTATE.5  ; '1' when all Data has been received
  000E                 408     LINFRAMERDY			BIT LINSTATE.6  ; '1' when CRC was received and checked
  000F                 409     LINSLEEPS			BIT LINSTATE.7  ; '1' when the bus sleeps
                       410     
                       411     ;Error Flags
  0010                 412     LINPARITYERROR			BIT LINERROR.0 ; '1' when a Parityerror was detected 
  0011                 413     LINVALIDATIONERROR   BIT LINERROR.1 ; '1' when a Validationerror was detected
  0012                 414     LINCHECKSUMERROR		BIT LINERROR.2 ; '1' when a Checksumerror was detected
  0013                 415     LINFRAMEERROR			BIT LINERROR.3 ; '1' when a Frame Error was detected
  0014                 416     LINPROTOCOLERROR     BIT LINERROR.4 ; '1' when an Error in the Protocolsequence was detected
  0015                 417     UARTFRAMINGERROR		BIT LINERROR.5 ; '1' when the UART detected a Framing Error
  0016                 418     LINWAKEEVENT   		BIT LINERROR.6 ; '1' when a Wakeup-Event occured in Sleepmode
                       419     
                       420     ;ParityFlags
  001E                 421     CALCPAR0	 BIT _PARITY.6
  001F                 422     CALCPAR1  BIT _PARITY.7
                       423     
                       424     ;##################################################################################
                       425     ;#Start of Program                                                                #
                       426     ;##################################################################################
                       427     ;#		Interrupt Vectors																				 #
                       428     ;##################################################################################
                       429     
                       430     ;** UART Rx interrupt **
------                 431     CSEG AT 23H 
0023    020000   F     432     LJMP INTUARTRX
                       433     
                       434     ;** UART Tx interrupt **
------                 435     CSEG AT 6BH
006B    020000   F     436     LJMP INTUARTTX
                       437     
                       438     ;** Timer1 Interrupt, only when Timer1 is used as Syncseq-Edge-Counter **
                       439     $IF (_HW_SYNC_COUNTER) 
------                 440     CSEG AT 1BH
001B    020000   F     441     LJMP INTTIMER1
                       442     $ENDIF
                       443     
                       444     ;** external Int1 Interrupt, only when external Int1 is used as Syncseq-Edge-Counter **
                       445     $IF (_SW_SYNC_COUNTER)
                               CSEG AT 13H
                               LJMP INTEXT1
                               $ENDIF
                       449     
                       450     ;####################################################################################
                       451     ;#  Program Code																							#
                       452     ;####################################################################################		
------                 453     RSEG SLINMAC
                       454     
                       455     ;#############################################################################
                       456     ;# UART Rx-routine								                                   #
                       457     ;#############################################################################
                       458     INTUARTRX: 
0000    C0D0           459     						PUSH PSW
0002    C0E0           460     						PUSH ACC
0004    C2AC           461     						CLR ESR
                       462     						
0006    43D018         463     						ORL	PSW,#18H;	; use Registerbank 3
                       464     			; first test, if the bus is in Sleepmode
0009    300F20         465     						JNB	LINSLEEPS,_NORMALACTIVITY
                       466     ;*********************************************************************************** 						
                       467     ; test wakeup-frame
                       468     ;***********************************************************************************
000C    E599           469     						MOV 	A,SBUF
000E    6008           470     						JZ		_WAKEEVENT ; '0' received
0010    C3             471     						CLR  	C
0011    33             472     						RLC 	A
0012    500C           473     						JNC   _NOWAKEEVENT ; MSB was '0'-> can't be a wakeup-character
0014    547F           474     						ANL   A,#7FH       ; clear MSB
0016    7008           475     						JNZ	_NOWAKEEVENT ; if, except MSB, any '1' in the char, it can't be the wakeup-char
                       476     _WAKEEVENT: 	
0018    D216           477     						SETB	LINWAKEEVENT
                       478     ;###############################################################
                       479     ;# Return from Interrupt functions										#              	
                       480     ;#which can be called to return from the Interrupt routine.    #
                       481     ;#Course of the LJMPs this is 2-clock cycles slower than the   #
                       482     ;#'normal' procedure but saves several bytes of code.          #
                       483     ;#These functions are only valid for the ISR of UART Rx.       #
                       484     ;###############################################################
                       485     _ERRORRETURN:  ;a return when an Error raised
001A    752100         486     						MOV LINSTATE,#0
                       487     _EVENTRETURN:  ;a return with the LCALL to LinMacEvent
001D    120000   F     488     						LCALL LINMACEVENT
                       489     _NOWAKEEVENT: 
                       490     _RXRETI: 		  ;a return without LCALL to LinMacEvent		
0020    53BAF1         491     						ANL SSTAT,#0F1H ; reset the SSTAT register
0023    D0E0           492     						POP ACC
0025    D0D0           493     						POP PSW
0027    C298           494     						CLR RI
0029    D2AC           495     						SETB ESR
002B    32             496     						RETI
                       497     						
                       498     ;*********************************************************************************						
                       499     _NORMALACTIVITY: 
                       500     ;*********************************************************************************
                       501     ; test on Breakevent

⌨️ 快捷键说明

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