KE02 W25Q16

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

KE02 W25Q16

Jump to solution
5,343 Views
huyrua291996
Contributor I

Hi,

Can KE02 used with external spi flash w25q16?

If yes, what's exactly baudrate and clock can I config.

Here is datasheet of w25q16

But I dont know the config baudrate and clock in SPI 

This code I write with 250000 baudrate and bus clock default is 16MHz

And when I send the deviceID cmd to the SPI flash, it doesnt response

Labels (1)
Tags (1)
0 Kudos
Reply
1 Solution
5,049 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Huy,

   Of course you can use the KE02 to control the external spi flash w25q16.

  But, to meet the external flash demand, you need to use the GPIO as the CS control pin instead of the hardware SPI CS pin.

  About the KE02 SPI baudrate and clock configuration , you can refer to our KE driver code which can be downloaded from this link:

FRDM-KEXX Driver Library Package 

Please refer to the SPI project.

void SPI_SetBaudRate(SPI_Type *pSPI,uint32_t u32BusClock,uint32_t u32Bps)
{
    uint32_t u32BitRateDivisor;
    uint8_t u8Sppr;
    uint8_t u8Spr;
    uint8_t u8ReadFlag;
    u32BitRateDivisor = u32BusClock/u32Bps; /* calculate bit rate divisor */
       
    u8ReadFlag = 0;
    /* find best fit SPPR and SPR */
    for (u8Spr = 0; u8Spr <= 8; u8Spr++)
    {
        for(u8Sppr = 0; u8Sppr <= 7; u8Sppr++)
        {
            if((u32BitRateDivisor>>(u8Spr+1))<=(u8Sppr+1))
            {
                u8ReadFlag = 1;
                break;
            }
        }
        if(u8ReadFlag)
        {
            break;
        }
    }
    if(u8Sppr >=8)
    {
        u8Sppr = 7;
    }
    if(u8Spr >8)
    {
        u8Spr = 8;
    }
    /* set bit rate */
    pSPI->BR = SPI_BR_SPPR(u8Sppr) | SPI_BR_SPR(u8Spr);
}

If your SPI can't work, I suggest you use the logic analyzer to check the SPI wave, whether the wave meet your external flash demand or not.

Wish it helps you!


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

0 Kudos
Reply
4 Replies
5,049 Views
huyrua291996
Contributor I

Thanks Zhou

0 Kudos
Reply
5,049 Views
huyrua291996
Contributor I

Thanks Zhou,

My SPI is running because I config CS pin as GPIO

But when I config SSOE and MODFEN set to 1, it's not work right?

0 Kudos
Reply
5,049 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Huy,

   As I know, yes.

   Because the KE02 SPI CS will pull up after each SPI byte send, this won't meet your external SPI flash demand.

  That's why I suggest you configure the CS as GPIO, and use the GPIO to control the CS function.

Wish it helps you!

Kerry

 

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply
5,050 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Huy,

   Of course you can use the KE02 to control the external spi flash w25q16.

  But, to meet the external flash demand, you need to use the GPIO as the CS control pin instead of the hardware SPI CS pin.

  About the KE02 SPI baudrate and clock configuration , you can refer to our KE driver code which can be downloaded from this link:

FRDM-KEXX Driver Library Package 

Please refer to the SPI project.

void SPI_SetBaudRate(SPI_Type *pSPI,uint32_t u32BusClock,uint32_t u32Bps)
{
    uint32_t u32BitRateDivisor;
    uint8_t u8Sppr;
    uint8_t u8Spr;
    uint8_t u8ReadFlag;
    u32BitRateDivisor = u32BusClock/u32Bps; /* calculate bit rate divisor */
       
    u8ReadFlag = 0;
    /* find best fit SPPR and SPR */
    for (u8Spr = 0; u8Spr <= 8; u8Spr++)
    {
        for(u8Sppr = 0; u8Sppr <= 7; u8Sppr++)
        {
            if((u32BitRateDivisor>>(u8Spr+1))<=(u8Sppr+1))
            {
                u8ReadFlag = 1;
                break;
            }
        }
        if(u8ReadFlag)
        {
            break;
        }
    }
    if(u8Sppr >=8)
    {
        u8Sppr = 7;
    }
    if(u8Spr >8)
    {
        u8Spr = 8;
    }
    /* set bit rate */
    pSPI->BR = SPI_BR_SPPR(u8Sppr) | SPI_BR_SPR(u8Spr);
}

If your SPI can't work, I suggest you use the logic analyzer to check the SPI wave, whether the wave meet your external flash demand or not.

Wish it helps you!


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply