DT_INTS and 18F26k22


Closed Thread
Results 1 to 15 of 15

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default Re: DT_INTS and 18F26k22

    this works for me

    Code:
    #CONFIG
      CONFIG  FOSC = INTIO67
      CONFIG  PLLCFG = OFF
      CONFIG  PRICLKEN = OFF
      CONFIG  FCMEN = OFF
      CONFIG  IESO = OFF
      CONFIG  PWRTEN = OFF
      CONFIG  BOREN = SBORDIS
      CONFIG  BORV = 190
      CONFIG  WDTEN = ON
      CONFIG  WDTPS = 32768
      CONFIG  CCP2MX = PORTC1
      CONFIG  PBADEN = OFF
      CONFIG  CCP3MX = PORTB5
      CONFIG  HFOFST = ON
      CONFIG  T3CMX = PORTC0
      CONFIG  P2BMX = PORTB5
      CONFIG  MCLRE = EXTMCLR
      CONFIG  STVREN = ON
      CONFIG  LVP = OFF
      CONFIG  XINST = OFF
      CONFIG  DEBUG = OFF
      CONFIG  CP0 = OFF
      CONFIG  CP1 = OFF
      CONFIG  CP2 = OFF
      CONFIG  CP3 = OFF
      CONFIG  CPB = OFF
      CONFIG  CPD = OFF
      CONFIG  WRT0 = OFF
      CONFIG  WRT1 = OFF
      CONFIG  WRT2 = OFF
      CONFIG  WRT3 = OFF
      CONFIG  WRTC = OFF
      CONFIG  WRTB = OFF
      CONFIG  WRTD = OFF
      CONFIG  EBTR0 = OFF
      CONFIG  EBTR1 = OFF
      CONFIG  EBTR2 = OFF
      CONFIG  EBTR3 = OFF
      CONFIG  EBTRB = OFF
    #ENDCONFIG
      
      
            ;INCLUDE "modedefs.bas"
            ;INCLUDE"ALLDIGITAL.pbp"
            ;INCLUDE "HomeAutomationVars.bas"  'Open with PBP editor
            INCLUDE "DT_INTS-18.bas"     ; Base Interrupt System
            INCLUDE "ReEnterPBP-18.bas"     ; Include if using PBP interrupts
    
        define OSC 8
        
        
        DEFINE DEBUG_REG PORTB  
        DEFINE DEBUG_BIT 7
        DEFINE DEBUG_BAUD 9600 
        ' Set Debug mode: 0 = true, 1 = inverted
        DEFINE DEBUG_MODE 0
        x var word
        rxflag   var bit
        rxchar var byte
    ASM
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
     INT_Handler    RX1_INT ,    _read_serial,   PBP,  no
     endm
     INT_CREATE             ; Creates the interrupt processor
    ENDASM 
    OSCCON = $60   ;  OSC 8
    anselc = 0
    RCSTA  = $90   ' Enable serial port & continuous receive
    TXSTA  = $20   ' Enable transmit, BRGH = 0
    SPBRG  = 51    ' 9600 Baud @ 8MHz, 0.16%
    SPBRGH = 0
    BAUDCON.3 = 1  ' Enable 16 bit baudrate generator
    baudcon1= baudcon1&%11001111  ;invert tx/rx polarity   for usb-tty adapter
    TRISB.7 = 0  ;DEBUG
    LATB.7  = 1  ;DEBUG
    
       
    @   INT_ENABLE   RX1_INT     ; enable external (RX) interrupts    
    debug "running",13,10      
    Main:
        debug "."    
        for x = 1 to 1000
          if rxflag then
             Debug 13,10,"got !! asc chr ",#rxchar,13,10
             rxflag=0
          endif 
          pauseus 1000
        next x 
         
    Goto main   
        
        
    read_serial:
        rxflag = 1
        rxchar = rc1reg  
    @   INT_RETURN

    this is much better , get rid of all those nasty pauses and goto's


    Code:
     ;pic18f26k22 rx1 int demo
    #CONFIG
      CONFIG  FOSC = INTIO67
      CONFIG  PLLCFG = OFF
      CONFIG  PRICLKEN = OFF
      CONFIG  FCMEN = OFF
      CONFIG  IESO = OFF
      CONFIG  PWRTEN = OFF
      CONFIG  BOREN = SBORDIS
      CONFIG  BORV = 190
      CONFIG  WDTEN = ON
      CONFIG  WDTPS = 32768
      CONFIG  CCP2MX = PORTC1
      CONFIG  PBADEN = OFF
      CONFIG  CCP3MX = PORTB5
      CONFIG  HFOFST = ON
      CONFIG  T3CMX = PORTC0
      CONFIG  P2BMX = PORTB5
      CONFIG  MCLRE = EXTMCLR
      CONFIG  STVREN = ON
      CONFIG  LVP = OFF
      CONFIG  XINST = OFF
      CONFIG  DEBUG = OFF
      CONFIG  CP0 = OFF
      CONFIG  CP1 = OFF
      CONFIG  CP2 = OFF
      CONFIG  CP3 = OFF
      CONFIG  CPB = OFF
      CONFIG  CPD = OFF
      CONFIG  WRT0 = OFF
      CONFIG  WRT1 = OFF
      CONFIG  WRT2 = OFF
      CONFIG  WRT3 = OFF
      CONFIG  WRTC = OFF
      CONFIG  WRTB = OFF
      CONFIG  WRTD = OFF
      CONFIG  EBTR0 = OFF
      CONFIG  EBTR1 = OFF
      CONFIG  EBTR2 = OFF
      CONFIG  EBTR3 = OFF
      CONFIG  EBTRB = OFF
    #ENDCONFIG
      
      
    INCLUDE "DT_INTS-18.bas"     ; 
    
    define OSC 8
    DEFINE DEBUG_REG PORTB  
    DEFINE DEBUG_BIT 7
    DEFINE DEBUG_BAUD 9600 
    DEFINE DEBUG_MODE 0
    x         var  byte bank0
    flag      var  byte bank0
    rxflag    var flag.7
    dotflag   var flag.0 
    rxchar    var byte
    ASM
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
     INT_Handler    RX1_INT  , _read_serial,asm,no
     INT_Handler    TMR1_INT , _TOCK,asm,no
     endm
     INT_CREATE             ; Creates the interrupt processor
    ENDASM  
    clear  
    OSCCON = $60   ;  OSC 8
    anselc = 0
    RCSTA  = $90   ' Enable serial port & continuous receive
    TXSTA  = $20   ' Enable transmit, BRGH = 0
    SPBRG  = 51    ' 9600 Baud @ 8MHz, 0.16%
    SPBRGH = 0
    BAUDCON.3 = 1  ' Enable 16 bit baudrate generator
    T1CON=1         ;32mS tick
    TRISB.7 = 0  ;DEBUG
    LATB.7  = 1  ;DEBUG
    baudcon1= baudcon1&%11001111  ;invert tx/rx polarity   for usb-tty adapter
    pause 2000    ;give me time to setup debug
    @   INT_ENABLE   RX1_INT     ; enable external (RX) interrupts    
    debug 13,10 ,"listening "
    @ INT_ENABLE  TMR1_INT
    x=31
    while 1
        if rxflag then
             ;Debug 13,10,"got asc chr ",#rxchar,13,10
             tx1reg = rxchar     ;echo back
             rxflag = 0
        endif 
        if dotflag then
            debug "."                                   
            dotflag=0
        endif 
    wend 
    end    
    read_serial:
    ASM
        bsf _flag ,7
        MOVE?BB RC1REG,_rxchar    
        INT_RETURN    
    ENDASM
    TOCK:
    asm
        DECFSZ  _x,F    
        BRA BREXIT
        movlw 31    
        bsf _flag ,0 
        movwf _x         
    BREXIT 
        BCF PIR1 ,0 
        INT_RETURN 
    ENDASM
    Warning I'm not a teacher

  2. #2
    Join Date
    Jul 2009
    Location
    Ohio, USA
    Posts
    57


    Did you find this post helpful? Yes | No

    Default Re: DT_INTS and 18F26k22

    Bingo!

    Thanks Richard, this line
    Code:
    anselc = 0 '0 = Digital input buffer enabled
    did it!


    Mike

Similar Threads

  1. DT_Ints w/18F26K22 stop if incorrect baud rate
    By Dave in forum mel PIC BASIC Pro
    Replies: 21
    Last Post: - 8th September 2017, 13:54
  2. PROBLEM ICD 18F26K22 no work
    By FRAN200 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 4th July 2016, 12:55
  3. 18F26K22 slow startup
    By Tobias in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 7th January 2014, 22:10
  4. Compiling for 18F26K22 - Does anyone have a solution for me?
    By Balachandar in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 28th August 2012, 12:49
  5. Anyone found a Bootloader for 18F26K22?
    By Dave in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 11th August 2011, 18:23

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

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