This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Frequency measurement with XC161 chip

Hi

Since I have been asked to develop code to measure the frequency using XC161 microcontroller. Frankly I don't have any idea of implementing it.

However so far I have used the ADC to sample the sine wave of low frequency. Should I use compare and capture module in order to detect the rising edge? (Unless Im talking ***)

Your help would be greatly appreicated.

AJ

  • You have many choices and it would depend on what hardware resources are still available. Given any choice, I would probably use one of the general purpose timers. For example, use GPT2, T5 to capture the period with automatic clearing of T5. It assumes you have the signal connected to the CAPIN pin. I will also assume that the signal you are measuring does not violate any parameter listed in the datasheet.

    However, I don't have any idea of what you are doing or what you need to accomplish. I would prefer to help you with a problem and not just a solution.

    You should be able to use the manual in conjunction with DAVE to create the code.

    Please give it a try and then if you have problems getting it to work, ask your questions. I would be more than happy to help you as long as you put effort into it.

    -Chris

  • Hi Chris

    Thank you for dropping some hints. I am now famaliar with DAVE software and it is quite useful.

    Basically my signal (sine wave) is connected to AN channel 1 so that my microcontroller sample data 25us. This is where I am currently struck at the moment.

    Frequency measurement is completely new subject to me. In the meantime Im still learning to use XC161's various modules. I admit it is the powerful microcontroller that I have ever worked with.

    I am still thinking of the suitable method to measure the frequency at the moment.

    AJ

  • forget the a/d stuff, just (if needed) square the pulse and feed it to a timer if fast, an interrupt of slow.

    Erik

  • What is the expected frequency range that you are trying to measure? How accurate do you have to be with the measurement?

    AN1 is not connected to an alternate function so are you thinking of a purely software method to do it?

    From your hardware is it possible to connect it in parallel (or buffered) to another port pin of the XC161?