Can msp430afe253 generate PWM and measure external input 0-2khz frequency signal at the same time?
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.
Can msp430afe253 generate PWM and measure external input 0-2khz frequency signal at the same time?
Probably. It has only one timer, so you'll have some restrictions.
TA0 has two CCRs (don't count CCR0) so one can be used for PWM and the other for Capture (to measure frequency). It looks like only TA1 (CCI1) can be used for Capture, so you'll need to do the PWM with TA2 [Ref data sheet (SLAS701B) Tables 6-9 and 6-13].
They'll be working with a common time base. If you use hardware PWM, your Capture time range will be limited to your PWM period. This may or may not get in your way, but if you really need to measure very low frequency your PWM period will become unworkably long.
Alternatively, you can employ some software "help" to get "mostly-hardware" PWM, though this is not trivial.
This device wouldn't be my first choice for this application, but (if that's all you have) you may be able to use it.
I want to generate a pulse width adjustable PWM of 300Hz and accurately measure the external pulse of 0-2khz. Is 253 easy to realize?
The 300 Hz PWM also needs to be very accurate, because it outputs the analog voltage
Using hardware PWM at 300Hz, your frequency-measurement lower bound will be limited to >300Hz, since that's how fast the timer itself is cycling.
I'm not sure I understand the reference to "253". Is 253Hz your intended lower measurement bound?
As I was typing, it occurred to me that you could measure a 50% duty cycle signal as low as 150Hz by capturing both edges and adding the (consecutive) differences together. Any deviation from 50% would make one phase longer and increase that lower bound. This is a bit of a shaky premise unless you know quite a lot about your signal.
**Attention** This is a public forum