Subversion Repositories ROM Emulator

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 service 1
 
2
; configuration bits PIC18F4420 clocked at 40MHz
3
; internal oscillator & RA6 = digital port
4
    CONFIG	OSC = ECIO6
5
    CONFIG	FCMEN = OFF
6
    CONFIG	IESO = OFF
7
    CONFIG	PWRT = OFF
8
    CONFIG	BOREN = ON, BORV = 3
9
    CONFIG	WDT = OFF
10
    CONFIG	MCLRE = ON
11
    CONFIG	PBADEN = OFF
12
    CONFIG	LVP = OFF
13
    CONFIG	CCP2MX = PORTC
14
    CONFIG	LPT1OSC = OFF
15
    CONFIG	STVREN = ON
16
    CONFIG	XINST = OFF
17
 
18
; timer's
19
TMR0P8		EQU	B'00000010'	; TMR0 stop, prescaler = 8, 16 bit
20
 
21
; TMR0 count in ms with prescaler = 4 at 40MHz (period 0.8us)
22
; max. count = 52ms
23
#define	CNTTMR0(count)		(0x10000 - ((count * D'1250')))
24
 
25
TMR0P256	EQU	B'00000111'	; TMR0 stop, prescaler = 256, 16 bit
26
					; period = 25,6us @ 40Mhz, max. 1678ms
27
; TMR0 count in ms with prescaler = 256 at 40MHz (period 25.6us)
28
; max. count = 1678ms
29
#define	CNTMSTMR0(count)	(0x10000 - ((count * D'1250')) / D'32')
30
 
31
T20MS		EQU	CNTTMR0(D'20')	; counter 20ms (prescaler = 8)
32
T256MS		EQU	CNTMSTMR0(D'256') ; counter 256ms (prescaler = 256)
33
T1670MS		EQU	CNTMSTMR0(D'1670') ; counter 1670ms (prescaler = 256)
34
 
35
; equates
36
; host connect command (6 bytes sequence)
37
HOST_CONNECT1	EQU	0x87
38
HOST_CONNECT2	EQU	0xE9
39
HOST_CONNECT3	EQU	0x5D
40
HOST_CONNECT4	EQU	0x93
41
HOST_CONNECT5	EQU	0xB7
42
HOST_CONNECT6	EQU	0x57
43
 
44
; upload from host command (4 bytes: code followed by page & bank count)
45
HOST_UPLOAD1	EQU	0x99
46
HOST_UPLOAD2	EQU	0x51
47
 
48
; download to host command (4 bytes: code followed by page & bank count)
49
HOST_DOWNLOAD1	EQU	0x7D
50
HOST_DOWNLOAD2	EQU	0x3B
51
 
52
; positive response
53
DEV_ACK		EQU	0xAA
54
; negative response
55
DEV_NACK	EQU	0x55
56
 
57
;---- MACRO's ---------------------------------------------------------------
58
ldw	macro	f               ; load W (affect N,Z flags)
59
	movf	f, w
60
	endm
61
 
62
ldwb	macro	f               ; load W banked (affect N,Z flags)
63
	movf	f, w, BANKED
64
	endm
65
 
66
;---- ram variables ---------------------------------------------------------
67
ramvars		udata_acs	0x000
68
mscnt		res		2	; ms counter for timer 0
69
ndelay		res		2	; delay counter
70
pagecnt		res		1	; count of pages
71
bankcnt		res		1	; count of banks
72
pagecnt2	res		1	; count of pages
73
bankcnt2	res		1	; count of banks
74
madl		res		1	; page address
75
madh		res		1	; memory high address
76
umdat0		res		1	; first byte received
77
umdat1		res		1	; 2nd byte received
78
umrx		res		1	; flag recieved byte
79
extvcc		res		1	; external vcc detected
80
;memext		res		1	; extern memory buffer & access enabled
81
loaded		res		1	; memory loaded
82
conn		res		1	; connected flag
83