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.

eZ430-RF2500 Need to generate square waves

Hello everyone,

I am working on a project which requires me to generate squares waves from 10Hz to 10MHz using the eZ430-RF2500 MCU to do a sweep.  I have read and read and read through online sites and forums and I still have no idea where to start.  So far I know that I need to use some sort of timers and interrupt to achieve my goal.  However I do not know which pins on my controller I need to be output the square wave to and basically where to start.  If anyone can point me to the right place and resource I would greatly appreciate it.

  • The MSPs timers can generate PWM signals with their CCR units.
    A square wave is nothing more than a PWM signal with 50% duty cycle.

    Using the CCR0 unit, you can control the frequency.

    For details on timers and CCR units, see the timer section in the 2x family users guide.

    Now for the solutionm (or at least the basic approach) of your problem:

    Clock the timer with a base requency. Well, 20MHz aren't possible, The maximum port output frequency is 12MHz, but since the maximum frequency of this MSP is 16MHz, the maximum timer-generated frequency is 4MHz (with optional 8MHz)

    How to do it:

    Feed 16MHz into the timer. Let the timer run in up mode.
    Now program the CCR0 unit to set/reset mode and write 1 to CCR0 register. In this specific case, the TA.0 output will give 8MHz.
    For anything else, program CCR0 to toggle mode. With CCR0=1, this will give you 4MHz. (16MHz/ (2*(CCR0+1)).
    For CCR0=2, it gives you 2.66MHz, for CCR0=3 you'll get 2MHz etc. Down to 122Hz (with a resolution of 0.002Hz at this point). To go further down, you can use the tiemr predivider for an additional /2 or /4 divider, bringing you to 30Hz, and also an optional /2, /4 or /8 divider on the clock itself. So if the MSP is clocked by a 16MHz crystal (or a calibrated DCO setting of 16MHz, you can go from 3.8Hz to 8MHz. However, the higher the frequency, the bigger the steps.

    P.s.: forget about interrupts. At the higher frequencies, teh output frequency is in the range of the CPU clock. The maximum you can get using plain software is some 100 kHz. Unless you hardcode the complete sweep with hand-optimized assembly code. Then you can get up to ~4MHz. And probably create more code than the MSP can hold :)

**Attention** This is a public forum