Alpaslan_Ersoz
Junior Member level 2
- Joined
- Aug 9, 2018
- Messages
- 20
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 220
Actually, I couldn't read the correct values with 'volt' variables.
I want to share my code, input signal, and ADC signals. I miss something because the 'volt' shows different values than input signal amplitudes.
Function code:
ADC SCK (green plot), ADC CS (yellow plot), and ADC SDO (blue plot)
Input signal is
The 'volt' variable result is
I want to share my code, input signal, and ADC signals. I miss something because the 'volt' shows different values than input signal amplitudes.
Function code:
Code:
uint8_t i;
uint16_t Sample;
float volt=0;
uint8_t ADC_Buf[2];
float testdata_in[16];
uint8_t spidata[2];
void ADC_Conversion_of_Voltage_Transients()
{
spidata[0]=0x00; // Set everything up before you start the exchange
spidata[1]=0x00;
HAL_GPIO_WritePin(ADC_CS_GPIO_Port, ADC_CS_Pin, GPIO_PIN_RESET);
HAL_SPI_TransmitReceive(&hspi4,spidata,ADC_Buf,1,100); // See below
HAL_GPIO_WritePin(ADC_CS_GPIO_Port, ADC_CS_Pin, GPIO_PIN_SET);
Sample = (((uint16_t) ADC_Buf[1]) << 8 | ADC_Buf[0]);
volt = (float)(Sample * (5.0 / 4096.0)); //
testdata_in[i++]=volt;
i %= 16;
}
ADC SCK (green plot), ADC CS (yellow plot), and ADC SDO (blue plot)
Input signal is
The 'volt' variable result is