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

    PBP3_PPS_NOTES.txt:

    THIS FILE HAS BEEN UPDATED FOR PBP 3.1.1

    Devices with full Peripheral Pin Select (PPS) may be manipulated with the
    DEFINEs listed below. Default values shown may be subject to change due to
    Microchip pre-defined values. If in doubt, use the DEFINES to override defaults.


    --------------------------------------------------------------------------------

    Default output pins if no DEFINE is used:

    Pins: 8 14/16 20 28/40/48 64
    CCP1 RA2 RC5 RC5 RC2 RC2
    CCP2 RA5 RC3 RC3 RC1 RC1
    CCP3 RA2 RA2 RB5 RC3
    CCP4 RC1 RA4 RB0 RG3

    RX1 RA1 RC5 RB5 RC7 RC7
    TX1 RA0 RC4 RB7 RC6 RC6
    RX2 RC1 RC1 RB5* RG2
    TX2 RC2 RC2 RB4* RG1

    * RX2/TX2 defaults changed for some devices in PBP 3.1.1 to avoid ICSP lockout.

    Note that on some devices, any pin that is assigned to a CCP channel
    may not function as normal I/O. If a pin's CCP default inhibits a
    desired function, you can cancel the default as described below.

    --------------------------------------------------------------------------------
    HPWM

    Use the following PBP DEFINE statements to specify the output pins for HPWM.
    Check the Microchip datasheet (Peripheral Pin Select PPS) for the pins allowed
    on each CCP channel. The PPS peripheral will automatically be configured
    for the specified output pin upon execution of HPWM. When used on devices
    without PPS, these defines will only control the Data Direction SFRs (TRIS).

    These defines set PPS SFRs only once at program initialization. You may
    change the PWM output pin at any point in your program code by modifying
    the PPS SFRs. The HPWM command may be used without these DEFINEs if you
    manually configure the PPS and TRIS SFRs.

    As noted below, you may use DEFINE CCPx_REG 0 to inhibit PPS inititalization
    and automatic TRIS settings for any channel. You should do this if you plan
    to relocate pins with PPS settings at run-time to avoid erroneous TRIS settings.


    DEFINE CCP1_REG PORTC 'Channel-1 port
    DEFINE CCP1_BIT 2 'Channel-1 bit
    DEFINE CCP2_REG PORTC 'Channel-2 port
    DEFINE CCP2_BIT 1 'Channel-2 bit
    DEFINE CCP3_REG PORTC 'Channel-3 port
    DEFINE CCP3_BIT 3 'Channel-3 bit
    DEFINE CCP4_REG PORTG 'Channel-4 port
    DEFINE CCP4_BIT 3 'Channel-4 bit
    DEFINE CCP5_REG PORTG 'Channel-5 port
    DEFINE CCP5_BIT 4 'Channel-5 bit
    DEFINE CCP6_REG PORTE 'Channel-6 port
    DEFINE CCP6_BIT 6 'Channel-6 bit
    DEFINE CCP7_REG PORTE 'Channel-7 port
    DEFINE CCP7_BIT 7 'Channel-7 bit

    DEFAULT CCP PINS SET FOR UNUSED HPWM CHANNELS! If CCP_REG DEFINEs are set
    for unused channels, either explicitly or by default, the ports/pins specified
    as CCP/PWM outputs may not function as normal I/O until the PPS SRFs are cleared
    in your program code. To remove a default setting, define the CCPx_REG as 0,
    for example:

    DEFINE CCP1_REG PORTC 'Channel-1 port
    DEFINE CCP1_BIT 2 'Channel-1 bit
    DEFINE CCP2_REG 0 'Channel-2 UNUSED
    DEFINE CCP2_BIT 0 'Channel-2 bit
    DEFINE CCP3_REG 0 'Channel-3 UNUSED
    DEFINE CCP3_BIT 0 'Channel-3 bit
    DEFINE CCP4_REG 0 'Channel-4 UNUSED
    DEFINE CCP4_BIT 0 'Channel-4 bit


    --------------------------------------------------------------------------------
    HSEROUT/HSEROUT2

    Use the following PBP DEFINE statements to specify the output pins for HSEROUT
    and HSEROUT2. Check the Microchip datasheet (Peripheral Pin Select PPS) for the
    pins allowed on each EUSART. The PPS peripheral will automatically be configured
    for the specified RX/TX pins only once after reset or power up. This allows the
    PPS SFRs to be changed at runtime to relocate the RX/TX pins as needed. These
    defines will have no effect on devices without PPS.

    DEFINE HSER_RXREG PORTC
    DEFINE HSER_RXBIT 7
    DEFINE HSER_TXREG PORTC
    DEFINE HSER_TXBIT 6
    DEFINE HSER2_RXREG PORTB
    DEFINE HSER2_RXBIT 5
    DEFINE HSER2_TXREG PORTB
    DEFINE HSER2_TXBIT 4

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


    Did you find this post helpful? Yes | No

    Default Re: PPS understanding on 16F15313

    looking at PBP3_PPS_NOTES for ccp i see no mention of seting ccp inputs at all, its outputs

    reassigning ccpx inputs will be a manual effort

    the dt_ints-14 will not work in standard form , all the ccp ints are in pie/r 6

    i would just insert a new int to the file

    Code:
      #define CCP1_INT     PIR1,CCP1IF, PIE1,CCP1IE    ;-- CCP1 
      #define CCP2_INT     PIR2,CCP2IF, PIE2,CCP2IE    ;-- CCP2 
      #define CCP3_INT     PIR3,CCP3IF, PIE3,CCP3IE    ;-- CCP3                *
      #define CCP4_INT     PIR3,CCP4IF, PIE3,CCP4IE    ;-- CCP4                *
      #define CCP5_INT     PIR3,CCP5IF, PIE3,CCP5IE    ;-- CCP5                *
      #define CCP1_15313_INT     PIR6,CCP1IF, PIE6,CCP1IE    ;-- CCP1 
    
    Warning I'm not a teacher

  3. #3
    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

  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

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

  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

    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

  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

    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

  7. #7
    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

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