EmbeddedRelated.com
Forums

SD24 to sample a resistive bridge with pulsed bridge supply

Started by "Mat...@pentax.boerde.de [msp430]" September 9, 2015
Hi,

I want to use the SD24 (24 bit ADC in the MSP430AFE2x3) to sample a resistive
strain gauge bridge (load cell) with 350ohms directly. This is no rocket
science in case the bridge supply is at a DC reference voltage. But I want to
save power! The bridge supply is power hungry (2.5V at 350 ohms).
My idea is to pulse the bridge supply e.g. 10 times per second (the load is
stable) and sample it with the adc24 10 times per second.
I want to get a load resolution of at least 12 bits.
(bridge sensivity is 2mV/V, in case of a 2.5V supply I have 1uV for the LSB)

I have not worked with the ad24 yet. Will this approach save power? From the
datasheet I see that the reference needs at least 5ms turn on time.
But in case I use the ratiometric concept (ADC-reference = bridge supply), I
do not need the reference at all.
How low can I get the supply current? How long does it take for the AD24 to
take a sample? (I do not see any timings in the datasheet?)

Or should I go a different way (e.g. sample and hold circuit in front of high
impedance low power OPV-instrumenation amplifier) and then I use the 12bit
ADC to sample it.

Any of your ideas are valuable for me.

Thanks!
Matthias


Posted by: Matthias Weingart




Beginning Microcontrollers with the MSP430

I apologize for top posting, but in this case I don't want to
address specific points below but instead "just talk." Keep
in mind I'm more of a hobbyist here. But perhaps something I
say may help a little, just the same.

First off, the idea of periodically powering the bridge is
probably a good idea. So you are on the right track here.
However, I don't think sigma-delta converters are the right
approach when combined with the idea of powering and
unpowering the bridge circuit. So, if you can change to a SAR
type ADC, for example, that might help a lot in simplifying
what you do.

