suggestion on how to implement duel /quad spi interface


Closed Thread
Results 1 to 8 of 8
  1. #1
    Join Date
    Feb 2012
    Location
    PERTH AUSTRALIA
    Posts
    838

    Default suggestion on how to implement duel /quad spi interface

    HI Guys , most new spi FLASH allow for dual / quad spi interface to the pic

    can any one advise how this might be done in PBP using the shiftin shiftout command ?

    i assuming if dual you would get a word return , quad you would get 4 bytes ???


    regards

    Sheldon


    http://www.winbond.com/NR/rdonlyres/...0/W25Q16BV.pdf

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


    Did you find this post helpful? Yes | No

    Default Re: suggestion on how to implement duel /quad spi interface

    in dual mode you get 2 bits for every spi clk pulse one bit on each 1/0 pin from the flash chip ,
    in quad mode its 4 bits on 4 pins , you would need to write your own spi routines for either method ,I think hardware spi is about a good as you gunna get. with a 16f1825 chip I can do 2mbs easy with hardware spi (32mhz clk and for small bursts of course)

  3. #3
    Join Date
    Feb 2012
    Location
    PERTH AUSTRALIA
    Posts
    838


    Did you find this post helpful? Yes | No

    Default Re: suggestion on how to implement duel /quad spi interface

    yes no mater what shiftin/shiftout will get in/ out 1-8 bits per command and i cant see how to make it shift out /in more than 1 data pin synchronously ???

  4. #4
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default Re: suggestion on how to implement duel /quad spi interface

    Hi Sheldon,
    You can't do that with SHIFTIN/SHIFTOUT (without modifying the underlaying ASM routines of course (don't do that)).
    You need to write the routines yourself, shouldn't be that hard to do I don't think. But, as Richard points out, using the MSSP module in SPI mode will probably give you equal (or better) performance compared to a bitbanged dual SPI setup.

    /Henrik.

  5. #5
    Join Date
    May 2013
    Location
    australia
    Posts
    2,389


    Did you find this post helpful? Yes | No

    Default Re: suggestion on how to implement duel /quad spi interface

    just to make things clear shiftin/shiftout will get in/ out 1-8 bits per command is just wrong .
    shiftin/shiftout can process however many bits you require for as many vars as specified in the command (even 32 bit longs) but always 1 bit at a time
    Last edited by richard; - 27th June 2014 at 08:28.

  6. #6
    Join Date
    Feb 2012
    Location
    PERTH AUSTRALIA
    Posts
    838


    Did you find this post helpful? Yes | No

    Default Re: suggestion on how to implement duel /quad spi interface

    did not know that shiftin out did more than 8 bit at a time , nice to know ,

    i ll take a look at the how it may be done with the MSSP , be nice feature to have running when i get the flash chips that have the duel/ quad interface .
    project on hand does not need it but future ones will

    the example code i have on hand that uses the MSSP is as follows , suggestions on how this maybe changed



    Code:
     
    ' --- Hardware SPI / SSP register variables ---------------------------
       SSPEN	Var	SSPCON1.5	' SSP enable
        WCOL	Var	SSPCON1.7	' SSP write collision
        BF		Var	SSPSTAT.0	' SSP buffer full
        SSPIF	Var	PIR1.3		' SSP interrupt flag
    
    
    SPI_init:
    
    	        SSPSTAT = %00000000	    ' Sample at middle of data output time, Mode 1, 1: Transmit on idle to active clock transition.
    		SSPCON1 = %00010000	    ' SPI master mode, clock = Fosc/64, Mode 1, 1: Clock idle high.
    		SSPEN = 1		            ' Enable hardware SPI port.
    
    return
    
    
    
    Readbyte:
    	       SDC_data_in = SSPBUF	            ' Clear the buffer.
    		SSPIF = 0		                    ' Clear the interrupt flag.
    		SSPBUF = $ff		                ' Shift out a dummy byte.
    		While !SSPIF		                ' Wait for receive byte.
    		Wend
    		SDC_data_in = SSPBUF	            ' Get the byte.
    
    return
    
    writebyte:
    
    	        SDC_data_in = SSPBUF	        ' Clear the buffer.
    		SSPIF = 0	         	        ' Clear the interrupt flag.
    		SSPBUF = SDC_data_out	' Send the byte.
    		If (WCOL) Then Return	        ' Check for write collision.
    		While !SSPIF		        ' Wait for send to complete.
    		Wend
    return

  7. #7
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default Re: suggestion on how to implement duel /quad spi interface

    Hi Sheldon,
    I'm not sure but I think there might be some confusion going on here.
    Neither SHIFTIN/SHIFTOUT nor the MSSP module will be able to handle dual or quad SPI interface - period.
    If you're going to do it you'll have to bitbang it yourself which, again, is probably slower than doing it "normaly" with the MSSP module.

    The thing with dual and quad SPI is that it's getting closer to a parallell bus. With dual SPI there are two datalines and with quad SPI there are four (instead of one) that get sampled on the active edge of the clock. SHIFTIN/SHIFTOUT doesn't support it and the MSSP module only have one data line input so it's impossible.

    /Henrik.

  8. #8
    Join Date
    Feb 2012
    Location
    PERTH AUSTRALIA
    Posts
    838


    Did you find this post helpful? Yes | No

    Default Re: suggestion on how to implement duel /quad spi interface

    thanks henrik, i did misunderstand that

Similar Threads

  1. 4-20mA using SPI Interface
    By gavo in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 10th April 2013, 19:51
  2. LTC2400 SPI interface
    By designer salwar in forum mel PIC BASIC
    Replies: 1
    Last Post: - 2nd March 2011, 21:50
  3. SPI interface
    By malc-c in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 9th January 2011, 01:06
  4. LTC2400 SPI interface
    By PUGALENTHI.P in forum mel PIC BASIC
    Replies: 26
    Last Post: - 23rd July 2010, 15:57
  5. Using PBPro for SPI Interface
    By twincitian in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 22nd March 2007, 07:57

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts