Friday, August 14, 2009

Random MSP430 notes #1: Do not turn on the ADC twice

For my thesis, I use the ScatterWeb MSB430 sensor nodes which are driven by an MSP430 from Texas Instruments. I ran into a weird problem today after adding some code which I expected to have no effect at all. In fact, I just enabled the MSP430's ADC12 twice. What could possibly go wrong?

Ok, ok, I admit it's all in the user manual: The manual states that bits 15-3 of the ADC12CTL0 register may not be modified if conversions are enabled, i.e. if the ENC bit is set.
I found out -- the hard way -- if you modify the bits nevertheless, the conversions will actually stop! Since the ADC12ON bit is bit number 4, turning on the ADC12 twice will actually turn it off ...