Sign in to follow this  
Followers 0
USWaterRockets

MSP432 ADC14 Energia Strangeness

9 posts in this topic

I am having an issue with the ADC14 peripheral of the MSP432 on the MSP432 Launchpad using Energia.

 

Background: I've used "ordinary" Arduinos in the past to get things up and running quickly for test fixtures or one-off devices, but for MSP432 and most everything else I do I prefer Assembly and C languages. I thought I would try my hand at doing something in Energia, to see how it compared.

 

My test project was simply to characterize the ADC14 because it has decent resolution and that could be useful in other projects, so I started out with the basic AnalogReadSerial example and got it running.

 

The first thing I see is that it returns 10-bit results! Ok, so a little searching on this forum tells me that I need to use obscure/undocumented functions for the ADC14, and I need analogReadResolution(14); to make it 14-bit.

 

So, I tried that and so far so good, it works! I get 14-bit results, and the last bit is dithering as expected.

 

The next thing I notice is that the values are reading pretty much as one would expect, if a 3.3V reference was used. The schematic seems to show that the VREF+ is connected to the 3.3V supply, so this makes sense. However, I was planning on using the internal reference voltages because they more closely match my input range.

 

So, I search around and find that there are some other obscure functions that are used to set the reference voltage, so I use analogReference(INTERNAL2V5) in my code.

 

At first look, the results seemed to make sense, as I put in 1.65V and the value jumped up from 8135 (3.3V reference) to 11708 (2.5V reference), but when I calculated the expected value of 1.65V on a 2.5V scale, I get 10813, which is not even close to 11708.

 

It was then I noticed that the LSB of my reading is really not dithering at all, it's rock solid unless I change the input value.

 

I think something is going on with the ADC14 that I am not aware of. Perhaps it's being a n00b at Energia, but this seems strange.

 

Anyone have any ideas? Thanks!

 

 

 

 

 

 

 

 

Share this post


Link to post
Share on other sites

I'm looking at this a little more and it looks like the MSP432 Launchpad has the Veref+ and Veref- (external Vref) pins tied to the expansion connectors on the board edge, and they do not supply any kind of external reference on the board by default. Since the documentation seems to say that the ReadAnalog() function returns values from 0 to 1023 for 0V to ~3.0V (Vcc), and the MSP432 does not have an internal reference greater than 2.5V, I believe that the ReadAnalog() function is somehow scaling the readings so that the reported values would be consistent with the ReadAnalog() function documentation.

 

If so, this scaling may be interfering with the values I expect when I set the 2.5V reference as the ACD14 reference voltage.

Share this post


Link to post
Share on other sites

I am by no means an ADC expert and others might have a better answer but: take in account that typically power supplies are spec'ed as +/- 10%. 11708 - 10813 = 895 ~ 8% so it seems to be within spec. 

Share this post


Link to post
Share on other sites

I am by no means an ADC expert and others might have a better answer but: take in account that typically power supplies are spec'ed as +/- 10%. 11708 - 10813 = 895 ~ 8% so it seems to be within spec. 

 

Everything seems to be powered correctly. I am using the MSP432 Launchpad, and I have 6 or 7 of them on hand and they all act the same way. It looks like everything is great when I am using the 3.3V reference. (I was mistaken before in an earlier post when I said there was on 3.3V reference. It uses AVcc for that.)

 

I just find that when I try and use the internal reference using the provided function, that I get odd values. It's as if the ADC become nonlinear when I turn on the internal reference.

 

Now I am beginning to understand more the reason that a lot of people turn their noses up to Arduino. If you do something with it that is supported and documented it works great. So a novice can set up PIDs and Servos and PWMs and hook things up and it just works, but if you try and do something that nobody has done before, you have to mess around and write drivers and it's all buried in a mass of subdirectories.

 

I'm going to start over with this project, using CCS and C, because that will strip away the safety nets and I will have to learn the ADC14 peripheral and know how it works.

Share this post


Link to post
Share on other sites

As an idea, you could check the errata PDF for the MSP432, it accompanies the data sheet. Specifically, there's a few silicon bugs related to the REF module; this drives the ADC at 1.2, 1.45, 2.5, Vcc and Vss.

I had some issues related to Vref selection and external output to pin P5.6 which were finally resolved by sequencing the ADC register bits appropriately to work around the bugs. This I did in CCS6, not Energia.

Although I didn't experience your situation, perhaps this can help you.

USWaterRockets likes this

Share this post


Link to post
Share on other sites

Are there any calibration constants (e.g. slope compensation) in the MSP432 being used by Energia's analog implementation?  (I haven't inspected it myself yet... the EMT stuff is still a mystery to me in terms of how it's organized, always seems to be a binary build here or there)

Share this post


Link to post
Share on other sites

As an idea, you could check the errata PDF for the MSP432, it accompanies the data sheet. Specifically, there's a few silicon bugs related to the REF module; this drives the ADC at 1.2, 1.45, 2.5, Vcc and Vss.

I had some issues related to Vref selection and external output to pin P5.6 which were finally resolved by sequencing the ADC register bits appropriately to work around the bugs. This I did in CCS6, not Energia.

Although I didn't experience your situation, perhaps this can help you.

 

I read the datasheet and understand the ADC14, which is pretty slick. I coded it in CCSV6 and it works as expected.

 

I think I will poke in the Energia driver for the ADC14 and REF and see if I can spot what's happening. I have a feeling it may be trying to output the VREF on the external pin and this is conflicting with a GPIO or something and causing the Vref to be erratic. Just a guess. I have not looked at it yet.

 

Thanks for the input.

Share this post


Link to post
Share on other sites

Are there any calibration constants (e.g. slope compensation) in the MSP432 being used by Energia's analog implementation?  (I haven't inspected it myself yet... the EMT stuff is still a mystery to me in terms of how it's organized, always seems to be a binary build here or there)

 

It claims to be factory trimmed, so it should be "point and shoot".

 

The ADC14 is really quite sophisticated, and can read many things autonomously. I don't see how that feature even begins to be accessed using Energia. I may just use this as an excuse to play with TI/RTOS instead. 

Share this post


Link to post
Share on other sites

It claims to be factory trimmed, so it should be "point and shoot".

 

The ADC14 is really quite sophisticated, and can read many things autonomously. I don't see how that feature even begins to be accessed using Energia. I may just use this as an excuse to play with TI/RTOS instead.

 

Good call... I have been slowly working through the training videos myself. Gotta get back to them soon :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0