Menu

Hardware I2C with Pics that use PPS

Help
viscomjim
2016-09-06
2016-09-06
  • viscomjim

    viscomjim - 2016-09-06

    In another post Evan showed some code to set the PPS for HI2C...

    UNLOCKPPS   ' GCB COMMAND
    RXPPS=0x0D        'Pin RB5 source is an input for RX
    RB7PPS=0x14       'Pin RB7 source is TX/CK
    
     RB4PPS = 0x11     'RB4->MSSP:SDA
     RB6PPS = 0x10     'RB6->MSSP:SCL
     SSPDATPPS = 0x0C  'RB4->MSSP:SDA
     SSPCLKPPS = 0x0E  'RB6->MSSP:SCL
     LOCKPPS   ' GCB COMMAND
    

    Quick question about pps as in your example above...

    I see where you are setting the RX and TX on the uart to pins RB5 and RB7. That seems to make sense. However on setting the SDA and SCL you use two different commands for each. Could you be so kind as to explain why the first two commands don't do the whole job?

    RB4PPS = 0x11     'RB4->MSSP:SDA
    RB6PPS = 0x10     'RB6->MSSP:SCL
    

    Why is this also needed?

    SSPDATPPS = 0x0C  'RB4->MSSP:SDA
    SSPCLKPPS = 0x0E  'RB6->MSSP:SCL
    

    Just trying to learn. The PPS thing is pretty cool on the newer pics, but this would have been a gotcha for me. I probably would have only done the first two and wondered why this didn't work.
    Any help is greatly appreciated.

     
  • Chris Roper

    Chris Roper - 2016-09-06

    And in that other post, befor I saw Evans request, I wrote:

    That is becouse the SDA and SCL pins are bidirectional, well the SDA always is and the SCL if the PIC is a Slave Vs Master, but it costs nothing to always define both pins as both Input and Output.
    To see a realy clever use of PPS look at C:\GCB@Syn\GreatCowBasic\Demos\Vendor Boards\Xpress Evaluation Board\11 Using PWM to control LED brightness.gcb
    it contains:

      UNLOCKPPS
          RA3PPS = 0x000E;   'RA3->PWM6:PWM6OUT;
          RA1PPS = 0x000E;   'RA1->PWM6:PWM6OUT;
          RA2PPS = 0x000E;   'RA2->PWM6:PWM6OUT;
          RA0PPS = 0x000E;   'RA0->PWM6:PWM6OUT;
      LOCKPPS
    

    Which allows one PWM output to drive all 4 LED's simultaniously.

    Cheers
    Chris

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.