Part Number: TMS570LS1227
Other Parts Discussed in Thread: HALCOGEN
Tool/software: Code Composer Studio
Hi all,
I've just finished the 12 bit ADC tutorial that can be found here: https://www.youtube.com/watch?v=YOBWhFE0LZg and now I would like to expand the code so that I can read two ADC pins and send the readings via SCI.
You can see below what my Halcogen settings for ADC Group 1 Configuration is. I am using Pin 15 to monitor a voltage.
I guess the first step will be to select the other pin where I want to monitor the second voltage source (lets say pin 23) , and increase the FiFo Size to 2, right?
And below, my main() as it is, just for 1 pin ADC. The problem is that I don't know how to change the call to adcGetData so that I can get the information from both ADC pins. Any guidance would be greatly appreciated!
/* 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[8];
/* 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 */
int main(void)
{
/* 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();
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
value=(unsigned int)adc_data_ptr->value;
NumberOfChars = ltoa(value, (char *)command); //Converts "value" to a string and stores it in "command".
//Transmit over Serial
sciSend(scilinREG, 2, (unsigned char *) "0x");
sciSend(scilinREG, NumberOfChars,command);
sciSend(scilinREG, 2, (unsigned char *) "\r\n");
}
/* USER CODE END */
return 0;
}
/* USER CODE BEGIN (4) */
/* USER CODE END */