A 16-bit SAR would be nice and I've used one that was on a
SiLabs which could run quite fast, but the analog section is
over-kill for your needs (though the C8051 core probably
isn't over-kill.) I don't know of an MSP430 with a 16-bit SAR
on it. But there are 12-bit ones. You could plan your noise
level to give you about 10 bits and then over-sample enough
to make sure you get a good 12 bits. Your 10Hz rate wouldn't
be at all hard to achieve.

The 350 ohm impedance you are talking about is "normal" for
strain gauges. Typically, I seem to recall, you get about 1mV
to 3mV of output per drive-volt on the bridge. The first
thing that came to mind was to run the bridge on a low supply
rail. But at 1V of drive, you're still talking about 3mA of
supply current. Dropping that to 0.1V brings the current down
into "reasonable" but then you will have trouble with
accuracy and precision. So I think this is why your thoughts
about short, powered samples is the correct approach. I just
don't think that goes well with sigma-delta.

Use a standard differential amplifier arrangement (3 op-amps)
and set up a three-terminal regulator with a BJT (or two)
that you use to enable its output into the bridge. This way
you can have a precision supply rail that you easily control
and can actively turn off when you don't need it. That supply
will supply your bridge AND your opamps. You'll have to work
out the setup time before sampling starts. Also, you might
want to consider using a CD4016 switch that is constantly
powered to gate the final amp output to your micro input. I'd
expect something less than 150 microamps (regulator, mostly)
as achievable for the OFF current compliance figure. ON, of
course, will be lots more.

You can look up ideas with google using "sampled strain gauge
signal conditioner" and see where that takes you. I'd avoid
the sigma-delta for a pulse-powered bridge, though. But
perhaps you can get enough experimental data from that one to
see if you can make it work okay. I've never attempted it so
I really don't have any experience to draw on, regarding real
results. I just avoid them when I know I will be powering up
and powering down an analog input system or using an analog
input multiplexer. (They generally "don't like" switched
inputs as it takes them time to "re-acquire" an input without
mixing it up into a mush from the other states the input goes
though.)

Jon
On Wed, 9 Sep 2015 10:10:11 +0000 (UTC), you wrote:

>I want to use the SD24 (24 bit ADC in the MSP430AFE2x3) to sample a resistive
>strain gauge bridge (load cell) with 350ohms directly. This is no rocket
>science in case the bridge supply is at a DC reference voltage. But I want to
>save power! The bridge supply is power hungry (2.5V at 350 ohms).
>My idea is to pulse the bridge supply e.g. 10 times per second (the load is
>stable) and sample it with the adc24 10 times per second.
>I want to get a load resolution of at least 12 bits.
>(bridge sensivity is 2mV/V, in case of a 2.5V supply I have 1uV for the LSB)
>
>I have not worked with the ad24 yet. Will this approach save power? From the
>datasheet I see that the reference needs at least 5ms turn on time.
>But in case I use the ratiometric concept (ADC-reference = bridge supply), I
>do not need the reference at all.
>How low can I get the supply current? How long does it take for the AD24 to
>take a sample? (I do not see any timings in the datasheet?)
>
>Or should I go a different way (e.g. sample and hold circuit in front of high
>impedance low power OPV-instrumenation amplifier) and then I use the 12bit
>ADC to sample it.
>
>Any of your ideas are valuable for me.
>
>Thanks!
>Matthias

Posted by: Jon Kirwan




"Jon Kirwan j...@infinitefactors.org [msp430]" :

> You can look up ideas with google using "sampled strain gauge
> signal conditioner" and see where that takes you. I'd avoid
> the sigma-delta for a pulse-powered bridge, though. But
> perhaps you can get enough experimental data from that one to
> see if you can make it work okay. I've never attempted it so
> I really don't have any experience to draw on, regarding real
> results. I just avoid them when I know I will be powering up
> and powering down an analog input system or using an analog
> input multiplexer. (They generally "don't like" switched
> inputs as it takes them time to "re-acquire" an input without
> mixing it up into a mush from the other states the input goes
> though.)

Jon, thank you for your idea's.

Isn't it possible to just "pause" the sampling of the delta sigma converter
(let it sleeping, all registers keep their values) and awake it after 100ms
with nearly the same input level as before the sleep? The sd24_a input is
just a 18pF capacitor. The 350ohms will charge it quickly...
Sure, I have to clock the adc as long as it is required to step the new
reading completely through the full decimation filter.

The PIR example from texas instrument slaa283 is quite interesting,
It uses the sd16 to sample a big capacitor behind the PIR sensor. It is
sampling the input for 1ms (4 samples each time) and sleep for 341ms. It
seems interrupted sampling is possible with delta sigma too.
To further reduce power consumtion they also switch the reference voltage
off during sleep. It seems that the charge in the capacitor at the ref-pin
will stay - accurate enough for this application - at ref-level for 341ms.

https://www.olimex.com/Products/MSP430/Starter/MSP430-
PIR/resources/slaa283.pdf

Matthias


Posted by: Matthias Weingart




On Sun, 13 Sep 2015 23:08:19 +0000 (UTC), you wrote:

>"Jon Kirwan j...@infinitefactors.org [msp430]" :
>
>> You can look up ideas with google using "sampled strain gauge
>> signal conditioner" and see where that takes you. I'd avoid
>> the sigma-delta for a pulse-powered bridge, though. But
>> perhaps you can get enough experimental data from that one to
>> see if you can make it work okay. I've never attempted it so
>> I really don't have any experience to draw on, regarding real
>> results. I just avoid them when I know I will be powering up
>> and powering down an analog input system or using an analog
>> input multiplexer. (They generally "don't like" switched
>> inputs as it takes them time to "re-acquire" an input without
>> mixing it up into a mush from the other states the input goes
>> though.)
>
>Jon, thank you for your idea's.

Well, don't thank me too quickly. I haven't helped at all.
Just offered a few of my mostly ignorant thoughts.

>Isn't it possible to just "pause" the sampling of the delta sigma converter
>(let it sleeping, all registers keep their values) and awake it after 100ms
>with nearly the same input level as before the sleep?

I haven't seen one work like that. They are basically very
fast "1 bit" converters with a lot of state behind it. It
takes a long time for those "bits" to fill the state. Once
you get the pipeline filled up, you can get very precise
values at a fairly reasonable rate.... if it is still
attached to the same input which is "drifting" around the
nominal value at less than some specified rate. But the
sample rate is based upon an ALREADY FILLED pipeline. You
have to fill it before the first value is really any good.
You can find out how long it takes to fill the state and, in
my limited experience, that will take a LOT LONGER than the
specified sample rate for the unit.

Whether or not you are able to stop the filling process on a
dime is another question. I haven't spent the time on the
MSP430 24 bit sigma-delta module. Nor have I tested it. So I
can't offer any experience there. Perhaps if you shut down
the module, then shut off the power to the bridge, and before
starting the module back up again first re-power the bridge,
you might be okay. But one problem of several that comes to
mind is that the bridge value may have drifted too far away
from its earlier value and may require, therefore, a complete
"refill" in order to re-acquire the ADC value. Even with all
that. So you'd need to explore this, I think. The counter to
what I just wrote is that you aren't looking for 24 bits or
21 bits or even 16 bits... but more like 12? So.... maybe.

>The sd24_a input is
>just a 18pF capacitor. The 350ohms will charge it quickly...

Hehe. That's true. Have you computed your expected S/N for
the analog portion of the input system, yet? Just curious.

>Sure, I have to clock the adc as long as it is required to step the new
>reading completely through the full decimation filter.
>
>The PIR example from texas instrument slaa283 is quite interesting,
>It uses the sd16 to sample a big capacitor behind the PIR sensor. It is
>sampling the input for 1ms (4 samples each time) and sleep for 341ms. It
>seems interrupted sampling is possible with delta sigma too.

I've just used the ADC10 and ADC12 sections, never the SD16
section. But yes, if you find some good examples there then I
think that you may be able to cross-apply them to your case.
Again... test things out. But perhaps it will work out fine.

>To further reduce power consumtion they also switch the reference voltage
>off during sleep. It seems that the charge in the capacitor at the ref-pin
>will stay - accurate enough for this application - at ref-level for 341ms.
>
>https://www.olimex.com/Products/MSP430/Starter/MSP430-
>PIR/resources/slaa283.pdf

Yes. To save power you should switch off everything you can
think of and handle. That's a given.

I'm interested in what you find out. I think you already have
figured out enough to take a fair shot at it. Sounds like you
may be able to do just fine. [Personally? I'd have preferred
to use an ADC12 or ADC10 section and use over sampling to
achieve the desired resolution... after making sure that my
noise is where it needs to be (for an ADC12 the noise should
be about 1000 ppm or so, I think, and for an ADC10 perhaps
5000 ppm; then use averaging to squeeze back down.)]

Jon

Posted by: Jon Kirwan




"Jon Kirwan j...@infinitefactors.org [msp430]" :

> On Sun, 13 Sep 2015 23:08:19 +0000 (UTC), you wrote:

>>Isn't it possible to just "pause" the sampling of the delta sigma
>>converter (let it sleeping, all registers keep their values) and awake
>>it after 100ms with nearly the same input level as before the sleep?
>
> I haven't seen one work like that. They are basically very
> fast "1 bit" converters with a lot of state behind it. It
> takes a long time for those "bits" to fill the state. Once
> you get the pipeline filled up, you can get very precise
> values at a fairly reasonable rate.... if it is still
> attached to the same input which is "drifting" around the
> nominal value at less than some specified rate. But the
> sample rate is based upon an ALREADY FILLED pipeline. You
> have to fill it before the first value is really any good.
> You can find out how long it takes to fill the state and, in
> my limited experience, that will take a LOT LONGER than the
> specified sample rate for the unit.

The question is: how does the decimation filter work. In case it is working
like a FIR, then it should be filled after a fixed time and I should ne able
to find out, how long it take, in case it is a IIR, well then the fill-time
is not really fixed....

>>The sd24_a input is
>>just a 18pF capacitor. The 350ohms will charge it quickly...
>
> Hehe. That's true. Have you computed your expected S/N for
> the analog portion of the input system, yet? Just curious.

No, not yet. :-) Maybe the noise from the resistors will be quite large and I
have to add additinal capacitance to get it lower? I am not experienced with
calculating noise figures, but surpricingly according to

