LPC55S69 (OKDO-E1 Board) SPI first CLK cycle twice long

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

LPC55S69 (OKDO-E1 Board) SPI first CLK cycle twice long

跳至解决方案
711 次查看
maciek21
Contributor II

Hi, trying to understand SPI on LPC55s69
Sent (0b10000000) over SPI MOSI to understand how it work, find out that first CLK cycle duty is twice as long as other.  

Can anybody explain to my why and how can I fix that?
(Need identical time cycle to control addressed led)

analyze.png

set.png

  

 

#include <stdio.h>
#include "board.h"
#include "peripherals.h"
#include "pin_mux.h"
#include "clock_config.h"
#include "LPC55S69_cm33_core0.h"
#include "fsl_debug_console.h"

#define TRANSFER_SIZE (1) /*! Transfer dataSize */

uint8_t masterRxData[TRANSFER_SIZE] = {0};
uint8_t masterTxData[TRANSFER_SIZE] = {0};

int main(void)
{
	spi_transfer_t masterXfer;

	/* Init board hardware. */
	BOARD_InitBootPins();
	BOARD_InitBootClocks();
	BOARD_InitBootPeripherals();

	#ifndef BOARD_INIT_DEBUG_CONSOLE_PERIPHERAL
		/* Init FSL debug console. */
		BOARD_InitDebugConsole();
	#endif

	/*Config transfer*/
	masterXfer.txData = masterTxData;
	masterXfer.rxData = masterRxData;
	masterXfer.dataSize = sizeof(masterTxData);
	//masterXfer.configFlags = kSPI_FrameAssert;
	masterXfer.configFlags = 0;

	PRINTF("Debug start \r\n");

	masterTxData[0] = 0b10000000;

	while(1)
	{
		SPI_MasterTransferBlocking(FLEXCOMM8_PERIPHERAL, &masterXfer);
		for(volatile int i=0;i<500000;i++);
	}

	return 0;
}

 

标记 (3)
0 项奖励
1 解答
671 次查看
Alex_Wang
NXP Employee
NXP Employee

Hi, @maciek21 

        According to CPOL=0, the idle level is low, and CPHA=0 is rising edge sampling. While your logic analyzer shows falling edge sampling, you should choose the appropriate trigger edge. You can send me the screenshots of all SPI signals, including CLK, CS, MOSI and MISO.

Best regards, Alex

在原帖中查看解决方案

0 项奖励
4 回复数
682 次查看
Alex_Wang
NXP Employee
NXP Employee

Hi, @maciek21 

        For the first picture, it seems that the clock signal is incorrect, could you please show me all the signals of SPI?

        How did you set up CPOL and CPHA? The picture is blurry and I can't see it clearly.

Best regards, Alex

0 项奖励
678 次查看
maciek21
Contributor II

hi, hope this time attache file will work 

CPOL = 0
CPHA = 0

0 项奖励
672 次查看
Alex_Wang
NXP Employee
NXP Employee

Hi, @maciek21 

        According to CPOL=0, the idle level is low, and CPHA=0 is rising edge sampling. While your logic analyzer shows falling edge sampling, you should choose the appropriate trigger edge. You can send me the screenshots of all SPI signals, including CLK, CS, MOSI and MISO.

Best regards, Alex

0 项奖励
662 次查看
maciek21
Contributor II

Hi, first, thanks for your help.

That's suggestion about CPOL and CPHA kind of answer my question and helped me find solution and fix problem.

The IDLE state for MOSI (and all other SPI signals) in this board is HIGH, as it is physically pulled-up to VCC by a resistor.

Due to this information, I should use CPOL = 1 and CPHA = 1 and that's worked.

I believe further investigation MISO, SSEL or SCK won't be necessary because I only need MOSI to control over led.

Have a good day