Page 1 of 1
Read voltage with msp430-f2013
Posted: Mon Apr 13, 2009 1:30 pm
by toneskater
Hello World
I have a problem with msp430 microcontroller f2013
I'm a student, and I can not find what I need.
I downloaded all the manuals, and I understand in theory what should I do, but in practice I can not write the code.
I want to write c code to read an external voltage to analyze a signal, and insert it in any register of the microcontroller in order to use it later. Do not think that I have not tried to do it, I downloaded numerous examples, but unfortunately do not know where to begin. Can you give me a hand?
Andrea
Posted: Tue Apr 14, 2009 7:19 am
by toneskater
I write this code:
Code: Select allSD16AE = SD16AE3; //External input from channel 3
SD16INCTL0 = SD16INCH_3; // Input control register
SD16CTL = // Control register
0 + // clock divider
0 + // low power mode (for enable SD16LP)
0 + // clock divider
SD16SSEL1 + // use ACLK
0 + // V(MID) buffer off (not in 2013?)
SD16REFON + // reference on
SD16OVIE ; // enable overflow interrupt
SD16CCTL0 = // Channel 0 control register
SD16UNI + // unipolar mod
//SD16XOSR + // extended mode, 1024 sampling
SD16SNGL + // single conversion
SD16OSR1 + SD16OSR0 + // 32 oversampling
SD16LSBTOG + // don't toggle on SD16MEM0 reads
SD16LSBACC + // read the low order 16-bits
0 + // offset binary, not 2s complement
SD16IE + // interrupt enable
SD16SC ; // start conversion
volt = SD16MEM0
and then i connect the positive and negative cable to the corrects pins
There are any error??[/code]
Posted: Tue May 12, 2009 8:32 am
by fll-freak
A couple of things I noticed.
1) You did not show instructing the MSP that the pin you want to use is assigned as a peripheral and not GPIO. Read the section on GPIO in the user's manual.
2) You request the conversion and then immidiately ask for the converted value. The ADC is fast, but not that fast. You should either delay a while, or better yet, ask for the conversion complete to generate an interrupt. Inside the interrupt handler you can copy the value from the ADC to your memory.
Posted: Tue May 12, 2009 9:49 am
by Philba
there is a lot of sample code available on the TI site. It's been a while since I used the ADC on that chip but I recall starting with TI sample code. You might have to dig around a bit unless they've improved the site.