SparkFun Forums 

Where electronics enthusiasts find answers.

Discussions on how to get your MSP JTAG programmer up and running.
By Guilherme
#61423
Hi everybody.

I am brazilian and my english isn't too good, but I want to learn how to work with MSP's. I was reading about MSP430F2012, and saw that this chip has two PWM channels.

I would like to know with is possible works with a counter and a PWM generator at the same time, with this MSP. If not, what MSP do you think is better?
By OldCow
#61444
Hi,

MSP430F2012 has a single Timer with two Capture/Compare channels. The simplest way to generate a PWM output this will use up both of the Capture/Compare channels and you cannot use them as a counter anymore. But there are other ways to implement PWM and counter.

What is the frequency and duty cycle resolution of the PWM you want? What is the max counting rate you want? What else do you want do with it? I may be able to help you. But without knowing your goal, it is hard for me to make any recommendation.

-- OCY
By Guilherme
#61466
Hi OldCow.

Well, my goal is to implement an ADC using a PWM and a filter. But while this PWM is working, I want a counter that don't stop his count. Do you understand?

A counter and, at the same time, a PWM. But the counter does not affect or control the PWM.


I did this with a PIC from Microchip, but now I am searching for autonomy.


Tks for the help
By OldCow
#61489
I understand your English. But I do not fully understand your technical requirements.

F2012 has a 10-bit ADC with 2.5V built-in reference. If you use single ended analog input, it has to be between 0V and 2.5V. If you use differential analog input, both A+ and A- has to be between 0V and Vcc (3.3V) and the difference has to be between 0 and 2.5V or between –1.25V and +1.25V. The analog inputs also need to have low impedance (see data sheet). The conversion time can be <4 micro-sec.

There is no DAC; the Timer inside F2012 can be used to generate PWM. You will need external low-pass filter to use PWM output as analog signal. If you need 10-bit resolution, the PWM frequency is lower than 16 kHz. Thus you DAC is much much slower than your ADC.

With both the ADC and PWM going, you can still use one or more of the port pins to count rising or falling edges of an external digital signals (0V/3.3V only). But you cannot use the Timer to count because it is already used for PWM generation. You need to use interrupts and software counters. Your counting rate will be limited to ~100 kHz.

The CPU of F2012 can also be used to do digital filtering for the ADC, but not for the DAC. Furthermore, there is no floating point hardware and the amount of Flash and RAM are very limited (2048 bytes and 256 bytes). I am not sure if you need to do digital filtering. It depends on the characteristics of you analog input.

Which PIC did you use before? MSP430F2012 uses 3.3V.
By Guilherme
#61574
If you use single ended analog input, it has to be between 0V and 2.5V.
Yes, this is the case. From a analog signal that get in the MSP, the programm will analyze and create a time limit to a counter and will modify the duty cycle of the PWM.

This analog signal of entrance is between 0V and 2.5V so, no problem with this

There is no DAC; the Timer inside F2012 can be used to generate PWM. You will need external low-pass filter to use PWM output as analog signal.
Exactly. This is the meannig of the PWM. Create an analog signal. (I think I typed wrong ADC instead of DAC, sorry)
But you cannot use the Timer to count because it is already used for PWM generation. You need to use interrupts and software counters.
I think this interrupts that you are talking about are the same at PIC and I liked very much your idea that is using an external interrupt to countdown. Excelent idea. I just have to put a Xtal conected on a pin.
Your counting rate will be limited to ~100 kHz.
That means what? That I just can use a frequency lower than 100 kHz, or that I just can use frequency higher than 100 kHz or just 100 kHz?
Which PIC did you use before? MSP430F2012 uses 3.3V.
I used PIC16F690. This PIC can use between 3.5 and 5.5V, but he use a lot of current. So this is the reason that I am studying the MSP
By OldCow
#61580
I did not ask what you use the counter for. What I had in mind was called an event counter. If no event is coming (that is, 0 Hz square wave), the counter remains unchanged. There is no problem for incoming frequency to be too low. But if the input changes too fast, the event counter may not be able to keep up with it. So usually there is an upper limit. If you use the Timer/Counter TA2 inside the F2012 chip, this upper limit is 8 MHz. If you use interrupt and software to implement an event counter, the upper limit is about 100 kHz. This means if an event comes in within 10 microsecond of the previous event, the software may not have Enoch time to count both of them.

What resets the counter? What starts the counting? What stops the counting? What reads the counter? What do you use the counter for?

I do not understand why would you use a counter to count a crystal oscillator. Are you saying that you need a crystal controlled clock?
By Guilherme
#61610
What resets the counter? What starts the counting? What stops the counting? What reads the counter? What do you use the counter for?
The counting starts when the hole circuit is turned on. The counting doesnt stop. Actually, this counter is a timer. When the timer counting is equal a time limit, which is the result of a math equation, the timer resets.


I think you did not understand my point yet. According to an analog signal of entrance, the program has to modify the duty cycle of the PWM and create a time limit for the timer. So, I don't need any event counter, unless these events be a clock signal to increment the timer, because you told me when the timer is beeing used to create a PWM, I cannot use as a timer too, can I? So, the problem that I have to solved is how can I make a PWM and a timer at the same time.

[/quote]
By OldCow
#61626
I misunderstood your need for a counter. I understand now.

When the TA2 module is used to generate a PWM output, it can also generate up to two independent interrupts. One at the beginning of the output pulse, the other one at the end of the output pulse. (Both will have the same period as the period of the PWM.) You can adjust the PWM duty cycle etc. inside the interrupt service routines.

There is also a WDT module that can also be used as a timer. It is less flexible.

Do you have the hardware yet? If not, I recommend the TI development kit. They call it eZ430-F2013. It has all the tools you need (to be used with your own Windows PC). It cost only $20 in USA. But the chip in this kid is a MSP430F2013, not F2012. You should also order their eZ430_T2012 at the same time. For $10, you get three fingernail sized boards each with a F2012. They can be plugged to the finger sized eZ430-F2013 and replace the F2013.

What documents do you have? The F2012 Datasheet and the F2xx Family User's Guide (slau144e.pdf) are both needed. Code examples are helpful too.

You can download KickStart (slac050t.zip) and start to write code and debug it with or without hardware.
By weglobal
#72120
Ola guilherme eu sou brasileiro e vivo nos Estado Unidos tenho acesso a material sobre MSP430 por favor me contact se voce necessita de algo e se posso lhe ajudar
marcelode@ymail.com