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.

AM2434: The timer period is unstable

Part Number: AM2434

Tool/software:

OS: FreeRTOS

 

SDK: mcu_plus_sdk_am243x_08_06_00_45

 

Hi,

If the timer is started before the task is created, the output period of the DAC module is stable, as shown in Figure 1.


Why is the output period of the DAC module unstable when the timer is started after task creation, as shown in Figure 2.

 

What could be the reason?

 

Best Regards

uint32_t gv_TaskStack[122880/sizeof(uint32_t)] __attribute__((aligned(32)));
SemaphoreP_Object gv_stObjectSem;

int main(void) {

  DAC_Init(void); // DAC module initialization

  // TMR3_Start
  TimerP_start(gTimerBaseAddr[CONFIG_TIMER3]);

  TaskP_Params stTaskParams;

  // create its semaphore for task
  SemaphoreP_constructBinary(&gv_stObjectSem, 0);

  // create task
  TaskP_Params_init(&stTaskParams);
  stTaskParams.name = "Task1";
  stTaskParams.stackSize = 122880;
  stTaskParams.stack = (uint8_t*)gv_TaskStack;
  stTaskParams.priority = 26;
  stTaskParams.taskMain = (TaskP_FxnMain)Task1;
  TaskP_construct(&gv_stTaskObj, &stTaskParams);

  // If the timer is started here, the output period of the ADC module will be unstable
  // TimerP_start(gTimerBaseAddr[CONFIG_TIMER3]);

}

void ISR_TIMER3(void) {
  SemaphoreP_post(&gv_stObjectSem);
}

// Callback to call when interrupt is received

void TimerP_isr3(void *args)
{
  void ISR_TIMER3(void *args);

  ISR_TIMER3(args);
  TimerP_clearOverflowInt(gTimerBaseAddr[CONFIG_TIMER3]);
  HwiP_clearInt(CONFIG_TIMER3_INT_NUM);
}


void Task1(void *pvdArgs) {

  SemaphoreP_pend(&gv_stObjectSemCNC, SystemP_WAIT_FOREVER);

  DAC_Output(0, 49152); // The DAC module outputs a voltage of 5V

  ClockP_usleep(200);

  DAC_Output(0, 32767); // The DAC module outputs a voltage of 0V

}

  • Hello Wang Tong,

    I am working through this. Expect me to reply in one or two days.

    I appreciate your patience !

    Kind Regards,

    Anastas Yordanov

  • Hi Wang Tong,

    I suppose you use an external DAC. A DAC peripheral is not available in the AM2434 according to the SoC documentation.

    1. Which hardware interface does the AM2434 use to communicate with the external DAC ?

    I am looking at the Task1 code and as a hardware application engineer try to understand the hardware behavior according to the waveforms you obtained:

    2. I think 200 us rising time to reach from 0V to 5V, would be too slow a settling time for a DAC output.

    And I referred this example thread on some typical DAC output settling time: 

    DAC output parameters example

    I see no flat 5V segment visible in the output curve. It seems to me that you either have some filter capacitor attached at the DAC output or you placed the probe at another circuit point different than the DAC output. Can you clarify ?

    3. Would it be possible to provide a schematic of your measurement setup ?

    Regarding your main concern, I can see the Timer 3 generated period (duration from DAC output at 0V through the next time DAC output starts from 0V) is approximately 1 ms.  On the second waveform I can see it varies +-200 us in length, as per your concerns.

    4. Is your application running under freeRTOS or some other RTOS ? Please specify the RTOS and the version you are using.

    I am asking because this thread tag OS is "FreeRTOS" but  I don't see a direct xTaskCreate invokation. Even the task creation call is  wrapped by your TaskP_construct function I am also concerned that I don't see vTaskStartScheduler() invokation near the end of your main function.

    In case your RTOS is freeRTOS:

    As per my basic experience with freeRTOS and the SDK provided examples, calling vTaskStartScheduler() with some error check, at the end of your main() function would insure that Task 3 execution is started by the scheduler after Timer 3 was started  regardless of the order in which you invoke the TimerP_start(), before or after the Task 1 creation. Can you check at which point is  vTaskStartScheduler() called 

    Based on your answers, if there are no hardware concerns, I will forward the thread to the software team for analysis.

    Thanks

    Kind Regards,

    Anastas Yordanov