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
I write this code:
SD16AE = 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]
A couple of things I noticed.
-
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.
-
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.
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.