cancel
Showing results for 
Search instead for 
Did you mean: 

How can i get the clock signal from SPI_SCK?

Young Gwon Shin
Associate
Posted on June 19, 2018 at 05:23

Hello. I want ask something that drive to me mad.

Using STM32F769NIH for control external ADC(AD7192) with SPI interface

SPI6 for SPI communication(PG13 -> SCK, PA6 -> MISO, PG14 -> MOSI)

nChip Select controlled by PI13

clock enable to all use(PORT A, G, I) and SPI6 also

setting to SPI6 and initialize it

but I can't get the clock signal from PG13(SPI6_SCK) 

how can i get the clock signal? what is wrong?

p.s i check  PIN and AF from ref. if i mistake it, plz tell me 

//////////////////////////////////////////////////////code/////////////////////////////////////////////////////////

GPIO_InitTypeDef GPIO_InitStruct;

SPI_HandleTypeDef hspi;

__HAL_RCC_GPIOI_CLK_ENABLE(); //nCS PIN

GPIO_InitStruct.Pin = GPIO_PIN_13;

GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;

GPIO_InitStruct.Pull = GPIO_NOPULL;

GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;

HAL_GPIO_Init(GPIOI, &GPIO_InitStruct);

__HAL_RCC_SPI6_CLK_ENABLE(); //spi gpio

__HAL_RCC_GPIOG_CLK_ENABLE(); // PG13 ------> SPI6_SCK

GPIO_InitStruct.Pin = GPIO_PIN_13;

GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

GPIO_InitStruct.Pull = GPIO_PULLDOWN;

GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;

GPIO_InitStruct.Alternate = GPIO_AF5_SPI6;

HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);

__HAL_RCC_GPIOA_CLK_ENABLE(); // PA6 ------> SPI6_MISO

GPIO_InitStruct.Pin = GPIO_PIN_6;

GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

GPIO_InitStruct.Pull = GPIO_PULLDOWN;

GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;

GPIO_InitStruct.Alternate = GPIO_AF8_SPI6;

HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

__HAL_RCC_GPIOG_CLK_ENABLE(); // PG14 ------> SPI6_MOSI

GPIO_InitStruct.Pin = GPIO_PIN_14;

GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

GPIO_InitStruct.Pull = GPIO_PULLDOWN;

GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;

GPIO_InitStruct.Alternate = GPIO_AF5_SPI6;

HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);

hspi.Instance = SPI6;

hspi.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_256;

hspi.Init.Direction = SPI_DIRECTION_2LINES;

hspi.Init.CLKPhase = SPI_PHASE_1EDGE;

hspi.Init.CLKPolarity = SPI_POLARITY_LOW;

hspi.Init.DataSize = SPI_DATASIZE_8BIT;

hspi.Init.FirstBit = SPI_FIRSTBIT_MSB;

hspi.Init.TIMode = SPI_TIMODE_DISABLE;

hspi.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;

hspi.Init.CRCPolynomial = 7;

hspi.Init.NSS = SPI_NSS_SOFT;

// hspi.Init.NSSPMODE = SPI_NSS_PULSE_DISABLE;

hspi.Init.Mode = SPI_MODE_MASTER;

if(HAL_OK != HAL_SPI_Init(&hspi))

{

printf('INIT_ERROR');

}

while(1)

{

}

/////////////////////////////////////////////end/////////////////////////////////

2 REPLIES 2
Posted on June 19, 2018 at 11:00

Check if there is no continuity error (badly soldered ball) by setting this pin as GPIO Out and toggling it.

JW

Posted on June 20, 2018 at 03:08

Thanks a lot for reply.

In your answer, i find the probability of device problem

finally I made it. but it is not the problem of code. 

I found SPI interface was working but SCK couldn't find it. 

i also check disco board with example code, my scope couldn't found SCK signal from SCK PIN.

So just problem in scope or scope setting. 

Really appreciate to you.

Best regards.