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.

Use capGetSignal

Other Parts Discussed in Thread: HALCOGEN

Hi,

Hi, I am using CCS6, Halcogen v4 and the TMS 0332

I have an input pin that I want to read the period and duty cycle from.

 

I found a document (no date) titled "1512.NHET PWM generation and Capture using Halcogen.pdf"  (attached) that describes exactly what I want to do.  However, in Halcogen (v4) there is a note on the Cap 0-7 tab when you hover over the pin "Note HRShare must be enabled for Pin[x] and pin[x+1] using Port Config Tab to use 'capGetSignal' API.

 

So I am confused whether I can read the period and duty cycle through one pin or not?  I don't want to go down a road that won't get what I need.

 

 

6153.1512.NHET PWM generation and Capture using HALCoGen.pdf

  • David,


    Let me try to clarify.

    The document you are using is old, and a lot has to be changed to make it compatible with the current version of Halcogen.
    Here is the new main code to demonstrate the capGetSignal API.

    /* USER CODE BEGIN (1) */
    #include <stdio.h>
    #include "gio.h"
    #include "esm.h"
    #include "het.h"
    #include "dcc.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) */
    hetSIGNAL_t Duty_Period1,Duty_Period2,Duty_Period3,Duty_Period4 ;
    hetSIGNAL_t Set_Duty_Period1;
    /* USER CODE END */

    void main(void)
    {
    /* USER CODE BEGIN (3) */
        int i;
        gioInit();
        gioSetDirection(hetPORT1, 0xBFFFFFFF); // 30 Input, 10 Output
        gioSetBit(hetPORT1, 10, 1);
        while(gioGetBit(hetPORT1, 30) == 0);
        gioSetBit(hetPORT1, 10, 0);
        capGetSignal(hetRAM1,cap0,&Duty_Period1);
        hetInit();
        for(i=0;i<0x10000;i++); // Simple Delay
        capGetSignal(hetRAM1,cap0,&Duty_Period2);
        for(i=0;i<0x10000;i++); // Simple Delay
        capGetSignal(hetRAM1,cap0,&Duty_Period3);
        pwmStop(hetRAM1, pwm1);
        Set_Duty_Period1.duty = 75;
        Set_Duty_Period1.period = 2000;
        pwmSetSignal(hetRAM1, pwm1, Set_Duty_Period1);
        pwmStart(hetRAM1, pwm1);
        for(i=0;i<0x10000;i++); // Simple Delay
        capGetSignal(hetRAM1,cap0,&Duty_Period4);
        for(i=0;i<0x10000;i++); // Simple Delay
    /* USER CODE END */
    }

    The capGetsignal is used to return the Period and the Duty Cycle of an external signal.
    In order to perform this task using NHET, HR Share has to be used.
    What HR share is doing is, for 1 external signal on HET pin x, NHET will use 2 HR block to capture this signal.
    Block x and block x+1.

    In this example code, the NHET[10] is used to generate a PWM, and this signal has to be connected at the board level to NHET[30].
    Because we are using capGetSignal in this example, the HR ressources of NHET input 30 and 31 will be used.

    HR Sharing are always working on 2 adjacent pins (Even number and next one)

    The NHET[31] pin cannot be used for timing purposes anymore, but can still be controlled as a GIO pin.

    If you run this code, you should see the following results:

    Please let me know if I've clarified your question.

  • Thanks.  I think that clears it up. 

    I am using the 0332...in Halcogen under HET->Pin 0-7 in the HR Share block the selection is greyed out.  I just want to make sure with the setting it is on I can do what you have described.

     

    Thanks,

    David

  • David,

    On this device, you have only a subset of NHET pins, mainly the even number.
    For these pins, Halcogen is by default setting the HR share option and you cannot deselect from the GUI.


    For the pin with even and even+1, like NHET[18] and NHET[19], NHET[22] and NHET[23], NHET[28] and NHET[29], NHET[30] and NHET[31] this option is still available.