https://en.wikipedia.org/wiki/Johnson%E2%80%93Nyquist_noise

it seems the noise in a RC system does not depend from R, just
from C, and with 18pF it is 15uV/sqrt(Hz) and at 100nF it is at
0.2uV/sqrt(Hz), and it takes (7*tau) 250us to stabilize.
I am at 10Hz sample rate, so I think I do not have to add a sample and hold
circuit to further reduce this time and increase accuracy..

> I'm interested in what you find out. I think you already have
> figured out enough to take a fair shot at it. Sounds like you
> may be able to do just fine. [Personally? I'd have preferred
> to use an ADC12 or ADC10 section and use over sampling to
> achieve the desired resolution... after making sure that my
> noise is where it needs to be (for an ADC12 the noise should
> be about 1000 ppm or so, I think, and for an ADC10 perhaps
> 5000 ppm; then use averaging to squeeze back down.)]

I will give it a try; on last week I was still in the "find out how" phase of
the project, now it is getting more and more out of the dust, it is nice to
share ideas with you. :-)

Matthias


Posted by: Matthias Weingart




On Mon, 14 Sep 2015 07:21:42 +0000 (UTC), you wrote:

>"Jon Kirwan j...@infinitefactors.org [msp430]" :
>
>> On Sun, 13 Sep 2015 23:08:19 +0000 (UTC), you wrote:
>
>>>Isn't it possible to just "pause" the sampling of the delta sigma
>>>converter (let it sleeping, all registers keep their values) and awake
>>>it after 100ms with nearly the same input level as before the sleep?
>>
>> I haven't seen one work like that. They are basically very
>> fast "1 bit" converters with a lot of state behind it. It
>> takes a long time for those "bits" to fill the state. Once
>> you get the pipeline filled up, you can get very precise
>> values at a fairly reasonable rate.... if it is still
>> attached to the same input which is "drifting" around the
>> nominal value at less than some specified rate. But the
>> sample rate is based upon an ALREADY FILLED pipeline. You
>> have to fill it before the first value is really any good.
>> You can find out how long it takes to fill the state and, in
>> my limited experience, that will take a LOT LONGER than the
>> specified sample rate for the unit.
>
>The question is: how does the decimation filter work. In case it is working
>like a FIR, then it should be filled after a fixed time and I should ne able
>to find out, how long it take, in case it is a IIR, well then the fill-time
>is not really fixed....

