cancel
Showing results for 
Search instead for 
Did you mean: 

Use SPI to to manage ADS1118

FItal
Associate II

Hello everybody!

Sorry for the question but i am in need of help.

I use STM32CubeIDE 1.5.1 with stm32 discovery f407g to manage an exyernal adc ADS1118.

ADC works well with Arduino, but unfortunately I can't get it to work with discovery....

 /* USER CODE END SPI1_Init 1 */

 hspi1.Instance = SPI1;

 hspi1.Init.Mode = SPI_MODE_MASTER;

 hspi1.Init.Direction = SPI_DIRECTION_2LINES;

 hspi1.Init.DataSize = SPI_DATASIZE_16BIT;

 hspi1.Init.CLKPolarity = SPI_POLARITY_LOW;

 hspi1.Init.CLKPhase = SPI_PHASE_1EDGE;

 hspi1.Init.NSS = SPI_NSS_HARD_OUTPUT;

 hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_32;

 hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;

 hspi1.Init.TIMode = SPI_TIMODE_DISABLE;

 hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;

 hspi1.Init.CRCPolynomial = 10;

//I want to send this setting to get the input ain0:

uint8_t buffer_tx0[2] = {235,195};

uint8_t buffer_rx[2];

//get the data

 HAL_GPIO_WritePin(GPIOB, GPIO_PIN_1, GPIO_PIN_RESET);

 HAL_Delay(1);

 HAL_SPI_TransmitReceive_DMA(&hspi1, buffer_tx0, buffer_rx, 2);

 HAL_GPIO_WritePin(GPIOB, GPIO_PIN_1, GPIO_PIN_SET);

 HAL_Delay(1);

I certainly make some mistakes, but by now I'm too confused.

Help me!

Thanks in advance

2 REPLIES 2
FItal
Associate II

Thanks anyway for not supporting. Now i use a pic32

mjinm.1
Associate

error: SPI_PHASE_2EDGE

error: SPI_PHASE_2EDGE