• AVR Freaks

Hot!SPI PPS mapping

Author
GunkutA
Junior Member
  • Total Posts : 107
  • Reward points : 0
  • Joined: 2019/01/10 00:09:38
  • Location: 0
  • Status: offline
2019/04/17 23:42:39 (permalink)
0

SPI PPS mapping

Hello I need to communicate with a Dual DAC by using SPI. DAC: MAX5223. ( I could not share datasheet. Site gave me error)
I use PIC 18F26K83. I will only transmit data to the DAC, I will not receive anything. This is how I made the connections between my PIC and DAC( see the image attached). So my question is related to PPS mapping and pin configurations:
Do I need to map my pins as inputs also? This is how I did the PPS mapping but I m not really sure:
I used RxyPPS register (Page: 267) in order to set my pins as output sources by using table 17-2 (Page:268)
 
RC7PPS= 0b00011111 ; //DIN, RC7 = SDIPPS
RC6PPS= 0b00100000; //CS, RC6= SSPPS
RC5PPS= 0b00011110; //SCLK, RC5=SCKPPS

 
So I believe this is enough for setting them as output. Do I also need to set them as inputs? If yes how do I do that? I think I need to use xxxPPS register (Page:265) by using table 17-1 (Page:266). But I don't know how to use it. Do I do something like this:
 
RC7PPS= 0b00010100 ; //DIN, RC7 = SDIPPS
RC6PPS= 0b00000101; //CS, RC6= SSPPS
RC5PPS= 0b00010011; //SCLK, RC5=SCKPPS

 
I know it does not make sense but I m confused about using RxxxPPS register. 
 
 
 
 
 
#1

3 Replies Related Threads

    pcbbc
    Super Member
    • Total Posts : 926
    • Reward points : 0
    • Joined: 2014/03/27 07:04:41
    • Location: 0
    • Status: offline
    Re: SPI PPS mapping 2019/04/18 03:28:46 (permalink)
    +2 (2)
    GunkutAThis is how I made the connections between my PIC and DAC( see the image attached).
    You forgot to attach anything.
     
    Do I need to map my pins as inputs also?
    Input pins are different from output pins. See:
    17.1 PPS Inputs
    17.2 PPS Outputs
    17.3 Bidirectional Pins
    PPS selections for peripherals with bidirectional signals on a single pin must be made so that the PPS input and PPS output select the same pin.

     
    RC7PPS= 0b00011111 ; //DIN, RC7 = SDIPPS
    //Pin RC7 is configured as output SPI1 (SDO)

    RC6PPS= 0b00100000; //CS, RC6= SSPPS
    //Pin RC6 is configured as output SPI1 (SS)

    RC5PPS= 0b00011110; //SCLK, RC5=SCKPPS
    //Pin RC5 is configured as output SPI1 (SCK)
     
    So I believe this is enough for setting them as output. Do I also need to set them as inputs? If yes how do I do that? I think I need to use xxxPPS register (Page:265) by using table 17-1 (Page:266). But I don't know how to use it. Do I do something like this:
    No, inputs are defined by the following registers:
     
    SPI1 Clock SPI1SCKPPS
    SPI1 Data SPI1SDIPPS
    SPI1 Slave Select SPI1SSPPS
     
    The values you need to set for these registers are given in 17.8 Register Definitions: PPS Input Selection
    bit 7-6 Unimplemented: Read as ‘0’
    bit 5-3 xxxPPS<5:3>: Peripheral xxx Input PORTx Pin Selection bits

    101 = Reserved
    100 = Reserved
    011 = Reserved
    010 = PORTC
    001 = PORTB
    000 = PORTA
    bit 2-0xxxPPS<2:0>: Peripheral xxx Input PORTx Pin Selection bits
    111 = Peripheral input is from PORTx Pin 7 (Rx7)
    110 = Peripheral input is from PORTx Pin 6 (Rx6)
    101 = Peripheral input is from PORTx Pin 5 (Rx5)
    100 = Peripheral input is from PORTx Pin 4 (Rx4)
    011 = Peripheral input is from PORTx Pin 3 (Rx3)
    010 = Peripheral input is from PORTx Pin 2 (Rx2)
    001 = Peripheral input is from PORTx Pin 1 (Rx1)
    000 = Peripheral input is from PORTx Pin 0 (Rx0)
     
    Inputs and outputs are configured differently.  You need to remember any one pin can only be mapped to a single OUTPUT function (or you'd have a conflict).  But one pin can drive multiple input singnals, no problem at all.
    Therefore: outputs are mapped by pin via RxxPPS
    And: inputs are mapped by function via pinfuncPPS register
    #2
    rodims
    Super Member
    • Total Posts : 1478
    • Reward points : 0
    • Joined: 2009/02/10 11:08:59
    • Location: 51.9627, 7.6262
    • Status: offline
    Re: SPI PPS mapping 2019/04/18 03:50:35 (permalink)
    +1 (1)
    I will only transmit data to the DAC, I will not receive anything.

    Your MAX DAC does not have any SPI output, so there is nothing to connect to your PIC SDI input.
    https://datasheets.maximi....com/en/ds/MAX5223.pdf
    Also I assume you will use SPI as master.  In general you have to control the CS line of your SPI device separately.
    For future projects, if you want to read digital input with your PIC, you also must care about the ANSEL register settings (here ANSELC).  Chapter 16.3.3. "Analog Control"  in your manual.
    post edited by rodims - 2019/04/18 03:52:58
    #3
    GunkutA
    Junior Member
    • Total Posts : 107
    • Reward points : 0
    • Joined: 2019/01/10 00:09:38
    • Location: 0
    • Status: offline
    Re: SPI PPS mapping 2019/04/18 23:00:34 (permalink)
    0
    Thanks pcbbc for the detailed explanation. So this PPS settings should be enough because I only need to set them as outputs:
    RC7PPS= 0b00011111 ; //DIN, RC7 = SDIPPS
    RC6PPS= 0b00100000; //CS, RC6= SSPPS
    RC5PPS= 0b00011110; //SCLK, RC5=SCKPPS
    post edited by GunkutA - 2019/04/18 23:06:55
    #4
    Jump to:
    © 2019 APG vNext Commercial Version 4.5