I have the following code: (Using PIC18LF45K22)
Code:
Include "modedefs.bas"
INCLUDE "DT_INTS-18.bas"
INCLUDE "ReEnterPBP-18LP.bas"
INCLUDE "ReEnterPBP-18.bas"
DEFINE OSC 4
;----[Device Configuration]--(See manual section 4.9)---------------------------
#CONFIG
CONFIG FOSC = HSMP ; Internal oscillator block
CONFIG PLLCFG = OFF ; Oscillator used directly
CONFIG PRICLKEN = OFF ; Primary clock can be disabled by software
CONFIG FCMEN = OFF ; Fail-Safe Clock Monitor disabled
CONFIG IESO = ON ; Oscillator Switchover mode disabled
CONFIG PWRTEN = OFF ; Power up timer disabled
CONFIG BOREN =OFF ; Brown-out Reset DISabled
CONFIG BORV = 190 ; VBOR set to 1.90 V nominal
CONFIG WDTEN = OFF ; WDT is always enabled. SWDTEN bit has no effect
CONFIG WDTPS = 512 ; 1:512
CONFIG CCP2MX = PORTC1 ; CCP2 input/output is multiplexed with RC1
CONFIG PBADEN = OFF ; PORTB<5:0> pins are configured as digital I/O on Reset
CONFIG CCP3MX = PORTB5 ; P3A/CCP3 input/output is multiplexed with RB5
CONFIG HFOFST = ON ; HFINTOSC output and ready status are not delayed by the oscillator stable status
CONFIG T3CMX = PORTC0 ; T3CKI is on RC0
CONFIG P2BMX = PORTD2 ; P2B is on RD2
CONFIG MCLRE = EXTMCLR ; MCLR pin enabled, RE3 input pin disabled
CONFIG STVREN = OFF ; Stack full/underflow will cause Reset
CONFIG LVP = OFF ; Single-Supply ICSP disabled
CONFIG XINST = OFF ; Instruction set extension and Indexed Addressing mode disabled (Legacy mode)
CONFIG DEBUG = OFF ; Disabled
CONFIG CP0 = ON ; Block 0 (000800-001FFFh) not code-protected - all protected actually
CONFIG CP1 = ON ; Block 1 (002000-003FFFh) not code-protected
CONFIG CP2 = ON ; Block 2 (004000-005FFFh) not code-protected
CONFIG CP3 = ON ; Block 3 (006000-007FFFh) not code-protected
CONFIG CPB = ON ; Boot block (000000-0007FFh) not code-protected
CONFIG CPD = ON ; Data EEPROM not code-protected
CONFIG WRT0 = ON ; Block 0 (000800-001FFFh) not write-protected
CONFIG WRT1 = ON ; Block 1 (002000-003FFFh) not write-protected
CONFIG WRT2 = ON ; Block 2 (004000-005FFFh) not write-protected
CONFIG WRT3 = ON ; Block 3 (006000-007FFFh) not write-protected
CONFIG WRTC = ON ; Configuration registers (300000-3000FFh) not write-protected
CONFIG WRTB = ON ; Boot Block (000000-0007FFh) not write-protected
CONFIG WRTD = ON ; Data EEPROM not write-protected
CONFIG EBTR0 = ON ; Block 0 (000800-001FFFh) not protected from table reads executed in other blocks
CONFIG EBTR1 = ON ; Block 1 (002000-003FFFh) not protected from table reads executed in other blocks
CONFIG EBTR2 = ON ; Block 2 (004000-005FFFh) not protected from table reads executed in other blocks
CONFIG EBTR3 = ON ; Block 3 (006000-007FFFh) not protected from table reads executed in other blocks
CONFIG EBTRB = ON ; Boot Block (000000-0007FFh) not protected from table reads executed in other blocks
#ENDCONFIG
DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
DEFINE HSER_TXSTA 20h ' Enable transmit, BRGH = 0
DEFINE HSER_CLROERR 1 ' Clear overflow automatically
DEFINE HSER_BAUD 4800
DEFINE HSER_SPBRG 51 ' 4800 Baud @ SPBRGH = 0
BAUDCTL.3 = 1 ' Enable 16 bit baudrate generator
DEFINE HSER2_RCSTA 90h ' Enable serial port & continuous receive
DEFINE HSER2_TXSTA 20h ' Enable transmit, BRGH = 0
DEFINE HSER2_CLROERR 1 ' Clear overflow automatically
DEFINE HSER2_BAUD 4800
;DEFINE HSER2_SPBRG 51 ' 4800 Baud @ SPBRGH = 0
'SPECIAL FUNCTION REGISTER SETTINGS
' DISABLE SR LATCH
SRCON0=0
'-------------------------
' DISABLE COMPARATORS
CM1CON0.7=0
CM2CON0.7=0
'-------------------------
' DISABLE DAC MODULE
VREFCON1.7=0
' DISABLE FIXED VOLTAGE REFERENCE
VREFCON0.7=0
'-------------------------
'DISABLE CTMU MODULE
CTMUCONH=0
'-------------------------
'DISABLE ADC
ADCON0=0
'-------------------------
' DISABLE HIGH/LOW VOLTAGE DETECT MODULE
HLVDCON=0
'-------------------------
'-------------------------
' DISABLE TIMER 0/1/2/3/4/5
T0CON=0
T1CON=0
T2CON=0
T3CON=0
T4CON=0
T5CON=0
T6CON=0
'-------------------------
' INTERRUPT SETUP
RCON.7=0
INTB0 VAR INTCON.1
INTCON=0 '%00010000
INTCON2=%00000000
INTCON3=0
PIE1=0
PIE2=0
PIE3=0
PIE4=0
PIE5=0
LATA=%00000000
LATB=%00000000
LATC=%00001000
LATD=%00000000
LATE=%010
'PORTA initialises as ANALOG INPUTS except A4 - Keep then as it is to reduce power
TRISA=%11101111 : ANSELA=%11101011 ' Make all pins ANALOG input except RA2 (MODEM STAT PIN)
TRISB=%11111111 : ANSELB=%00111110
TRISC=%10100101 : ANSELC=%00100100
TRISD=%10100000 : ANSELD=%00011111 ' PORTD as test LED (RD6/7 ARE TX2/RX2)RD5 AS TEST INPUT
TRISE=%000 : ANSELE=%000' TRISE=%100 : ANSELE=%100 (KEEP E2 FOR TESTING
' PORT MAPPING TO NAMES
Pwr_Key Var LATE.1
COM VAR PORTE.2
' VARIABLES DECLARED HERE
COUNTER VAR BYTE
Counter2 var byte
MESS VAR BYTE[500]
Bity Var BIT
'VARIABLE INITIALISATION-------
Counter2=0
COUNTER=51
MESS=0
Bity=0
Pwr_Key=0 : PAUSE 2000 : Pwr_Key=1
PAUSE 10000
ASM
INT_LIST macro ; IntSource, Label, Type, ResetFlag?
INT_Handler RX1_INT, _GetData, PBP, yes
endm
INT_CREATE ; Creates the interrupt processor
ENDASM
@ INT_ENABLE RX1_INT ; enable external (INT) interrupts
WHILE 1
A: ' CHECK IF MODEM IS WORKING OK AND SET ECHO OFF
HSEROUT2 ["SENDING AT",13,10]
HSEROUT ["AT",13,10]
GoSub GetResponse
HSEROUT ["ATE0",13,10]
GoSub GetResponse
HSEROUT2 ["ATE0 RESULT=OK",STR MESS\500,13,10]
WHILE 1
HSEROUT2 ["SEND COMMAND",13,10]
HSERIN2 [STR MESS\500\13]
HSEROUT2 ["SENDING-",STR MESS,13,10]
HSEROUT [STR MESS,13,10]
GoSub GetResponse
WEND
GetResponse:
While Bity=0 : wend
Bity=0
Return
GetData:
Bity=1
HSERIN [STR MESS\500\10]
HSEROUT2 ["RESULT=",STR MESS,13,10]
@ INT_RETURN
What I am trying to achieve here is the response from the modem in the interrupt. I get the following errors when compiling:
Executing: "C:\Program Files (x86)\PBP3\PBPX.EXE" -ampasmwin -k# -p18LF45K22 "TRIAL2.BAS"
PICBASIC PRO(TM) Compiler 3.0.7.1, (c) 1998, 2013 microEngineering Labs, Inc.
All Rights Reserved.
Error[116] C:\USERS\PMARSTERS\DESKTOP\EES\TRIAL2\TRIAL2.ASM 846 : Address label duplicated or different in second pass (Z0003F)
Error[116] C:\USERS\PMARSTERS\DESKTOP\EES\TRIAL2\TRIAL2.ASM 909 : Address label duplicated or different in second pass (Z00040)
Error[116] C:\USERS\PMARSTERS\DESKTOP\EES\TRIAL2\TRIAL2.ASM 962 : Address label duplicated or different in second pass (Z00041)
Error[116] C:\USERS\PMARSTERS\DESKTOP\EES\TRIAL2\TRIAL2.ASM 993 : Address label duplicated or different in second pass (Z00042)
Halting build on first failure as requested.
BUILD FAILED: Tue Mar 24 10:18:40 2015
Help please!
Bookmarks