Menu

New capability: LCD connectivity for SPI Serial Expander. LCD_IO = 14

Anobium
2023-08-17
2023-08-17
  • Anobium

    Anobium - 2023-08-17

    LCD connectivity for SPI Serial Expander

    Just added a new capability to the LCD library. LCD connectivity for SPI Serial Expander like the MCP23S17. Connectivity is simple using only three microcontroller ports ( you could use two and strap the SPI Chip Select [ LCD_SPI_CS] to ground).

    It is fast and just works.

    Configuration is amazing easy. As is all the LCD connectivity. As follows:

    //Constants - LCD connectivity type;controls whether to use HW SPI; The inter character delay
    #define LCD_IO 14
    #define LCD_HARDWARESPI
    
    'Pin mappings for LCD IO SPI Expander
    #define LCD_SPI_DO          portc.5
    #define LCD_SPI_SCK         portc.3
    #define LCD_SPI_CS          porta.2
    

    If you are using a PPS chip and you want to use the hardware SPI then you need to add PPS, something like this but this is specific to one type of chip and is shown as an example. I have added an IFDEF test to automatically support the use of software SPI.

    'PPS Tool version: 0.0.6.3
    // Generated for 18f67k40
    
    #startup InitPPS, 85
    #define PPSToolPart 18f67k40
    
    Sub InitPPS
    
            #ifdef LCD_HARDWARESPI
                SSP1CLKPPS = 0x13;   //RC3->MSSP1:SCK1;    
                RC3PPS = 0x19;   //RC3->MSSP1:SCK1;    
                RC5PPS = 0x1A;   //RC5->MSSP1:SDO1;    
                SSP1DATPPS = 0x14;   //RC4->MSSP1:SDI1;  
            #endif
    
        End Sub
    

    The connectivity is shown below: The microcontroller connections are as follows:

    RC3 > Expander SPI SCK ( clock)
    RC5 > Expander SPI SI (slave in)
    RA2 > Expander SPI CS ( chip select) - could be set to 0v0
    RB5 > Expander Reset ( optional)


    There are some options you can tweak. See the example setup below. You can play with the use of hardware or software SPI, SPI frequency ( HWSPIMODE MASTERFAST). LED speed, the connectivity between the expander and the LCD and otheroptions.

    //Constants - LCD connectivity type; controls whether to use HW SPI; The inter character delay
    #define LCD_IO 14
    #define LCD_HARDWARESPI
    #define LCD_SPEED FAST
    #define HWSPIMODE MASTERFAST
    //These are phyiscal connections from the expander to the LCD.  These are automatically set in the library and are shown here purely for clarity.
        #define     LCD_SPI_EXPD_ADDRESS        0x40     // address of the expander
        #define LCD_SPI_EXPANDER_E_ADDRESS      0x40     // GPA6 on the expander
        #define LCD_SPI_EXPANDER_RS_ADDRESS     0x80     // GPA7 on the expander   
    
    'Pin mappings for LCD IO SPI Expander
    #define LCD_SPI_DO          portc.5
    #define LCD_SPI_SCK         portc.3
    #define LCD_SPI_CS          porta.2
    // Optional(s) reset Port.Pin connection to expander, select one.
        // #define LCD_SPI_RESET_IN       portb.5
        #define LCD_SPI_RESET_OUT      portb.5
    

    Anyway, enjoy.

     

    Last edit: Anobium 2023-08-17
  • Anobium

    Anobium - 2023-08-17

    See https://gcbasic.sourceforge.io/help/_lcd_io_14.html for the Help on the new capability.

     

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.