• AVR Freaks

Hot!SST26VF032B SPI driver for Harmony

Author
zugunruhe
New Member
  • Total Posts : 8
  • Reward points : 0
  • Joined: 2018/07/26 15:50:29
  • Location: 0
  • Status: offline
2018/07/27 05:14:05 (permalink)
0

SST26VF032B SPI driver for Harmony

I am using Harmony v2.06 and PIC32MX on a custom board with SST26VF032B flash memory. The SST26VF032B is designed to use SPI mode so I need the SPI driver for it NOT SQI !
The problem is when I read I read all FFs. It is either that my writes don't go through or my reads are not correct.
Here is what I have done so far:
- Using "sst25_fat" example (MPLAP Harmony examples) and change the SST25 code for SST26
- I have added unlock code to send Global Block Protection Unlock 98H. I can verify that the BPNV Block-Protection Volatility State is 1. I did also try to send block protection command 0x42 for all 10s instead of the global one. I think the chip comes up unlocked by default any ways so technically I shouldn't need to do any extra unlocking but I did it anyways to be in the safeside.
- I do use the same state machine as of SST25. So it sends Write-Enable command (06h) before each write. I also added the code to verify WPEN bit is set as expected...
I know there are some standalone SPI drivers for the SST26 devices here https://www.microchip.com/wwwproducts/en/SST26VF064B but I am not sure how I can incorporate the driver into Harmony framework (e.g. replacing APIs like SPI2_Exchange8bit()) ...
Please help! I am stuck for quite some time now :(
let me know if you need more info...
 
#1

18 Replies Related Threads

    NKurzman
    A Guy on the Net
    • Total Posts : 17916
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: SST26VF032B SPI driver for Harmony 2018/07/27 06:32:06 (permalink)
    5 (1)
    Start by reading the JEDEC code from the chip. The number You should get is listed in the datasheet this will let you know your reads are working
    #2
    zugunruhe
    New Member
    • Total Posts : 8
    • Reward points : 0
    • Joined: 2018/07/26 15:50:29
    • Location: 0
    • Status: offline
    Re: SST26VF032B SPI driver for Harmony 2018/07/27 08:10:08 (permalink)
    0
    Yes, I did that before. I am reading three bytes (by sending JEDEC-ID command) one of which is device ID 0x42 for this chip.
    Also, additional information: WP# and HOLD# are both pulled up in my custom board.
    #3
    zugunruhe
    New Member
    • Total Posts : 8
    • Reward points : 0
    • Joined: 2018/07/26 15:50:29
    • Location: 0
    • Status: offline
    Re: SST26VF032B SPI driver for Harmony 2018/07/28 14:32:16 (permalink)
    0
    I also tried the Legacy Peripheral Libraries and install them in the XC32 compiler environment (Harmony Framework) so I could compile and try the drivers from here  https://www.microchip.com/wwwproducts/en/SST26VF064B. After importing the code and trying to compile I realized that these are not for PIC32 architecture as the SPI configurations are different:
    ../src/mcc_generated_files/spi2.c:69:5: error: 'SPI2CON1' undeclared (first use in this function)
         SPI2CON1 = 0x007F;    

         ^
    ../src/mcc_generated_files/spi2.c:89:25: error: '__SPI2STATbits_t' has no member named 'SRXMPT'
         while ( SPI2STATbits.SRXMPT == true);

     
    I hope this is due to my naiveness but I think Microchip has never tested SST26 for their PIC32 platforms!!! and they are intentionally being vague about it... again I hope I am wrong then there'd at least be a solution to my problem at the cost of being stupid! acceptable trade-off haha...
    The alternative I am thinking at this point is to change the Flash Chip to SST25 !!! unless I find a solution before then ...
     
    #4
    NKurzman
    A Guy on the Net
    • Total Posts : 17916
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: SST26VF032B SPI driver for Harmony 2018/07/28 17:04:42 (permalink)
    0
    I can confirm the chip works fine with a pic32mz SPI and the harmony PLIB functions.
    What baud rate are you using?
    The PIC32mz has a slightly different set up for it top baud rate. And it is slower than the sst26.
    I can post my setup, but not on a weekend.
    Remind me during working hours(EST)
    Did look at the sample code posted with the flash chip?
    #5
    zugunruhe
    New Member
    • Total Posts : 8
    • Reward points : 0
    • Joined: 2018/07/26 15:50:29
    • Location: 0
    • Status: offline
    Re: SST26VF032B SPI driver for Harmony 2018/07/28 18:15:01 (permalink)
    0
    SPI BD is 10Mhz
    #define DRV_SPI_BAUD_RATE_IDX0                 10000000
    I started off with sst25_fat examples came with the Harmony installation and tried to change the SST25 driver for SST26. There are not much extra set up for SST26 as the flash chip is unlocked by default I believe. So as far as SPI underlying driver I am using the the same as what was used in the example.
    So just to clarify, have you done SPI driver for SST26 with PIC32MZ ? I know there is a harmony example for SQI mode not SPI...
    #6
    NKurzman
    A Guy on the Net
    • Total Posts : 17916
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: SST26VF032B SPI driver for Harmony 2018/07/28 18:49:46 (permalink)
    0
    I only used the harmony PLIB libraries. I did not use the harmony SPI driver. I can not say whether the driver works or not. Just that that flash chip will work with the the pic32mz.
    There is sample code with on the chips web page. It must be properly unlocked to write to it. During the write you must check the status to insure it is done.
    Note the SST25 write is not compatible with the SST26. They are pin compatible, but not software compatible.
    #7
    NKurzman
    A Guy on the Net
    • Total Posts : 17916
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: SST26VF032B SPI driver for Harmony 2018/07/30 12:28:53 (permalink)
    #8
    zugunruhe
    New Member
    • Total Posts : 8
    • Reward points : 0
    • Joined: 2018/07/26 15:50:29
    • Location: 0
    • Status: offline
    Re: SST26VF032B SPI driver for Harmony 2018/07/30 14:01:01 (permalink)
    3 (1)
    Thanks but that's what I posted earlier too :-)
    #9
    zugunruhe
    New Member
    • Total Posts : 8
    • Reward points : 0
    • Joined: 2018/07/26 15:50:29
    • Location: 0
    • Status: offline
    Re: SST26VF032B SPI driver for Harmony 2018/07/30 14:04:31 (permalink)
    0
    I ported over the above driver and replaced SRXMPT with SPIRBF:
    In other words replaced "while ( SPI2STATbits.SRXMPT == true);" with "while (!SPI2STATbits.SPIRBF);" in SPI module and now I can read and right properly !!!
     
    #10
    zugunruhe
    New Member
    • Total Posts : 8
    • Reward points : 0
    • Joined: 2018/07/26 15:50:29
    • Location: 0
    • Status: offline
    Re: SST26VF032B SPI driver for Harmony 2018/07/30 14:06:16 (permalink)
    0
     
    Note that my environment is PIC32 and the legacy drivers are for older platforms. So I had to install legacy libs ...
    #11
    zugunruhe
    New Member
    • Total Posts : 8
    • Reward points : 0
    • Joined: 2018/07/26 15:50:29
    • Location: 0
    • Status: offline
    Re: SST26VF032B SPI driver for Harmony 2018/07/30 14:38:08 (permalink)
    0
    Lastly for others who might run into the same problem:
    To me, the root cause of the problem was in the underlying SPI code/module in Harmony frameworks.
    Interesting enough the framework works with older chip (SST25) not with the newer one (SST26). I might be missing some reasons between the lines but the state of the Microchip examples are the older chip(SST25) works with the newer framework (Harmony) and newer chip(SST25) with legacy driver haha...
    Anyways my problem has been resolved now and don't need to replace the chip! Thank you NKurzman for the help.
    #12
    NKurzman
    A Guy on the Net
    • Total Posts : 17916
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: SST26VF032B SPI driver for Harmony 2018/07/30 14:56:30 (permalink)
    0
    Glad you got it to work.  I tried posting code earlier, but the Fourm Firewall blocked it.
    Note Harmony has replacement functions for the old PLIB
    ie
    PLIB_SPI_BufferWrite();
    PLIB_SPI_TransmitBufferIsFull()
    PLIB_SPI_ReceiverBufferIsFull()
    PLIB_SPI_BufferRead()
    ect
     
    #13
    BumpSplat
    Senior Member
    • Total Posts : 163
    • Reward points : 0
    • Joined: 2017/11/06 13:23:11
    • Location: Bend, OR
    • Status: offline
    Re: SST26VF032B SPI driver for Harmony 2018/10/07 15:21:16 (permalink)
    0
    Slightly off topic, I'm using the VF032B and was wondering if a reset is required after an erase cycle.  Also, the reset sequence uses an 8 bit "reset enable" CSHigh slight delay CSLow 8 bit "reset".  I'm using it in 16 bit mode.  Do I need to change my SPI interface to 8 bit for the reset process? -Thanks
    #14
    BumpSplat
    Senior Member
    • Total Posts : 163
    • Reward points : 0
    • Joined: 2017/11/06 13:23:11
    • Location: Bend, OR
    • Status: offline
    Re: SST26VF032B SPI driver for Harmony 2018/10/07 15:45:43 (permalink)
    0
    Also, is it possible to very a software reset was completed correctly?
     
    It's very strange I can successfully program the IC 7 times and it fails on the eighth cycle.  It's actually random but the concept is the same....
    post edited by BumpSplat - 2018/10/07 15:47:27
    #15
    BumpSplat
    Senior Member
    • Total Posts : 163
    • Reward points : 0
    • Joined: 2017/11/06 13:23:11
    • Location: Bend, OR
    • Status: offline
    Re: SST26VF032B SPI driver for Harmony 2018/10/07 16:18:58 (permalink)
    0
    Disregard, I'm stepping over to a more active thread. :)
    post edited by BumpSplat - 2018/10/11 14:53:17
    #16
    dapeters
    New Member
    • Total Posts : 12
    • Reward points : 0
    • Joined: 2016/10/10 13:20:36
    • Location: 0
    • Status: offline
    Re: SST26VF032B SPI driver for Harmony 2019/11/06 06:40:15 (permalink)
    0
    I have been using Harmony Framework V.2.04 for quite a while on a custom control that incorporates the SST25 device.  Now that the SST25 is becoming obsolete, I've tried putting in a comparable SST26 and have had no luck getting memory writes to work.  I am using the Page Program command (0x02) to do the writes, but all I get back are 0xFF's.  Has anyone had any luck using the Harmony Framework with SPI mode for the SST26?
    One thing I question is that the data sheet says the WEL bit is automatically reset after certain commands, like erasing or writing, but I never see that bit get cleared.
    #17
    NKurzman
    A Guy on the Net
    • Total Posts : 17916
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: SST26VF032B SPI driver for Harmony 2019/11/06 08:35:52 (permalink)
    0
    http://ww1.microchip.com/downloads/en/DeviceDoc/Device%20drivers%20SST26VF032B.zip
    Look at SST26VF032B.c in  "for DM240001 Pictail Plus connector"
    That is the origional pre-Microchip code and what I used as a reference.
     
    I got it working with a PIC32MZ and Harmony V1.11 in SPI Mode.
    Not using the Harmony Drivers, just it's PLIB.  Note that the SPI Settings are different if you are trying to run it at max bus speed. ( Sample at the end, not in the middle)
    And note the V25 and V26 communications are not the same.
    #18
    dapeters
    New Member
    • Total Posts : 12
    • Reward points : 0
    • Joined: 2016/10/10 13:20:36
    • Location: 0
    • Status: offline
    Re: SST26VF032B SPI driver for Harmony 2019/11/06 13:40:00 (permalink)
    5 (1)
    I found my problem.  I thought all memory was "unlocked" at power up.  I had to issue a global unlock command during initialization to be able to write to it.
    #19
    Jump to:
    © 2019 APG vNext Commercial Version 4.5