2 Replies Latest reply on Aug 21, 2015 12:04 AM by jizh_2145461

    can not set the speed of the spi2

    jizh_2145461

      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