It's NOT an IIR. I don't know the details, because I haven't
taken the time to do more than read the occasional discussion
from manufacturers. But I do know that it is more like an FIR
+ some stuff that "shapes the noise" where possible to push
it into higher frequencies, so that it can be nicely cut off
in the digital filters.

It is this "noise shaping part" that I feel is a uniquely
added concept to an FIR. So it's not exactly an FIR, as I
ignorantly see it. I believe some smart person worked out a
method, looking over the 1-bit converter process, that could
help push the shape of the normal distribution of noise so
that it's a somewhat distorted distribution. But as I said,
I'm ignorant about the details.

>>>The sd24_a input is
>>>just a 18pF capacitor. The 350ohms will charge it quickly...
>>
>> Hehe. That's true. Have you computed your expected S/N for
>> the analog portion of the input system, yet? Just curious.
>
>No, not yet. :-) Maybe the noise from the resistors will be quite large and I
>have to add additinal capacitance to get it lower? I am not experienced with
>calculating noise figures, but surpricingly according to
>
>https://en.wikipedia.org/wiki/Johnson%E2%80%93Nyquist_noise

The following has almost nothing to do with the question at
hand, but I thought it would be worth writing out what I
understand of some basics, first.

There is a treatment of noise issues from resistors and
capacitors -- both are based upon the fundamental idea of
assuming an equipartion of thermal energy, 1/2 kT per
available vibrational mode (almost always a valid
assumption.)

Thermal noise is also "Johnson noise" in the early
literature, but as a hobbyist perspective I think Johnson
noise has become associated with resistor noise today.
Capacitor noise, though technically based on the same
mechanism but with a different resulting algebraic equation,
might also be called Johnson noise. But most reading I've
done doesn't use Johnson noise for that.

The electromotive force developed across the ends of a
conductor due to Thermal noise is unaected by the presence
or absence of direct current. Electron thermal velocities in
a conductor are much greater than electron drift velocities
by a factor of a 1000 or more. This means you don't worry
about current noise, as something inherent in the current,
unless it crosses a PN junction (diode.) If it does, because
this affects the above relationship of thermal vs drift
velocities, you get "shot noise" and you have to take it into
account. To add things, though, you have to put apples to
apples -- so it needs to be converted to an equivalent
voltage noise first or else visa versa.

There is also flicker noise. This in resistors depends on
manufacturing. But there is flicker noise in the base
junction of BJTs, FETs, and so on. In BJTs, flicker noise is
said to increase a lot if the BE junction is subjected to
repeated breakdown voltages (often, that value can be in the
area of 5-6V or so, which can easily happen in switcher
circuits where the base isn't well protected when turned
off.)

