2021-03-10 08:51 AM
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
2021-03-26 11:42 AM
Thanks anyway for not supporting. Now i use a pic32
2022-03-16 05:34 PM
error: SPI_PHASE_2EDGE
error: SPI_PHASE_2EDGE