Other Parts Discussed in Thread: HALCOGEN
Dear sir,
thank you so much for your reply sir.
Through UART i am sending the data and receiving the response as per the command structure given by client
only pending is adc
in adc i want to read the voltage and displaying in gui
i am using this AD7476SR
TZ-R2 in schematic 3rd pin as the input voltage of 3V
from bellow code iam receiving the response is 60159 constant. changing input voltage of ADC no change in output response
/* USER CODE BEGIN (0) */
#include "sci.h"
#include "adc.h"
#include "stdlib.h"
/* USER CODE END */
/* Include Files */
#include "sys_common.h"
/* USER CODE BEGIN (1) */
unsigned char command[10];
/* USER CODE END */
/** @fn void main(void)
* @brief Application main function
* @note This function is empty by default.
*
* This function is called after startup.
* The user can use this function to implement the application.
*/
/* USER CODE BEGIN (2) */
/* USER CODE END */
//adcData_t data; //ADC Data Structure
//adcData_t *adc_data_ptr = &data; //ADC Data Pointer
//unsigned int NumberOfChars, value;
int main(void)
{
/* USER CODE BEGIN (3) */
/* USER CODE BEGIN (3) */
adcData_t adc_data; //ADC Data Structure
adcData_t *adc_data_ptr = &adc_data; //ADC Data Pointer
unsigned int NumberOfChars, value;
sciInit();
adcInit();
adcCalibration(adcREG1);
// adcCalibration(adcREG2);
while(1) // Infinite loop to acquire and send ADC sample data via SCI (UART)
{
adcStartConversion(adcREG1,adcGROUP1); //Start ADC conversion
while(!adcIsConversionComplete(adcREG1,adcGROUP1)); //Wait for ADC conversion
adcGetData(adcREG1,1U,adc_data_ptr); //Store conversion into ADC pointer
// adcGetData(adcREG1, adcGROUP1,&adc_data[0]);
value=(unsigned int) adc_data_ptr-> value;
// NumberOfChars = ltoa(value, (char *)command); //Converts "value" to a string and stores it in "command".
NumberOfChars= sprintf(command, "%d", value);
// NumberOfChars= sprintf(value, "%d", command);
//Transmit over Serial
// sciSend(scilinREG, 2, (unsigned char *) "0x");
sciSend(scilinREG, NumberOfChars,command);
sciSend(scilinREG, 2, (unsigned char *) "\r\n");
__delay_cycles(10000000); // 1-second delay
}
/* USER CODE END */
return 0;
}
/* USER CODE BEGIN (4) */
/* USER CODE END */
the above code is used to read the voltage of adc
i am taking the reference code from this video www.youtube.com/watch
i am trying to read the voltage of ADC .
iam attaching the snapshots for halcogen also sir.
please guide me