Back to the topic. Your input amplifier is responding to
voltage. So what you want is some kind of estimate of the
"equivalent voltage noise" as referred to the input (or you
could refer things to the output... but you don't control
what is attached there.)

I did a quick search. You might read this paper:

http://users.ece.gatech.edu/mleach/papers/AnalogNoise.pdf

Just get down into it a few pages and you'll see some
treatments there. I can't vouch for it, as I haven't read it,
but it seems to broadly cover the kind of analysis I was
wondering about.

The point here is that if you were using over-sampling to
achieve your 12-bit precision figure, then you'd want to set
your noise level (S/N) to about 2-3 bits WORSE than your ADC
specified precision. Noise tends to be Poison in nature,
which integrated looks like a Gaussian curve. And more
averaging of Poisson events narrows the skirts of the
Gaussian nicely, so averaging works in this case. But you
need noise to create that random walk process so that the
averaging can do its work. If you have too little noise,
averaging is pretty much useless in making things better.

So if you know in advance you will be averaging to improve
precision, you want to know that your noise is Poisson around
the "real value."

>it seems the noise in a RC system does not depend from R, just
>from C, and with 18pF it is 15uV/sqrt(Hz) and at 100nF it is at
>0.2uV/sqrt(Hz), and it takes (7*tau) 250us to stabilize.
>I am at 10Hz sample rate, so I think I do not have to add a sample and hold
>circuit to further reduce this time and increase accuracy..

In low pass filters, I think that is correct. (I don't recall
seeing an analysis for a high pass filter, so I'm reserving
judgment there.)

Because it is so "fast" with respect to your desired sample
rate, though, I think this is an argument for more filtering.
Here's my thinking.

You want a measurement period of 100ms. If you have a high
bandwidth input signal, it will move around a lot. This is
because everything is proportional to the square root of
bandwidth. A wider bandwidth means more probability at
distant skirts away from the real signal. And that is what
your ADC will be "seeing." (Now, again, none of this
necessarily applies to sigma-delta in quite the same way,
because of those "noise shaping" things they do that I don't
fully appreciate.) So without a sample and hold, you want as
much low pass filtering as you can get away with, consistent
with a fast enough response time that your input "settles"
before your next sample.

So, let's say you want your signal to settle to within 12
bits of precision between these 100ms samples. Let's say to
1/2 bit. With 12 bits, that's 1:8000, or so. Solving for
time, you want tau = 11ms. That is, if I got the calcs right:

tau = t / ln(8000) = 100ms / ln(8000) approx 11.1ms

Your tau is, therefore, too fast. Which means you are letting
in unnecessarily high noise.

But then, you are using a sigma-delta. So... I'm not sure how
that thinking should be modified.

>> I'm interested in what you find out. I think you already have
>> figured out enough to take a fair shot at it. Sounds like you
>> may be able to do just fine. [Personally? I'd have preferred
>> to use an ADC12 or ADC10 section and use over sampling to
>> achieve the desired resolution... after making sure that my
>> noise is where it needs to be (for an ADC12 the noise should
>> be about 1000 ppm or so, I think, and for an ADC10 perhaps
>> 5000 ppm; then use averaging to squeeze back down.)]
>
>I will give it a try; on last week I was still in the "find out how" phase of
>the project, now it is getting more and more out of the dust, it is nice to
>share ideas with you. :-)

Hehe. I'll learn, too. I probably said something (more than
one) stupid above and someone will correct me. Or you will.
And I'll gain a somewhat better understanding from that,
which is all to the good.

Jon

>
>Matthias
>
>
>Posted by: Matthias Weingart
>
>
>
>
I am using Tom Baugh's MSP430F2274 board and software in a class. We are also using IAR Kickstart.

In his second lab exercise, BetterNextProject, we see various timing interrupt methods and LPM3 to reduce the number of cycles and power consumed. Each time the LED output, P1.0, toggles due to a timer firing its interrupt, the SMCLK can be seen making a burst of 28 cycles of running in active mode. Analyzing the disassembly code and reading the Family User's Guide, I can only account for 24 cycles.

Here are the details:

