;**********************************************************************
;                                                                     *
;    Filename:      p18f2420-2520-4420-4520.cfg                       *
;    Date:          13.03.2010                                        *
;    FF Version:    3.6                                               *
;    Copyright:     Mikael Nordman                                    *
;    Author:        Mikael Nordman                                    *
;                                                                     * 
;    Modified:                                                        *
;**********************************************************************
;    FlashForth is licensed acording to the GNU General Public License*
;**********************************************************************
;;; FlashForth processor specific configuration

; The config directive is used control the processor configuration bits
; See processor specific include file for details.


        config OSC = INTIO7 ; HS
        config FCMEN = OFF
        config IESO = OFF
        config PWRT = ON
        config BOREN = SBORDIS
        config WDT = ON
        config WDTPS = 256
        config MCLRE = ON
        config LPT1OSC = OFF
        config PBADEN = OFF
        config CCP2MX = PORTC
        config STVREN = ON
        config LVP = OFF
        config XINST = OFF
        config DEBUG = OFF
        config CP0 = ON
        config CPB = ON
        config WRTC = ON
        
;;;  Specify the clock frequency here, INTRC = 8 MHz
        constant clock=d'8000000'

;;; Calculate the program memory write delay
        constant clock_MHZ = clock / d'1000000'
        constant write_delay = (d'255' * clock_MHZ) / d'60'  

;;; Specify RS-232 The baud rate here
        constant baud=d'38400'
        constant spbrgval = ((clock/baud)/d'16') - 1

;;; Some constants controlling how writes to program flash is made.
;;; Check the Microchip errata documents for details.
        constant flash_write_outer_loop = d'2'
        constant flash_write_inner_loop = d'32'

;;; Start address of the user dictionary
;;; This should be aligned with the program memory protection bits
        constant dp_user_dictionary = h'2000'

;;; Constant for the MS word.
        constant   tmr2prescaler = d'4'
        constant   tmr2postscaler = d'16'
        constant   tmr2ms_val=(clock/d'4000'/tmr2prescaler/tmr2postscaler) 

        constant   tmr1prescaler = d'1'
        constant   tmr1ms_val_lo=(0 - clock/d'4000'/tmr1prescaler)&h'ff' 
        constant   tmr1ms_val_hi=((0 - clock/d'4000'/tmr1prescaler)>>8)&h'ff'


;;; Define which words you want to leave out from the core dictionary
;;; #define SKIP_DUMP
;;; #define SKIP_MULTITASKING

;;; Define SAFE_CHECK to enable writechecks on dictionary
;;; All words are protected except the last one.
;;; The border is where LATEST points, that is the NFA of the
;;; latest defined word.
#define SAFE_CHECK
;;; Define SAFE_CHECK1 to enable writechecks
;;; on system variables below h'f060'
#define SAFE_CHECK1


;;; Define which timer is stepping TICKS and MS. Only one can be uncommented.
;;; #define MS_TMR1
;;;  #define MS_TMR2
#define MS_TMR3

;;; Allow warm reset by ctrl-O
#define CTRL_O_WARM_RESET

;;; Define if 8-bit characters should be sent by TX1
;;; Use with HW flow control and without ctrl-O reset for 
;;; full binary character set.
;#define USE_8BIT_ASCII

;;;
;;; Flow control defintions ********************************

;;; Use SW flow control XON/XOFF as default
;;; Uncomment to use HW flow control
;#define FC_TYPE_HW

#ifdef FC_TYPE_HW
; Low latency UART in host or HW flow control 
;;; Define the RX1 fill level for CTS off
 constant RX1_OFF_FILL = d'32'

; Clear To Send to the computer, DB9 PIN 8
#define HW_FC_CTS_PORT LATC
#define HW_FC_CTS_TRIS TRISC
#define HW_FC_CTS_PIN  0

;;; Define if also RTS flow control should be included
;;; RTS lets the terminal control if FF is allowed to transmit data
; #define HW_FC_RTS ; Comment out to leave out RTS

; Request To Send from the computer, DB9 PIN 7.
#ifdef HW_FC_RTS
#define HW_FC_RTS_PORT PORTC
#define HW_FC_RTS_TRIS TRISC
#define HW_FC_RTS_PIN  1
#endif  ; HW_FC_RTS

#else   ;
#define FC_TYPE_SW
;;; Define the RX1 fill level for XOFF
;;; Mainly useful for SW flow control
;;; RX1 interrupt buffer size is 64 characters.

; High latency UART in host
; LINUX : setserial /dev/ttySx ^low_latency
        constant RX1_OFF_FILL = d'5'

; Low latency UART in host or HW flow control  
; LINUX : setserial /dev/ttySx low_latency
;       constant RX1_OFF_FILL = d'32'

#endif
