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.

tms570 how to capture frequency using PCNT problem

Other Parts Discussed in Thread: TMS570LS3137, HALCOGEN

Hi,

I am using TMS570LS3137 FREERTOS  to capture the different frequencies in different N2HET pins that value displayed on Hyperterminal within one task, 

below i explained wat i did in HALCOGen for this

In HALCOGen

1. disable the all drivers and enable only SCI2 and HET1 driver.

2.  Select the LINE1 High and HET Low in interrupt assignment.

3. Select the baudrate , tx tx interrupt in SCI2.

4. select the pin numbers in HET1 capture0-7 block.

5. generate the code 

In CCS

1. create the task, initialize the SCI and HET.

2. capture the freaquency value by using below function

hetSIGNAL_t capGetSignal(hetRAMBASE_t * hetRAM, uint32_t cap);

Probelms:

Here SCI is working fine but wen i use capture function return value duty is 0xFFFFFFFF. if i change the frequency also getting same. 

I am new to this MCU please help me what i need to do measure the frequency

Regards,

chethan kumar

  • I guess you're already calling hetInit() before calling capGetSignal(). Please check the following .

    1) Is the pinmuxing correct ? Go to PINMUX tab and select HET1. (This should not be the problem but better check)

    2) Are you getting the correct period value? Only the duty value is wrong?

    3) Which version of Halcogen are you using?

  • Hello,

    Thank you for your response. 

    my code process like this

     hetSIGNAL_t  Capture0,Capture1,Capture2,Capture3;  

    vtask1(void *pvParameters)

            sciInit();
            hetInit();

           for(;;)

           {

                     Capture0 = capGetSignal(hetRAM1,cap0);

                     Capture1 = capGetSignal(hetRAM1,cap1);

                    Capture2 = capGetSignal(hetRAM1,cap2);

                    Capture3 = capGetSignal(hetRAM1,cap3);

            }

    }

    Here cap0 = NHET16, cap1 = NHET17, cap2 = NHET18, cap0 = NHET19 are usable pins, i am trying to capture 4 channel frequency continuously  and i am not using HR share here.

    1. I didnt select HET1 in pinmuxing.

    2. still i wont get period and duty of external frequency.

    3. i am using Halcogen v3.02.

    is this correct or not, if not what is the procedure please tell me.

    Regards,

    Chethan kumar

  • Hi Chetan,

    Thanks for sharing the code. Here are my comments.

    1) Enable HET1 in PINMUX (to be safe)

    2) Change the Pins you use. Use NHET16,18,20,22 and enable HRSHARE on all of them. The reason is that in the HALCoGen code, the pins used as channel Cap0 will be n and n+1( so in your case, 16 and 17 will be used by Cap0). But pin n+1 is being used again in your code(for Cap1 which will use 17 and 18 and so on). This could be the problem.

    3) Try updating to the latest version of HALCoGen(4.02.00) since it will be difficult to debug from an old version.

    4) What is the expected frequency of the input pwm signal?

     

  • Hello vineeth,

    Thanks for your suggestion, I have little bit confusion

    1. First initialize HET after that use getcapture function is it right.....?

    2. I have Halcogen version 4.02 and ccs 6.0 but is use this IDE for this MCU it will show link command error shall I get why it is happening.....?

    Thanks and Regards,

    Chethan kumar

  • Just a quick note from having used the capGetSignal fn myself...The first time you read from it for a particular pin it will return garbage data, so do a set of reads at initialization before you actually want to use the values and ignore the results.

     

    Dave

  • Hi Chethan,

    1) Yes. Your current sequence of the HET functions is correct.

    2) You should probably start a new thread for this issue.

    You should try what has suggested above. Also, did you try changing the pins like I suggested earlier? What were the results?

  • Hi Chethan,

     

    I also noticed that you have other threads open with questions relating to HALCoGen v3.02. t would be difficult to provide support with an older version. Most of your questions may get solved if you can move to the current version. Try doing that first. If you're having trouble with linking, you can start a new thread for the issue.


    Thanks and Regards,

    Vineeth

     

  • Hello Vineeth,

    Thank you for your suggestions, now it is working,
    As per your suggestions now i tried to start with new version CCS and HALCogen. Here what i did in older version same thing i did but frequency is not capturing but same code work in loder version.

    Older Version:
    CCS v5.0 and HALCogen v3.02

    New Version:
    CCS v6.02 and HALCOgen v4.02

    Here HR clock and prescale will be change.
    is there any changes

    Regards,
    Chethan kumar
  • Hi Chethan,
    I'm glad it's working. The change in HR clock and prescale should not be a problem. Since you have started another thread for the issue, you can close this thread by marking it as answered.
    Regards,Vineeth