KL26Z SPI MOSI Idles high

cancel
Showing results for 
Search instead for 
Did you mean: 

KL26Z SPI MOSI Idles high

691 Views
markmichael
Contributor I

I'm trying to read/write data to a camera module using the SPI interface. The slave generates a response with an arduino but not with the frdm-KL26z. I used an oscilloscope to compare the MOSIs and I found that POL and PHA were 0 in both of them. The only difference was that the Arduino has the MOSI pulled down and the KL26z has it pulled up. I'm using Processor Expert and KSDK 1.3 and I can't find a way to change where the MOSI idles for the KL26z.

Here is the Arduino SCK and MOSI (0x80, 0x55) (receives response)

Arduino.jpg

Here is the Freescale sending the same bytes (no response)Freescale.jpg

In a quick attempt to validate my hypothesis, I wired the CS and and MOSI to digital inputs and output a CS XOR MOSI modified MOSI. The problem with that is that the bytes were shifted (maybe because the CPU had to process them after the original signal is sent?), but I ordered a XOR logic gate that should be here soon.

I would appreciate any suggestions on how to fix this. Although it isn't pictured, I verified that CS is pulled low for the transmission and pulled back up between transmissions. I also double checked that the slave was configured for POL 0 and PHA 0. I also made sure the frequency wasn't too high (it's set to 75khz; the slave can work with up to 8Mhz).

0 Kudos
4 Replies

273 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi

First of all, sorry for my later reply.

I checked the ArduCAM-M-2MP camera datasheet, the SPI communication using CPOL = 0 and CPHA = 0 mode.

I don't think the KL26 SPI module cause the problem if there with correct setting.

I am doubt the Processor Expert component customer generated code caused the issue.

Could you guide me which component you are using to generate the SPI code?

pastedImage_2.png

Have you tried to prot the KSDK V1.3 <spi_dma_blocking_example_master> demo with your application?

Thank you for the attention.

Have a great day,
Ma Hui
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

273 Views
markmichael
Contributor I

Here is the documentation for the camera module: http://www.arducam.com/downloads/shields/ArduCAM_Mini_2MP_Camera_Shield_Hardware_Application_Note.pd...

I should mention that there is an error where it describes the SPI mode as 0 with POL 0 and PHA 1. It has been addressed and corrected on github here: SPI Interface error with CC3200 and ArduMini 2MP (OV2640) · Issue #49 · ArduCAM/Arduino · GitHub

Basically, its corrected to Mode 0, POL 0 PHA 0.

Also, to test the interface, I am sending {0x80, 0x55} in one transmission to write into the module's test register and then sending {0x00, 0x00}, to read it back and see if it matches. Here is the code for that part:

uint8_t spiTest[2]={0x80, 0x00};

uint8_t spiReadTest[2]={0x00, 0x00};

uint8_t spiTestBuffer[2]={0};

GPIO_DRV_WritePinOutput(J2_6,0);

spi_status_t spiReturnValue0=SPI_DRV_DmaMasterTransferBlocking(

  SPI1_IDX,

  &spiSensor2_MasterConfig0,

  spiTest,

  NULL,

  2,

1000

  );

GPIO_DRV_WritePinOutput(J2_6,1);

GPIO_DRV_WritePinOutput(J2_6,0);

spi_status_t spiReturnValuea=SPI_DRV_DmaMasterTransfeBlockingr(

  SPI1_IDX,

  &spiSensor2_MasterConfig0,

  spiReadTest,

  spiTestBuffer,

  2,

1000

  );

GPIO_DRV_WritePinOutput(J2_6,1);

0 Kudos

273 Views
markmichael
Contributor I

Sorry, my comment posted before I finished the code and that typo in "DmaMasterTransferBlocking isn't in the actual code. Everything builds without error.

Also here are the settings I'm using in PE:

Capture.PNG

uint8_t spiTest[2]={0x80, 0x00};

uint8_t spiReadTest[2]={0x00, 0x00};

uint8_t spiTestBuffer[2]={0};

GPIO_DRV_WritePinOutput(J2_6,0);

spi_status_t spiReturnValue0=SPI_DRV_DmaMasterTransferBlocking(

  SPI1_IDX,

  &spiSensor2_MasterConfig0,

  spiTest,

  NULL,

  2,

1000

  );

GPIO_DRV_WritePinOutput(J2_6,1);

GPIO_DRV_WritePinOutput(J2_6,0);

spi_status_t spiReturnValuea=SPI_DRV_DmaMasterTransferBlocking(

  SPI1_IDX,

  &spiSensor2_MasterConfig0,

  spiReadTest,

  spiTestBuffer,

  2,

1000

  );

GPIO_DRV_WritePinOutput(J2_6,1);

0 Kudos

273 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi

I don't think the MOSI idle voltage level will affect the SPI communication.

Could you provide the external camera module datasheet? I will check that camera module requirement.


Thank you for the attention.

Have a great day,
Ma Hui
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos