can not set the speed of the spi2

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
jizh_2145461
Level 1
Level 1

the spi2 works in master mode, and I set the  spi2 clock(P03) with spiffyd_configure() function, write data with spiffyd_txData().

but the real frequency is always about 10MHZ.  


the code is following :

void spiffy2_master_initialize(void)

{

   // Use SPIFFY2 interface as master

   spi2PortConfig.masterOrSlave = MASTER2_CONFIG;

   // pull for MISO for master, MOSI/CLOCK/CS if slave mode

   spi2PortConfig.pinPullConfig = INPUT_PIN_PULL_UP;

   // Use P03 for CLK, P00 for MOSI and P01 for MISO

   spi2PortConfig.spiGpioConfig = MASTER2_P03_CLK_P00_MOSI_P01_MISO;

   // Initialize SPIFFY2 instance

   spiffyd_init(SPIFFYD_2);

   // Define this to the Port/Pin you want to use for CS.

   // Port = P#/16 and PIN = P# % 16

   // Configure the CS pin and deassert it initially.

   // If enabling output, you only need to configure once. Use gpio_setPinOutput to toggle value being o/p

   gpio_configurePin(SPI_CS_PORT, SPI_CS_PIN, GPIO_OUTPUT_ENABLE | GPIO_INPUT_DISABLE, 0);

   // Configure the SPIFFY2 HW block

   spiffyd_configure(SPIFFYD_2, SPI_SPEED, SPI_MSB_FIRST, SPI_SS_ACTIVE_LOW, SPI_MODE_3);

}

void writec(UINT8 data)

{

   gpio_setPinOutput(SPI_CS_PORT, SPI_CS_PIN, 0);

gpio_setPinOutput(LCD_A0_PORT, LCD_A0_PIN, 0);

bleapputils_delayUs(1);

spiffyd_txData(SPIFFYD_2, 1 ,&data);

bleapputils_delayUs(1);

// gpio_setPinOutput(SPI_CS_PORT, SPI_CS_PIN, 1);

}

here is the oscillograph of the clock pin

scope_2.jpg

0 Likes
1 Solution

the hw platform is BCM20737, and i change the clock pin from P03 to P24, it works well, thanks.

View solution in original post

0 Likes
2 Replies
MichaelF_56
Moderator
Moderator
Moderator
250 sign-ins 25 comments on blog 10 comments on blog

Are you following the example shown in the WICED™ Smart Hardware Interfaces guide?

I know it states that the maximum SCLK speed supported by SPIFFY2 is 6 MHz at all IO supply voltages.

0 Likes

the hw platform is BCM20737, and i change the clock pin from P03 to P24, it works well, thanks.

0 Likes