Menu

xpress board gpio

Help
2018-05-09
2018-05-10
  • stan cartwright

    stan cartwright - 2018-05-09

    Using pps tools what is a default port data dir in out called?
    I set up pins for spi mosi and sck but want to reset pins to standard ports. What in the pps input output lists is a data port?

     

    Last edit: stan cartwright 2018-05-09
  • Anobium

    Anobium - 2018-05-09

    Demos are a great place to start.

    See .. \GCB@Syn\GreatCowBasic\Demos\Vendor Boards\Xpress Evaluation Board\20 Temperature Sensor_Alarms to Serial Terminal.gcb This will show you Serial and I2C.

     'Xpress board
      Sub InitPPS
        UNLOCKPPS
            RC0PPS = 0x0010       'RC0->EUSART:TX;
            RXPPS  = 0x0011       'RC1->EUSART:RX;
    
            RC3PPS = 0x0017       'RC3->MSSP2:SDA2;
            SSP2DATPPS = 0x0013   'RC3->MSSP2:SDA2;
            SSP2CLKPPS = 0x0014   'RC4->MSSP2:SCL2;
            RC4PPS = 0x0016       'RC4->MSSP2:SCL2;
          LOCKPPS
      End sub
    

    But, as you are using a PPS part you can choose any port and PPS Tool will create the routine for you.

    For SPI. A quick search of the demos.

    ..\GCB@Syn\GreatCowBasic\Demos\GLCD Solutions\GLCD Simple Demonstration Solutions\GLCD_Simple_Demonstration_SPI_16F18855_for_ILI9486L@32.gcb

    Sub InitPPS
    
        SSP1DATPPS = 0x0C;   //RB4->MSSP1:SDI1;
        RB5PPS = 0x15;   //RB5->MSSP1:SDO1;
        RB3PPS = 0x14;   //RB3->MSSP1:SCK1;
    
    
    End Sub
    

    But, as you are using a PPS part you can choose any port and PPS Tool will create the routine for you.

    And, you can create you own routine that has Serial, SPI and I2C all defined.

     
  • stan cartwright

    stan cartwright - 2018-05-09

    I used similar from pps tool to set up other pins then this to set up other pins so pins are defined twice with same names cos I don't know what spi cs and dc are. If just in out, what is that called in pps tool in out lists please?

        #startup InitPPS, 85
        Sub InitPPS
                'Module: MSSP1
                RB5PPS = 0x0015    'SDO1 > RB5
                RB3PPS = 0x0014    'SCK1 > RB3
                SSP1CLKPPS = 0x000B    'RB3 > SCK1 (bi-directional)
        End Sub
    
     
    • Chris Roper

      Chris Roper - 2018-05-09

      Some pins need to be bi-directional to work such as Clock lines, shared data lines etc.
      You dont have to woryy if the line should be bi-directional or not.
      PPS takes care of it for you and will make both entrys if needed.

      SPI has different names on diferent devices and what is confusing you here is that you are used to the Arduino names. The link I posted bellow will talk you through srtting up SPI.

      in addition to that:
      CS is Chip Select, also known as SS or Slave Select.
      You only need that if you are using the PIC SPI in Slave rather than Master mode.
      I dont know what you mean by DC though.

      Follow the tutorial in the post below and then ask here if you have more questions.

       
  • Chris Roper

    Chris Roper - 2018-05-09

    If I am reading you correctly you are asking how to set a pin as normal I/O.

    With PPS you don't have to, all pins are generic I/O pins and addressed as normal

    i.e.
    Dir PortB.3 Out
    Dir PortC.2 In
    Etc.

    If you want to use a pin as something other than standard I/O you use PPS to allocate the pin to a Perephiral as Evan has done above.

    I did write a short tutorial on PPS here that may help:
    https://sourceforge.net/p/gcbasic/discussion/projects%26guides/thread/3fa399ca/?limit=25#0d45

    Cheers
    Chris

     
  • stan cartwright

    stan cartwright - 2018-05-09

    Chris-I have set pins as clk and mosi. I want to reset them as gpio. What is that called in the pps tools in out lists please.
    How come everyone else knows this info?
    Snippets are great to copy but don't explain the pps tool.
    I do want to use predefined templates I did myself. Cheers.

     

    Last edit: stan cartwright 2018-05-09
    • Chris Roper

      Chris Roper - 2018-05-09

      If you don't want them to be CLK and MOSI then don't allocate them.

      PPS is not intended to be changed on the fly, it should be allocated during initialisation only.
      With that is mind I am not aware of any PPS command to deallocate a pin.
      You could probably do It manually by clearing the appropriate bits of the appropriate registers.
      You will have to have a very thorough understanding of the Datasheet and PPS in order to try that and not break anything.

      I do not recommend it.

      As for defined templates nothing in PPS is predefined.
      You are looking at examples not templates.

      Read the Tutorial, use the PPS tool and create any combination of devices you wish.
      You do not need to copy and paste from the examples.

      Cheers
      Chris

       

      Last edit: Chris Roper 2018-05-09
  • stan cartwright

    stan cartwright - 2018-05-09

    Is it the pins aren't permanent after power off and go back to as new and they're set at run time?

     
    • Chris Roper

      Chris Roper - 2018-05-09

      Yes.

      PPS is just a set of registers that control a set of Multiplexers that in turn connect the external pins to the internal Peripherals. When power is lost so are the PPS settings.

      That is why PPS must go at the top of your program and is an integral part of the initialisation of the Device along with setting the clock speed and the configuration bits.

       
  • stan cartwright

    stan cartwright - 2018-05-09

    Anobium-demos don't show what the options in pps tools in out mean and the data sheet doesn't match up much--image 1st post.
    I've set pin as clk with pps and copied/pasted into my code then flashed.
    I erased the pps code and used different pin as clk then copied/pasted into my code then flashed. Do I now have 2 pins the same as the pin set 1st time has not been set second time to anything else like gpio?

     
    • Anobium

      Anobium - 2018-05-09

      You must have read Chris's PPS tuturial very quickly.

      Do I now have 2 pins the same as the pin set 1st time has not been set second time to anything else like gpio?
      I have no idea what you are saying.

      See this post - https://sourceforge.net/p/gcbasic/discussion/579126/thread/e43c9ad9/#aed5 It does say what to do.

       
  • stan cartwright

    stan cartwright - 2018-05-09

    PPS is just a set of registers that control a set of Multiplexers that in turn connect the external pins to the internal Peripherals. When power is lost so are the PPS settings.
    OK, I thought it was like eeprom or ula, ie permanent unless reprogrammed. Sorted.
    As I'm testing RC5 this ili9341 doesn't work. Flashes ok.
    Just sdo and sck were sorted with pps tool.
    wiring ok. Connected display to uno,works. Retried xpress didn't.
    Is it dc and/or cs ports cause problem?

    #chip 16f18855,32
    #option Explicit
    #include <glcd.h>
        #startup InitPPS, 85
        Sub InitPPS
                RB5PPS = 0x0015    'SDO1 > RB5
                RB3PPS = 0x0014    'SCK1 > RB3
                SSP1CLKPPS = 0x000B    'RB3 > SCK1 (bi-directional)
        End Sub
    #define GLCD_TYPE GLCD_TYPE_ILI9341
    #define GLCD_DC portb.0
    #define GLCD_CS   portb.2
    #define GLCD_RESET   portc.2 ; Reset line Tie high..not needed
    #define GLCD_DO   portb.5 ; Data out | MOSI SDI
    #define GLCD_SCK   portb.3 ; Clock Line SCK
    #define ILI9341_HardwareSPI  
    #define GLCD_EXTENDEDFONTSET1
    GLCDfntDefaultsize = 1
    GLCDRotate (landscape)
    GLCDCLS ILI9341_BLUE
    GLCDPrint (0,0,"hello",ILI9341_WHITE)
    do
    loop
    
     
  • stan cartwright

    stan cartwright - 2018-05-10

    I changed sdo,do,dc,cs to port c and the display works. Dunno why.

     

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.