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.

Multiple interrupts from multiple comparators?

Other Parts Discussed in Thread: MSP430G2553, LP339

Hello, I'm new to the MSP430 and am currently getting my head round the documentation. I am keen on implementing a member of the MSP430G2xx3 value line for my low-cost, low-power application and I am trying to determine whether I can use it's native comparators and interrupts for my needs. I would be very grateful for any help in confirming/refuting my thoughts on the matter below, and any further advice about how I might go about this.

I have 8 analog signals and a single mid-point reference voltage that I want to use to split each analog signal into either a HIGH or LOW signal. From the datasheet of the MSP430G2553, I gather that that HIGH/LOW threshold is pretty blurry. The analog signals in question will usually hover fairly close to the reference voltage so simply using digital inputs is out of the question.

No matter, that's what comparators are for right? I see that the MSP430G2xx3 line has a comparator that can be cycled through up to 8 different analog inputs. A quick calc of the minimum sample-and-hold time for each sample looks like the effective response checks out ok; so far so good.

My question is: is the cycling through each channel and sampling handled "peripherally" or does each step need to be instructed from software? Hoping for the former, and if so - can I assign interrupts to each channel?

The following sentence on page 528 (21.2.7) in SLAU144J (MSP430x2xx Family User Guide) reads like bad news to me: "One interrupt flag and one interrupt vector are associated with the Comparator_A+"

I would ideally like to be able to parse the 8 binary-converted analog signals into a single 8-bit variable using nothing but interrupt routines, so that I can have the main program focus on processing changes when they happen, and enter a low-power-mode. If it is confirmed that my desired implementation of the native comparator cannot be done, does anyone have any suggestions for an external 8-channel, low-power, low-cost comparator that I might use to carry out the binary conversion? Then presumably I can just send the output of that comparator into digital ports and trigger the interrupts from there.

Alternatively, does anyone know of any relatively low-cost microcontrollers that have particularly well-defined HIGH/LOW thresholds on their digital input ports?

Thanks!

  • It doesn't work like that. You get a single output bit / IRQ from the comparator.

    You would have to cycle through the inputs, wait for settling, and check the comparator output manually in software, bit by bit.

    Have you considered one of the "newer" MSP430's with ADC12? There you can have it automatically cycle through all channels, sampling/converting and then storing the samples into the multibyte sample memory. You configure it to run through all channels and interrupt you at the end. In your IRQ you loop 8 times to read the sample memory, compare, and add it to the correct bit location in your byte. Check SLAU208 for more details.
  • Hi Brian,

    Thanks for the suggestion. That could fit the bill nicely. No external parts, simple, etc.

    That said, I'd be a little concerned about power consumption. I have a feeling I'd need to use a fairly high-frequency clock in order to ensure that the ADCs and the triggered ISRs work fast (and reliably) enough to correctly identify three consecutive (HIGH/LOW/HIGH) edges in a row. So that rules out letting the ADCs cycle on a lazy low-power clock in the background. Presumably if you keep the DCO running full tilt then the current consumption in LPM0 isn't much lower than in active mode? Unless I used an external crystal perhaps?

    I realise it all depends on what that clock speed needs to be in order to get the necessary sampling resolution, which I suspect will be a bit of a trial and error approach. But I get the feeling I could easily end up with a constant current consumption of 1-3mA!

    On the other hand if I impemented a couple of 4-channel comparators (such as the LP339, $0.18/each), that might consume a little bit of extra current (not clear if it's 60uA per channel, or 60uA per chip), but a result I could really let the MCU go into a deep low-power mode between interrupts.

    What's really attracting me to the MSP430 range is it's low-power (with low-cost) capability, and so it feels that looping the ADCs as you suggest, whilst a nice simple solution, would not be taking advantage of this capability.

    But - as I said in my first post - I'm still getting my head round the MSP430 documentation, so it's possible I've made some incorrect assumptions here?

**Attention** This is a public forum