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
gbm
Lead III

Either use 3 8-bit frames (or 2 12-bit frames) and one 15-bit (reprogramming the SPI between transfers) or do it with 3 13-bit frames, shuffling the data in software.

What I need to set the Data size of SPI in Configuration

S.Ma
Principal

Use 8 bit SPI mode. If your SPI has 32 bit HW fifo, you can write 16 bit or 8 bit and all are sliced and queued, to minimize pause between bytes. Was the 24 bit to include a 8 bit command followed by 24 bit read? In write amd read mode things maybe simpler than thoughts...

Are these two independent transactions?

24 + 15 = 39

39 / 3 = 13

You could perhaps configure as 13-bit words, and do 3 word transfers.

It's hard to guess at exactly what you want to achieve, not sure I have time to read ADS7046 docs for you.

Look at the word length options you have for the STM32 you're using. Read the Chapter in the Reference Manual, situate yourself on the capabilities and flexibility.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Lead with what STM32 you're using? The STM32H745 or something else?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

I am using the STM32h745 series of controller. For calibaration purpose I need 24SCLK and for the data it requires 15 SCLK clock. Its only receiving mode.

In SPI I set the mode Receive only master

Data size I set the 16 bit

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

INPUT_VOLTAGE=(ADC_Value/4096)*3.3;

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

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

HAL_Delay(50);

This my programme .

0693W00000Y72fGQAR.pngHow I send the clock pulse 24 for calibration?

I use the only receiving function I need to use the Transmit function for sending dummy data for calibration?

0693W00000Y72faQAB.png 

gbm
Lead III

To send 24 clock pulses, just send 3 8-bit frames or 2 12-bit frames. You don't need to configure the MOSI line for that.

From the above docs, it should be done only once after powerup.

Then I need to call the HAL_SPI_Receive funtion 3 times? if I set the 8bit mode

S.Ma
Principal

The adc uses the spi clock to perform the binary search adc conversion, did you check if AD provides application notes or drivers? My guess to sell well, the adc shoul be easy to use. Some trial and errors maybe needed. Ideally, ST should providd one example of SPI Adc or dac driver to start from. Stick to 8, 16, 32 bit slices.