DT Ints on 18F (First time user problem)


+ Reply to Thread
Results 1 to 16 of 16
  1. #1

    Default DT Ints on 18F (First time user problem)

    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!
    ___________________
    WHY things get boring when they work just fine?

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    1,945

    Default Re: DT Ints on 18F (First time user problem)

    try without
    INCLUDE "ReEnterPBP-18LP.bas

    your not using a lp int anyway

  3. #3
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,371

    Default Re: DT Ints on 18F (First time user problem)

    Hi,
    There are two WHILE 1 statements but only one WEND:
    Code:
    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
    Although compiling your code as it was did NOT give the error message you show removing one of the WHILE 1 makes it compile without errors. Make sure you're compiling for the correct device.
    Finally, you generally don't want to have the reset flag option set to YES for the EUSART interrupt because the flag is cleared automatically by the hardware when the RX buffer is read.

    /Henrik.

  4. #4

    Default Re: DT Ints on 18F (First time user problem)

    Thanks. A few confirmations
    • Device is 18LF45K22 and it is compiled for the same device
    • Include 18LP file is commented
    • First while1 is commented in my file, must be a mistake while copying/pasting/editing
    Error is still there. Not sure if something needs changing in ReEnter file or DT_INT file?
    ___________________
    WHY things get boring when they work just fine?

  5. #5
    Join Date
    May 2013
    Location
    australia
    Posts
    1,945

    Default Re: DT Ints on 18F (First time user problem)

    I count two whiles but one wend

    Code:
    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

  6. #6

    Default Re: DT Ints on 18F (First time user problem)

    ;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
    Ignore the first While1 please.
    ___________________
    WHY things get boring when they work just fine?

  7. #7
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,371

    Default Re: DT Ints on 18F (First time user problem)

    As I said, commenting out any of the WHILE 1 statements makes it compile just fine for the 18LF45K22 at my end - with or without the ReEnterPBP-18LP.bas file included.
    What version of MPASM are you using? (I'm using 5.45)

    /Henrik.

  8. #8
    Join Date
    May 2013
    Location
    australia
    Posts
    1,945

    Default Re: DT Ints on 18F (First time user problem)

    not sure its a good practice to use hersin and hserout in an isr either
    b_c var word ; buffer count
    PIE3.5 I ASSUME IS RXINT ENABLE OR use
    @ INT_ENABLE RX1_INT


    GetData:

    mess[B_C]=RCREG
    if ( b_c > 499) OR ( MESS[B_C]=10) then
    bity=1
    PIE3.5=0 ; BUFFER FULL TAKE NO MORE or @ INT_DISABLE RX1_INT

    ENDIF
    B_C=B_C+1


    @ INT_RETURN


    PIE3.5=0 might be wrong the example I was drawing from uses two euarts
    Last edited by richard; - 24th March 2015 at 12:34. Reason: typo

  9. #9

    Default Re: DT Ints on 18F (First time user problem)

    I am using PBP3 with MPLAB v8.90.

    @Richard - Tried taking everything out of the ISR except Bity=1. Problem stays the same.
    ___________________
    WHY things get boring when they work just fine?

  10. #10
    Join Date
    May 2013
    Location
    australia
    Posts
    1,945

    Default Re: DT Ints on 18F (First time user problem)

    I concur with henrik it compiles for me with the bogus while removed

  11. #11

    Default Re: DT Ints on 18F (First time user problem)

    Would it be possible if one of you guys can upload your copy of DT INT and REEnter. I will try compiling with them. It compiles fine if I remove the Interrupts!
    ___________________
    WHY things get boring when they work just fine?

  12. #12
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,256

    Default Re: DT Ints on 18F (First time user problem)

    Yup, you want to keep the isr as short as possible; set only the flag.

    Then, back in main, check the flag, do the hser, then reset flag.

    Also, try adding a label to the main loop and a goto at the bottom.

    Robert

  13. #13

    Default Re: DT Ints on 18F (First time user problem)

    Thanks Demon, this is just a trial program and I wanted to set the PIC up properly before arranging the code nicely with labels etc.
    ___________________
    WHY things get boring when they work just fine?

  14. #14
    Join Date
    May 2013
    Location
    australia
    Posts
    1,945

    Default Re: DT Ints on 18F (First time user problem)

    I can't guarantee I have not fiddled with these but here they are
    Attached Files Attached Files
    Last edited by richard; - 24th March 2015 at 13:00. Reason: still can't tuype

  15. #15

    Default Re: DT Ints on 18F (First time user problem)

    Nops the same error still exists.
    BTW if its not too much to ask, can you also upload the compiled HEX file so I can get some results in the mean time someone helps to resolve the problem.
    ___________________
    WHY things get boring when they work just fine?

  16. #16
    Join Date
    May 2013
    Location
    australia
    Posts
    1,945

    Default Re: DT Ints on 18F (First time user problem)

    rename it back to . hex
    Attached Files Attached Files

Similar Threads

  1. User Position, Velocity & Time II (D1h)
    By dj.lambert in forum GPS
    Replies: 2
    Last Post: - 31st July 2009, 10:21
  2. Problem with Dt Ints Interrupts
    By Quin in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 18th July 2008, 20:21
  3. Some initial help for a first time PBP user
    By jtburnham in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 29th April 2006, 08:32
  4. First time with 18F pic...
    By gabrielg74 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 9th December 2005, 08:04
  5. need help first time user of picmicro
    By tekdavid in forum mel PIC BASIC
    Replies: 2
    Last Post: - 29th March 2005, 05:39

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts