Subversion Repositories ROM Emulator

Rev

Blame | Last modification | View Log | Download | RSS feed


; configuration bits PIC18F4420 clocked at 40MHz
; internal oscillator & RA6 = digital port
    CONFIG      OSC = ECIO6  
    CONFIG      FCMEN = OFF
    CONFIG      IESO = OFF
    CONFIG      PWRT = OFF
    CONFIG      BOREN = ON, BORV = 3
    CONFIG      WDT = OFF
    CONFIG      MCLRE = ON
    CONFIG      PBADEN = OFF
    CONFIG      LVP = OFF 
    CONFIG      CCP2MX = PORTC
    CONFIG      LPT1OSC = OFF
    CONFIG      STVREN = ON
    CONFIG      XINST = OFF

; timer's                                       
TMR0P8          EQU     B'00000010'     ; TMR0 stop, prescaler = 8, 16 bit

; TMR0 count in ms with prescaler = 4 at 40MHz (period 0.8us)
; max. count = 52ms
#define CNTTMR0(count)          (0x10000 - ((count * D'1250'))) 

TMR0P256        EQU     B'00000111'     ; TMR0 stop, prescaler = 256, 16 bit
                                        ; period = 25,6us @ 40Mhz, max. 1678ms
; TMR0 count in ms with prescaler = 256 at 40MHz (period 25.6us)
; max. count = 1678ms
#define CNTMSTMR0(count)        (0x10000 - ((count * D'1250')) / D'32') 

T20MS           EQU     CNTTMR0(D'20')  ; counter 20ms (prescaler = 8)                                  
T256MS          EQU     CNTMSTMR0(D'256') ; counter 256ms (prescaler = 256)
T1670MS         EQU     CNTMSTMR0(D'1670') ; counter 1670ms (prescaler = 256)

; equates
; host connect command (6 bytes sequence)
HOST_CONNECT1   EQU     0x87
HOST_CONNECT2   EQU     0xE9
HOST_CONNECT3   EQU     0x5D
HOST_CONNECT4   EQU     0x93
HOST_CONNECT5   EQU     0xB7
HOST_CONNECT6   EQU     0x57

; upload from host command (4 bytes: code followed by page & bank count)
HOST_UPLOAD1    EQU     0x99
HOST_UPLOAD2    EQU     0x51

; download to host command (4 bytes: code followed by page & bank count)
HOST_DOWNLOAD1  EQU     0x7D
HOST_DOWNLOAD2  EQU     0x3B

; positive response
DEV_ACK         EQU     0xAA
; negative response
DEV_NACK        EQU     0x55

;---- MACRO's ---------------------------------------------------------------
ldw     macro   f               ; load W (affect N,Z flags)
        movf    f, w
        endm

ldwb    macro   f               ; load W banked (affect N,Z flags)
        movf    f, w, BANKED
        endm

;---- ram variables ---------------------------------------------------------                                   
ramvars         udata_acs       0x000
mscnt           res             2       ; ms counter for timer 0
ndelay          res             2       ; delay counter
pagecnt         res             1       ; count of pages
bankcnt         res             1       ; count of banks
pagecnt2        res             1       ; count of pages
bankcnt2        res             1       ; count of banks
madl            res             1       ; page address
madh            res             1       ; memory high address 
umdat0          res             1       ; first byte received
umdat1          res             1       ; 2nd byte received
umrx            res             1       ; flag recieved byte
extvcc          res             1       ; external vcc detected
;memext         res             1       ; extern memory buffer & access enabled
loaded          res             1       ; memory loaded
conn            res             1       ; connected flag