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.

Compiler: TMS570 Launchpad ADC + PWM

Other Parts Discussed in Thread: HALCOGEN, LAUNCHXL2-570LC43

Tool/software: TI C/C++ Compiler

I am using the launchxl2-570lc43 and developing with Halcogen and CCS.  

I followed the example_EPWM_ADC from Halcogen with the exception that I utilized AD1IN_6 (which is connected to a potentiometer) as the input.

I also added some code to test the value of the ADC and light an LED.

I am able to use the pot to adjust the PWM duty cycle while monitoring on an oscope. 

I have observed a strange behavior on the nError LED.

Executions starts with no nError LED on.

When I adjust the duty cycle and the IF condition toggles, the nError LED comes on and stays on beyond that point.

This happens when I start from a high value and descend or a low value and ascend.

What might this error be related to and how can I prevent it from throwing the flag?

Here is the code I used in CCS:

/* USER CODE BEGIN (0) */
/* USER CODE END */

/* Include Files */

#include "HL_sys_common.h"

/* USER CODE BEGIN (1) */
#include "HL_etpwm.h"
#include "HL_adc.h"
#include "HL_gio.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.
*/

/* USER CODE BEGIN (2) */
/* USER CODE END */

int main(void)
{
/* USER CODE BEGIN (3) */
    _enable_interrupt_();
    adcInit();
    etpwmInit();
    gioInit();
    adcEnableNotification(adcREG1, adcGROUP0);
    adcStartConversion(adcREG1, adcGROUP0);
    while(1);
/* USER CODE END */

    return 0;
}


/* USER CODE BEGIN (4) */
void adcNotification(adcBASE_t *adc, uint32 group)
{
    adcData_t data;
    uint32 count;
    uint16 cmpA;

    count = adcGetData(adcREG1, adcGROUP0, &data);
    cmpA = (etpwmREG1->TBPRD * data.value)/0xFFF;
    etpwmSetCmpA(etpwmREG1, cmpA);

    if(data.value>=1000){
                   gioSetBit(gioPORTB, 6,1);
                }
               else{
                   gioSetBit(gioPORTB, 6,0);
               }

}
/* USER CODE END */