Action/Instruction (in execution order) Cycles (from Tables 3-14 & 16 in the Family User's Guide)

Interrupt Accepted 6
008094 bic.w #0xF0, 0x0(SP) 5 // First line of WatchdogTimer_ISR. All low-power modes cleared.
00809A reti 5
008050 xor.b #0x1,&P1OUT 4 // Constant Generator register source to absolute destination.
// This toggles the LED.
008054 jmp 0x804C 2 // End of While Loop.

00804C bis.w #0xD8,SR 2 // Beginning of While Loop. Start LPM3. Instruction immediately
___ //before the XOR.
Total 24 cycles

When I monitor SMCLK on P2.1 on an oscilloscope, it idles high and has 28 falling edges. In addition, the LED toggles on the 22nd falling edge.

I count 24 cycles in the code, but measure 28 on the oscilloscope. (And I count 20 until the end of the instruction toggling the LED but measure it occurring on the 22nd falling edge.

So, what am I missing?

Thanks,

Emmett Redd Ph.D. mailto:E...@missouristate.edu
Professor (417)836-5221
Department of Physics, Astronomy, and Materials Science
Missouri State University Fax (417)836-6226
901 SOUTH NATIONAL Lab (417)836-3770
SPRINGFIELD, MO 65897 USA Dept (417)836-5131

In statesmanship get the formalities right, never mind about the moralities. -- Mark Twain.

Posted by: "Redd, Emmett R"




I know it makes sense that "xor.b #0x1,&P1OUT" should be 4
cycles, given the constant generator. But can you find the
specific statement in the Family Guide that mentions using
the constant generator, instead of an inline constant,
requires one less clock than it would if the constant were
say #0xDD?

I just looked at SLAA0024 on TI's web site, looking at a
table on page 9-24, section 9.3.1, and it looks to me like it
is still 5 cycles. If I'm reading this correctly, then that
is at least one tiny detail to start the process of
accounting for differences.

I haven't spent more than 10 minutes yet, though. Just a
quick scan and then dragging up the PDFs for a moment. The
other thing that crosses my mind is if there might be a few
SMCLKs involved after the LPM mode bits are changed to sleep
the CPU. Do you know if there is a paper around where
counting SMCLK cycles at a pin is addressed when going into
sleep, or coming out? I don't recall reading one, but perhaps
looking for one might also help resolve the question.

Meanwhile, if something else comes to mind I'll post it.

Jon

Posted by: Jon Kirwan




How is the xor.b #01,&p1out encoded? It would still potentially
disassemble correctly if it didn't use the register for the #01, but
would then require 3 words. As Jon says, that would still only recover 1
clock for you. I haven't tried this myself, so don't know what else
might be added but can you stop the process after the reti.? A break on
the xor.b might change the behaviour, if so, perhaps move the LPM3 start
instruction there and see what happens.

Al

On 18/09/2015 4:57 AM, 'Redd, Emmett R' E...@missouristate.edu
[msp430] wrote:
> I am using Tom Baugh's MSP430F2274 board and software in a class. We are also using IAR Kickstart.
>
> In his second lab exercise, BetterNextProject, we see various timing interrupt methods and LPM3 to reduce the number of cycles and power consumed. Each time the LED output, P1.0, toggles due to a timer firing its interrupt, the SMCLK can be seen making a burst of 28 cycles of running in active mode. Analyzing the disassembly code and reading the Family User's Guide, I can only account for 24 cycles.
>
> Here are the details:
>
> Action/Instruction (in execution order) Cycles (from Tables 3-14 & 16 in the Family User's Guide)
>
> Interrupt Accepted 6
> 008094 bic.w #0xF0, 0x0(SP) 5 // First line of WatchdogTimer_ISR. All low-power modes cleared.
> 00809A reti 5
> 008050 xor.b #0x1,&P1OUT 4 // Constant Generator register source to absolute destination.
> // This toggles the LED.
> 008054 jmp 0x804C 2 // End of While Loop.
>
> 00804C bis.w #0xD8,SR 2 // Beginning of While Loop. Start LPM3. Instruction immediately
> ___ //before the XOR.
> Total 24 cycles
>
> When I monitor SMCLK on P2.1 on an oscilloscope, it idles high and has 28 falling edges. In addition, the LED toggles on the 22nd falling edge.
>
> I count 24 cycles in the code, but measure 28 on the oscilloscope. (And I count 20 until the end of the instruction toggling the LED but measure it occurring on the 22nd falling edge.
>
> So, what am I missing?
>
> Thanks,
>
> Emmett Redd Ph.D. mailto:E...@missouristate.edu
> Professor (417)836-5221
> Department of Physics, Astronomy, and Materials Science
> Missouri State University Fax (417)836-6226
> 901 SOUTH NATIONAL Lab (417)836-3770
> SPRINGFIELD, MO 65897 USA Dept (417)836-5131
>
> In statesmanship get the formalities right, never mind about the moralities. -- Mark Twain.
>
> Posted by: "Redd, Emmett R"
>
>
>
> Yahoo Groups Links
Yes, the xor.b is encoded as two words (E3D2 0021) and this is consistent with Table 3-16 (to partially answer Jon's question)
Addressing Mode Length of

Src Dst No. of Cycles Length of Instruction Example

Rn &EDE 4 2 MOV R5,&EDE

versus

#N &EDE 5 3 ADD #33,&EDE
And to further address Jon's question the Family Guide has a list of advantages for using the constant generators:

The constant generator advantages are:

No special instructions required

No additional code word for the six constants

No code memory access required to retrieve the constant
The last one implies saving a cycle although it does not explicitly say so.

But, Jon's SLAA024 has this:
If the interrupt is requested during the low power modes 3 or 4, then additional two cycles are needed.
So that counts for 2 of the 4 missing cycles although it gives no further explanation. It would be easy to try the other low power modes and see what happens. The LED reference signal could also help determine when those 2 extra cycles happen.

Concerning stopping the process after the RETI, not clearing the low-power bits inside the ISR would do that.

So, I have a couple of things to try and a new (to me) document to read. I'll report back when I have some more details.

Thanks both of you for the help and pointers.

Emmett Redd Ph.D. mailto:E...@missouristate.edu
Professor (417)836-5221
Department of Physics, Astronomy, and Materials Science
Missouri State University Fax (417)836-6226
901 SOUTH NATIONAL Lab (417)836-3770
SPRINGFIELD, MO 65897 USA Dept (417)836-5131

In statesmanship get the formalities right, never mind about the moralities. -- Mark Twain.

________________________________
From: m... [m...]
Sent: Thursday, September 17, 2015 10:32 PM
To: m...
Subject: Re: [msp430] Cycle Counting--Too Many

How is the xor.b #01,&p1out encoded? It would still potentially disassemble correctly if it didn't use the register for the #01, but would then require 3 words. As Jon says, that would still only recover 1 clock for you. I haven't tried this myself, so don't know what else might be added but can you stop the process after the reti.? A break on the xor.b might change the behaviour, if so, perhaps move the LPM3 start instruction there and see what happens.

Al

On 18/09/2015 4:57 AM, 'Redd, Emmett R' E...@missouristate.edu [msp430] wrote:

I am using Tom Baugh's MSP430F2274 board and software in a class. We are also using IAR Kickstart.

In his second lab exercise, BetterNextProject, we see various timing interrupt methods and LPM3 to reduce the number of cycles and power consumed. Each time the LED output, P1.0, toggles due to a timer firing its interrupt, the SMCLK can be seen making a burst of 28 cycles of running in active mode. Analyzing the disassembly code and reading the Family User's Guide, I can only account for 24 cycles.

Here are the details:

Action/Instruction (in execution order) Cycles (from Tables 3-14 & 16 in the Family User's Guide)

Interrupt Accepted 6
008094 bic.w #0xF0, 0x0(SP) 5 // First line of WatchdogTimer_ISR. All low-power modes cleared.
00809A reti 5
008050 xor.b #0x1,&P1OUT 4 // Constant Generator register source to absolute destination.
// This toggles the LED.
008054 jmp 0x804C 2 // End of While Loop.

00804C bis.w #0xD8,SR 2 // Beginning of While Loop. Start LPM3. Instruction immediately
___ //before the XOR.
Total 24 cycles

When I monitor SMCLK on P2.1 on an oscilloscope, it idles high and has 28 falling edges. In addition, the LED toggles on the 22nd falling edge.

I count 24 cycles in the code, but measure 28 on the oscilloscope. (And I count 20 until the end of the instruction toggling the LED but measure it occurring on the 22nd falling edge.

So, what am I missing?

Thanks,

Emmett Redd Ph.D. mailto:E...@missouristate.edu
Professor (417)836-5221
Department of Physics, Astronomy, and Materials Science
Missouri State University Fax (417)836-6226
901 SOUTH NATIONAL Lab (417)836-3770
SPRINGFIELD, MO 65897 USA Dept (417)836-5131

In statesmanship get the formalities right, never mind about the moralities. -- Mark Twain.

Posted by: "Redd, Emmett R"





Yahoo Groups Links