AnsweredAssumed Answered

KE06Z SPI strange behavior

Question asked by Nicolas Giussani on Sep 3, 2018
Latest reply on Sep 5, 2018 by Kerry Zhou



I'm really stuck with an issue I'm experiencing. I'm interfacing a Kinetis MKE06Z with a Microchip MCP23S17 I/O Expander. I have created the library for reading inputs, wich works perfectly when debugging (with a Segger SWD interface). If I restart my device, by disconnecting its power and connecting it again, signals are still the same (I'm attaching an image on this condition that I've got with my logic analizer), but the peripheral gets no data (I'm reading the inputs though a UART interface). I have no clue why is this happening. I've already checked every configuration (even in this condition everything is fine, as I'm sending it through the UART to verify it).


Logic Anlizer Capture


I'm also using another MCP23S17 for outputs, and it works fine, as I'm not reading any data from it.


Please help me solve this issue, as it is stopping a product development and it never happened to me before (it's not the first time I'm using both MCP23S17 nor MKE06Z)


P.S.: This is the reading routine, for more information:


uint8_t ExpIODInRead(uint8_t gpioPort)
#pragma diag_suppress=Pe550
   uint8_t dummy;
   uint16_t aux;
#pragma diag_warning=Pe550
   aux = 1000;
   while ((aux--) && !(SPI0_S & SPI_S_SPTEF_MASK));
   if (aux != 0) {

      SPI0_D = EXPIO_CMD_RD;
      while (!(SPI0_S & SPI_S_SPRF_MASK));
      dummy = SPI0_D;

      while (!(SPI0_S & SPI_S_SPTEF_MASK));
      SPI0_D = gpioPort;
      while (!(SPI0_S & SPI_S_SPRF_MASK));
      dummy = SPI0_D;

      while (!(SPI0_S & SPI_S_SPTEF_MASK));
      SPI0_D = 0;
      while (!(SPI0_S & SPI_S_SPRF_MASK));
      dummy = SPI0_D;

   return dummy ;