PPS understanding on 16F15313


Closed Thread
Results 1 to 15 of 15

Hybrid View

  1. #1
    Join Date
    Feb 2008
    Location
    Michigan, USA
    Posts
    231


    Did you find this post helpful? Yes | No

    Default Re: PPS understanding on 16F15313

    Richard,
    Thanks, I'll work on it again tonight and update as I sort it out.

    btw, thanks for taking up the torch around here. It probably seems tiring helping all the time, but it is appreciated.

    bo

  2. #2
    Join Date
    Feb 2008
    Location
    Michigan, USA
    Posts
    231


    Did you find this post helpful? Yes | No

    Default Re: PPS understanding on 16F15313

    Other than adding the define, is there anything else that needs to be addressed in DT_INTs to make it work?

  3. #3
    Join Date
    May 2013
    Location
    australia
    Posts
    2,644


    Did you find this post helpful? Yes | No

    Default Re: PPS understanding on 16F15313

    Other than adding the define, is there anything else that needs to be addressed in DT_INTs to make it work?
    other than
    Code:
    asm
    INT_LIST macro
          INT_Handler  CCP1_15313_INT,   _myisr,    PBP,  yes
          
          endm
          INT_CREATE
    
    
    ENDASM
    thats about all i recall . http://dt.picbasic.co.uk/ might have some detail i have missed
    Warning I'm not a teacher

  4. #4
    Join Date
    Feb 2008
    Location
    Michigan, USA
    Posts
    231


    Did you find this post helpful? Yes | No

    Default Re: PPS understanding on 16F15313

    I have been to http://http://dt.picbasic.co.uk/ a number of times to refresh myself, but I admit, I haven't mined it thoroughly. I went back and found a couple of nuggets. One was in "DT's other code examples" that gave a better explanation of IOC interrupts, the other was by mpgmike named http://dt.picbasic.co.uk/INT16/Customisation.

    I had found his explanation on the forums of the PIC18's, but couldn't quite sort it for the lesser PIC's.

    bo

  5. #5
    Join Date
    May 2013
    Location
    australia
    Posts
    2,644


    Did you find this post helpful? Yes | No

    Default Re: PPS understanding on 16F15313

    found his explanation on the forums of the PIC18's, but couldn't quite sort it for the lesser PIC's.
    i agree, its not very clear which "mods" apply to which dt-ints version
    a simple example adding 1 extra or modified dt-int to each version would be clearer
    adding a swag of int sources you will never use is an overkill for a pretty simple process

    you could use conditional asm constants to add a more generalised approach and standard notation
    like this
    ifdef PIR6
    #define CCP1_INT PIR6,CCP1IF, PIE6,CCP1IE ;-- CCP1
    #define CCP2_INT PIR6,CCP2IF, PIE6,CCP2IE ;-- CCP2
    else
    #define CCP1_INT PIR1,CCP1IF, PIE1,CCP1IE ;-- CCP1
    #define CCP2_INT PIR2,CCP2IF, PIE2,CCP2IE ;-- CCP2
    endif
    but who can be bothered to see if every pic16 chip with a PIR6 has a ccp1 + 2 and conforms to these settings.
    and what about new chips
    its just not worth the effort these days
    Warning I'm not a teacher

  6. #6
    Join Date
    Feb 2008
    Location
    Michigan, USA
    Posts
    231


    Did you find this post helpful? Yes | No

    Default Re: PPS understanding on 16F15313

    With your suggestions I was able to get it working. I will post the basics in case someone else needs to get through this. Having a better understanding of PPS will help a lot moving forward and allow me to take advantage of a lot of new features, some of which I didn't even know existed like an Angular Timer and a Math Accelerator with Proportional-Integral-Derivative (PID). Very interesting blocks to work with.

    bo

  7. #7
    Join Date
    Feb 2008
    Location
    Michigan, USA
    Posts
    231


    Did you find this post helpful? Yes | No

    Default Re: PPS understanding on 16F15313

    Here's what I finally worked out:

    Code:
    '*** DT_INTS_14.pbp changed and renamed DT_INTS_16F1xxx.pbp (AND put in the right folder!  ****************** 
    '*** bottom 2 lines apply to program below *******
    '...........
    ASM
    asm = 0
    Asm = 0
    ASM = 0
    pbp = 1
    Pbp = 1
    PBP = 1
    yes = 1
    Yes = 1
    YES = 1
    no  = 0
    No  = 0
    NO  = 0
    
    
      #define ALL_INT      	INTCON,GIE, INTCON,GIE      ;-- Global Interrupts   *
      #define T1GATE_INT   	PIR1,TMR1GIF, PIE1,TMR1GIE  ;-- Timer1 Gate         *
      #define INT_INT      	PIR0,INTF,  PIE0,INTE       ;-- External INT
        #define IOCA0_INT   IOCAF,IOCAF0, PIE0,IOCIE   ; RA0 IOC+           (MR)
        #define IOCA1_INT   IOCAF,IOCAF1, PIE0,IOCIE   ; RA1 IOC+           (MR)
        #define IOCA2_INT   IOCAF,IOCAF2, PIE0,IOCIE   ; RA2 IOC+           (MR)
        #define IOCA3_INT   IOCAF,IOCAF3, PIE0,IOCIE   ; RA3 IOC+           (MR)
        #define IOCA4_INT   IOCAF,IOCAF4, PIE0,IOCIE   ; RA4 IOC+           (MR)
        #define IOCA5_INT   IOCAF,IOCAF5, PIE0,IOCIE   ; RA5 IOC+           (MR)    
        #define IOCC0_INT   IOCCF,IOCCF0, PIE0,IOCIE   ; RC0 IOC+           (MR)
        #define IOCC1_INT   IOCCF,IOCCF1, PIE0,IOCIE   ; RC1 IOC+           (MR)
        #define IOCC2_INT   IOCCF,IOCCF2, PIE0,IOCIE   ; RC2 IOC+           (MR)
        #define IOCC3_INT   IOCCF,IOCCF3, PIE0,IOCIE   ; RC3 IOC+           (MR)
        #define IOCC4_INT   IOCCF,IOCCF4, PIE0,IOCIE   ; RC4 IOC+           (MR)
        #define IOCC5_INT   IOCCF,IOCCF5, PIE0,IOCIE   ; RC5 IOC+           (MR)
    
        #define CCP1_15313_INT PIR6,CCP1IF, PIE6, CCP1IE  ;                 (MR) 
        #define CCP2_15313_INT PIR6,CCP2IF, PIE6, CCP2IE  ;                 (MR)  
    '................



    Code:
    '****************************************
    '*  Name    : 16F15313 test-1.BAS                              
    '*  Author  :                                               
    '*  Notice  : Copyright (c) 2020    
    '*             : All Rights Reserved                              
    '*  Date    : 9/19/20                                             
    
    '* CCP1 used for Capture,  16F15313 has two            
    '*THIS REV:  WORKING                                            
    
    '                                    16F15313   
    '                        ---------------u-------------
    '                      -|vdd (+)                vss(-) |-         
    '       VSS out    -|RA5                 RA0/pgd |-  Pulse in *       
    '                      -|RA4                  RA1/pgc |-  Neut Out       
    '                      -|A3/Vpp/MCLR         RA2/ |-       
    '                         ----------------------------    
    '****************************************************************
    include "DT_INTS-16F1xxx.pbp"    ; Base Interrupt System. Ver 1.22 
    INCLUDE "ReEnterPBP.pbp"         ; Include for DT_INTS.  ver 3.4
    '*****************************************************************
    define OSC 8            ' tell the compiler that the OSC is 8MHz
    OSCEN = %01000000       ' HFINTOSC 
    OSCFRQ = %00000011      ' 8MHz
    '*********
    
    CCP1PPS = 0              ' assigns CCP1 Input to RA0;
    '*********
    PulseIN      var PORTA.0  ' 
    LED1        var PORTA.1  '  
    LED2         var PORTA.5  ' 
    PORTA   = %00001001      ' Outputs (except 0&3) = 0 on bootup
    TRISA = %00001001      ' Pins output(except 0&3)                                  
    ANSELA  = %00000000      ' Set all digital 
    ';----[High Priority Interrupts]----------------------------------------
    ASM
    INT_LIST  macro    ; IntSource,   Label,   Type, ResetFlag?
            INT_Handler  CCP1_15313_INT,   _Capture,  PBP, yes ;
        endm                     
            INT_CREATE               ; Creates the High Priority interrupt processor
            INT_ENABLE  CCP1_15313_INT
    ENDASM
    CCP1CON = %10000101    'capture mode, capture on rising edge
    
    Main:
    pause 1000
    GOTO Main
    '---[CCP1 - interrupt handler]------------------------------------------
    Capture:  ' Enter here with PulseIN (CCP1) 
        if CCP1CON = %10000101 then    ' If rising edge capture, then
            toggle LED1
            goto Over_CCP   ' Done, exit  
        endif
     if CCP1CON = %10000100 then   ' If falling edge capture, then
        toggle LED2
        CCP1CON = %10000101    ' switch back to rising edge
     endif
     Over_CCP    
    @ INT_RETURN
    END

Similar Threads

  1. PIC18F27J13 Peripheral Pin Select (PPS)
    By Aussie Barry in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 28th April 2015, 12:51
  2. DIV32 Understanding
    By enauman in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 19th January 2013, 20:44
  3. Help in Understanding the Math
    By Ramius in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 24th March 2012, 15:49
  4. So many option but little understanding
    By PickyBiker in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 23rd April 2010, 09:45
  5. Better understanding PULSIN
    By Wirecut in forum mel PIC BASIC
    Replies: 12
    Last Post: - 29th June 2008, 10:17

Members who have read this thread : 1

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

Tags for this Thread

Posting Permissions

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