cancel
Showing results for 
Search instead for 
Did you mean: 

How to generate 24 SCLK in SPI?

MDeva.1
Associate II

Hello,

I am working with ADS7046 i need to generate 24 cloacks for calibarration and for data I need the 15 SCLK .Its SPI COnfigurable. So how I can genertare the 24 SCLK and 15 SCLk

10 REPLIES 10

HAL_GPIO_WritePin(GPIOD,MUX_SEL3_Pin, GPIO_PIN_SET);

HAL_GPIO_WritePin(SPI3_CS_GPIO_Port, SPI3_CS_Pin, GPIO_PIN_RESET);

HAL_SPI_Receive(&hspi3, (uint8_t*)&Calibrartion[0],sizeof(ADC_Value), 100);

HAL_SPI_Receive(&hspi3, (uint8_t*)&Calibrartion[1],sizeof(ADC_Value), 100);

HAL_GPIO_WritePin(SPI3_CS_GPIO_Port, SPI3_CS_Pin, GPIO_PIN_SET); // 24 Clock pulses

 /* USER CODE END 2 */

 /* Infinite loop */

 /* USER CODE BEGIN WHILE */

while (1)

{

  /* USER CODE END WHILE */

  /* USER CODE BEGIN 3 */

ADC_Value=0;

INPUT_VOLTAGE=0;

/*

The least significant bit for the device is given by:

1 LSB = VREF / 2^N

where:

• VREF = Voltage applied between the AVDD and GND pins

• N = 12

*/

HAL_GPIO_WritePin(SPI3_CS_GPIO_Port, SPI3_CS_Pin, GPIO_PIN_RESET);

HAL_SPI_Receive(&hspi3, (uint8_t*)&ADC_Value,sizeof(ADC_Value), 100);

HAL_GPIO_WritePin(SPI3_CS_GPIO_Port, SPI3_CS_Pin, GPIO_PIN_SET);

//INPUT VOLTAGE = (ADC Value / ADC Resolution) * Reference Voltage

printf("ADC_Value=%x\n\r",ADC_Value);

INPUT_VOLTAGE=((ADC_Value >> 3)/4096)*3.3;

printf("ADC_Value=%x\n\r",ADC_Value);

printf("INPUT_VOLTAGE=%f\n\r",INPUT_VOLTAGE);

HAL_Delay(50);                            // 50 Msec

}

This is my code but I applied 3.3v but I get the zero value why?