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.

TMS570LS1227: Configuring eCAP Module to capture lower frequencies

Part Number: TMS570LS1227
Other Parts Discussed in Thread: HALCOGEN

Hello,

As I mentioned above I am using Hercules TMS570LS1227 Microcontroller and would like to use the eCAP module to capture a signal generated by a Hall Effect Sensor.

I previously used the  eCAP etPWM example included in HALCoGen and it worked successfully, then I used the function generator to generate a PWM and the eCAP module successfully captured it. However, when I tried to capture the PWM signal coming from the Hall Effect Sensor, the eCAP module couldn't capture it.

I am currently using VCLK4 frequency at 80 MHz and no prescale settings.   

The example in HALCoGen works with frequency ranges of 200 KHz thru 5 MHz.

I need to measure the frequency of a much more slower signal coming from the Hall Effect Sensor that ranges between 1 Hz and 208 Hz. Is there a way to set up the eCAP to measure very slow frequencies?

Thanks,

Jesus Galindo

  • Hello Jesus,

    The ecap can be used to capture low frequency signal. Do you mean the ECAP won't detect the PWM edge (rising or falling)? Please make sure that the signal from the Hall sensor is correct? You can test the ecap with low frequency signal from the function generator.
  • Hello,

    Yes, when I connect the function generator probe to the eCAP pin in the MCU it detects falling and raising edges successfully as long as the frequency ranges from 200 KHz to 5 MHz. But when the output signal from the Hall Effect Sensor is connected to the eCAP (the signal from the Hall Effect Sensor ranges between 1 Hz and 209 Hz), it does not capture anything. I have also generated a function with 1.00 KHz and the eCAP does not capture it either. Is there a specific way I need to set up the eCAP module to capture low frequencies?


    Here is some code I am using (I got it from the HALCoGen example), maybe there is a mistake on the code and that is the reason why the eCAP does not capture lower frequencies. VCLK4 runs at 80 MHz.


    /* USER CODE BEGIN (4) */

    void ecapNotification(ecapBASE_t *ecap,uint16 flags){

    // while(ecapREG5 !=0) {

    uint32 cap1, cap2, cap3;
    float64 pulse, period, Duty_Cycle;
    cap1 = ecapGetCAP1(ecapREG5);
    cap2 = ecapGetCAP2(ecapREG5);
    cap3 = ecapGetCAP3(ecapREG5);
    pulse = (cap2 - cap1)*1000/VCLK4_FREQ; //times 1000
    period = (cap3 - cap1)*1000/VCLK4_FREQ; //VCLK4_FREQ
    Duty_Cycle = (pulse/period)*100; //(pulse/period)*100
    printf("Pulse = %fus\n", pulse);
    printf("Period = %fus\n\n", period);
    printf("Duty Cycle = %f\n", Duty_Cycle);
    //}

    }
    /* USER CODE END */
  • Hello Jesus,

    There is requirement of minimum width of the input pulse, but there is no limitation for maximum width. ECAP should work for low frequency pulse.

    Your code for calculating the period and duty cycle is correct. I think you use the same code for capturing high frequency pulse input.

    I want to make sure that you use the same ecap channel (ecap 5) for low frequency and high frequency. The output of the hall sensor is in the valid range: HIGH>2V, and LOW<0.8V.