There's a bit more to it when using the ivt.bas module.
Try this... I modified the example to include your code.
It compiles, but it's completely untested, so if it doesn't' work let me know and I'll dig up some hardware.
Code: Select all
// xvISRRX test
device = 18F16Q41
clock = 64
// config settings
#if (_device = 18F16Q40) or (_device = 18F16Q41)
config
FEXTOSC = OFF, // Oscillator not enabled
RSTOSC = HFINTOSC_64MHZ,// HFINTOSC with HFFRQ = 64 MHz and CDIV = 1:1
CLKOUTEN = OFF, // CLKOUT function is disabled
PR1WAY = OFF, // PRLOCKED bit can be set and cleared repeatedly
CSWEN = ON, // Writing to NOSC and NDIV is allowed
FCMEN = OFF, // Fail-Safe Clock Monitor disabled
FCMENP = OFF, // Fail-Safe Clock Monitor disabled
FCMENS = OFF, // Fail-Safe Clock Monitor Disabled
MCLRE = EXTMCLR, // If LVP=0, MCLR pin is MCLR; If LVP=1, RE3 pin function is MCLR
PWRTS = PWRT_OFF, // PWRT is disabled
MVECEN = OFF, // Interrupt contoller does not use vector table to prioritze interrupts
IVT1WAY = OFF, // IVTLOCKED bit can be cleared and set repeatedly
LPBOREN = OFF, // Low-Power BOR disabled
BOREN = SBORDIS, // Brown-out Reset enabled , SBOREN bit is ignored
BORV = VBOR_1P9, // Brown-out Reset Voltage (VBOR) set to 1.9V
ZCD = OFF, // ZCD module is disabled. ZCD can be enabled by setting the ZCDSEN bit of ZCDCON
PPS1WAY = OFF, // PPSLOCKED bit can be set and cleared repeatedly (subject to the unlock sequence)
STVREN = ON, // Stack full/underflow will cause Reset
LVP = OFF, // Low voltage programming disabled
XINST = OFF, // Extended Instruction Set and Indexed Addressing Mode disabled
WDTCPS = WDTCPS_31, // Divider ratio 1:65536; software control of WDTPS
WDTE = SWDTEN, // WDT enabled/disabled by SWDTEN bit
WDTCWS = WDTCWS_7, // window always open (100%); software control; keyed access not required
WDTCCS = SC, // Software Control
BBSIZE = BBSIZE_512,// Boot Block size is 512 words
BBEN = OFF, // Boot block disabled
SAFEN = OFF, // SAF disabled
DEBUG = OFF, // Background Debugger disabled
WRTB = OFF, // Boot Block not Write protected
WRTC = OFF, // Configuration registers not Write protected
WRTD = OFF, // Data EEPROM not Write protected
WRTSAF = OFF, // SAF not Write Protected
WRTAPP = OFF, // Application Block not write protected
CP = OFF // PFM and Data EEPROM code protection disabled
#endif
include "intosc.bas"
#option DIGITALIO_INIT = true // automatically call SetAllDigital at startup
include "setdigitalio.bas"
include "pps.bas"
include "ivt.bas"
//
// If you are using a device with PPS mapped pins then set the #options
// 'USARTx_TX' and 'USARTx_RX' to match the port pins you're using before
// including the USARTx.bas module... you'll still have to setup the PPS
// NOTE: if the pins have analog capability it is up to the user to set
// the respective pins to digital IO mode (ie setalldigital)
//
#option USART_RX = PORTB.5
#option USART_TX = PORTB.7
include "USART.bas"
#option RX_BUFFER_SIZE = 128
#option RX_PRIORITY = 1 // high-priority (default)
include "xvISRRX.bas"
const
CR = 13,
LF = 10
dim rxc as byte
// on RX data event, replace period with underscore...
event OnData()
// ignore CR and LF...
if (ISRRX.DataByte = CR) or (ISRRX.DataByte = LF) then
ISRRX.ProcessByte = false
// replace period with space character...
elseif (ISRRX.DataChar = ".") then
ISRRX.DataChar = "_"
endif
end event
// assign uart pps pins (Q41)
sub assign_usart_pps()
pps.unlock()
pps.assign_output(RB7PPS, PPS_UART1_TX) // PORTB.7
pps.assign_input(U1RXPPS, PPS_PORTB, 5) // PORTB.5
end sub
//----------------------------------------------------------------------------
// main program entry begins here
//----------------------------------------------------------------------------
main:
output(PORTA.2)
low(PORTA.2)
assign_usart_pps()
// init interrupt controller
// set vector table to use ivt_table (see below)
SET_IVTBASE(ivt_table)
// set baudrate
SetBaudrate(br9600)
ISRRX.Initialize(OnData)
USART.write(CR, LF, "START TEST ISR", CR, LF)
// enable high-priority interrupts
ENABLE_INTERRUPT()
// loop forever...
while true
// wait and gather up incoming chars... simulates being busy
// max chars depend on the size of the input buffer and speed
delayms(500)
toggle(PORTA.2)
// report an error...
if ISRRX.Overrun() then
USART.WriteByte(byte("*"))
endif
// read data from the buffer and output...
while ISRRX.DataAvailable()
rxc = ISRRX.ReadByte()
USART.WriteByte(rxc)
end while
end while
//----------------------------------------------------------------------------
// IVT table initialization
//----------------------------------------------------------------------------
// create the primary IVT and add interrupt handlers to the table
// (IRQ_ISRRX and ISRRXIsr are defined in xvISRRX.bas)
CREATE_IVT(ivt_table)
SET_IVT_HANDLER(IRQ_ISRRX, ISRRXIsr)
END_IVT()
//----------------------------------------------------------------------------
// end IVT table
//----------------------------------------------------------------------------