KE06Z SPI strange behavior

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

KE06Z SPI strange behavior

Jump to solution
1,067 Views
ngiussani
Contributor III

Hi,

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).

spi_mke.jpg

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) {
      ExpIO_CS_Enable();

      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;
 
      ExpIO_CS_Disable();
   }
   return dummy ;
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
Labels (1)
0 Kudos
1 Solution
869 Views
ngiussani
Contributor III

Hi,

After reviewing documentation once and again, I finally solved the issue. The MISO pin is by default assigned to the NMI_b function. The thing is, under debug, somehow, it is correctly assigned to the MISO function, but when the device is switched off and back on, it resets to that default value.

I recognize my mistake, but I have to say that documentation is very confusing and you have to browse it back and forth to find everything you need to make something work.

Thanks Kerry for your support.

View solution in original post

0 Kudos
4 Replies
870 Views
ngiussani
Contributor III

Hi,

After reviewing documentation once and again, I finally solved the issue. The MISO pin is by default assigned to the NMI_b function. The thing is, under debug, somehow, it is correctly assigned to the MISO function, but when the device is switched off and back on, it resets to that default value.

I recognize my mistake, but I have to say that documentation is very confusing and you have to browse it back and forth to find everything you need to make something work.

Thanks Kerry for your support.

0 Kudos
869 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Thanks a lot for your updated information.

I don't know you are using the NMI pin. NMI, reset, swd_clk, swd_dat is the special pin, it is indefault as the special function, not the GPIO, so if you are using the NMI pin as SPI pin, you need to disable the NMI function in the register by yourself at first, otherwise, the code will enter the NMI interrupt.


Have a great day,
Kerry

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

0 Kudos
869 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Nicolas,

    No data means the MKE06Z don't get the useful SPI data.

    Please also tell me KE06 is the master or the slaver?

   If it is the master, from your attached logic analyzer wave, I find your MISO data is just 0XFF, 0XFF 0XF5;   0XFF, 0XFF 0XFF.

   Please check the MISO, is it what you needed?

   Please also share the SPI wave under the debugger mode(which works OK), then you also can check the MISO, is it also the same data as the none debugger mode?

   If the data is not the same, I think you also can check the oscilloscope wave, check the voltage.

  Besides, in the MKE06 initialization for SPI, please also enable the SPI pin pull up, then try it again.

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
869 Views
ngiussani
Contributor III

Hi Kerry,

Thanks for your answer. I don't get the "No data means the MKE06Z don't get the useful SPI data", as we can see useful data (0xF5 and 0xFF when MOSI is 0x00). When I'm debugging it is there. And it's working just fine, with the exact same data and signals in both cases.

Of course, as it is a peripheral, SPI is in Master Mode. Also, just for clarifying, baud rate is way lower than the maximum admitted by the peripheral.

As I mentioned, SPI wave is exactly the same. I already checked with an osciloscope and there is nothing wrong, and levels are just fine.

Enabling pull-ups was one of the things I tried, but nothing changed.

It is very frustrating, as I have both SPI channels enabled, and I have no trouble with the other one, that is writing and reading a Flash Memory and a RTCC.

0 Kudos