This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/TMS570LS1224: Light Sensor does not respond when light is shined

Part Number: TMS570LS1224
Other Parts Discussed in Thread: HALCOGEN, LAUNCHXL2-RM46, LAUNCHXL2-TMS57012

Tool/software: Code Composer Studio

Hello,

I recently followed this tutorial, which explains how to output the value that the light sensor of your board receives to a serial terminal: https://training.ti.com/hercules-how-tutorial-12bit-adc

I am trying to get the same results using a tms570ls1224 board. As in the tutorial, I am receiving values from the light sensor every frame, but when I shine a light on the sensor, the values do not appear to be affected. I believe the problem is that the light sensor is not properly connected to the ADC.

Here is the code I have in sys_main.c:

/* USER CODE BEGIN (0) */

#include "sci.h"

#include "adc.h"

#include "stdlib.h"

unsigned char command[8];

/* USER CODE END */

 

/* Include Files */

 

#include "sys_common.h"

 

/* USER CODE BEGIN (1) */

#include "gio.h"

#include "het.h"

/* 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.

*/

 

int main(void)

{

/* USER CODE BEGIN (3) */

    int i;

 

    gioInit();

    hetInit();

 

    adcData_t adc_data; //ADC Data Structure

    adcData_t *adc_data_ptr = &adc_data; //ADC Data Pointer

    unsigned int NumberOfChars, value; //Declare variables

 

     sciInit(); //Initializes the SCI (UART) module

     adcInit(); //Initializes the ADC module

 

     while(1) {

 

 

        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);

         sciSend(scilinREG, 2, (unsigned char *)"0x"); //Sends '0x' hex designation chars

         sciSend(scilinREG, NumberOfChars, command); //Sends the ambient light sensor data

          sciSend(scilinREG, 2, (unsigned char *)"\r\n"); //Sends new line character

    }

 

/* USER CODE END */

 

    return 0;

}

 

 

/* USER CODE BEGIN (4) */

void adcNotification(adcBASE_t *adc, unsigned group)

{

    return;

}

 

void sciNotification(sciBASE_t *sci, unsigned flags)

{

    return;

}

 

void esmGroup1Notification(int bit)

{

  return;

}

 

void esmGroup2Notification(int bit)

{

  return;

}

 

The code all appears to be correct. I believe I need to change something in adc.c or adc.h in order to allow the sensor to communicate with the ADC.

Here is a link to the schematics of my board: http://processors.wiki.ti.com/images/c/c1/LAUNCHXL2_TMS57012_RM46_REVA.pdf

This schematic can be found on page 10:

This diagram shows how the light sensor (Q1) is connected to the ADC (AD1IN_6/9.3D).

Does anyone know what I need to do to complete the connection between the light sensor and the serial terminal’s output?

  • Derek Washburn said:
    This diagram shows how the light sensor (Q1) is connected to the ADC (AD1IN_6/9.3D).

    Does anyone know what I need to do to complete the connection between the light sensor and the serial terminal’s output?

    How has the ADC been configured in HALCoGen?

    The "ADC1 Group 1" configuration in HALCoGen needs to sample Pin 6 since the light sensor is connected to the AD1IN[6] pin:

    [This was tested on a LAUNCHXL2-RM46, which has the same PCB as the LAUNCHXL2-TMS57012]

  • That worked. I enabled pin 6, and now the light sensor works as expected. Thank you so much!