Reply by veraleh September 23, 20102010-09-23
some compilers with optimization level not set to default will
optimize this loop and execute nothing.
it will simply disable this loop.
example - IAR compiler.

Ohad.

--- In m..., Hardy Griech wrote:
>
> On 23.09.2010 09:55, Martin wrote:
> :
> > for ( i=0; i<0x3600; i++) // Delay for reference start-up
> > {
> > }
> :
>
> Ok, the same questions as on the TI community: is this really a delay?
> And how about testing with the internal temperature sensor?
>
> Hardy
>

Beginning Microcontrollers with the MSP430

Reply by Hardy Griech September 23, 20102010-09-23
On 23.09.2010 09:55, Martin wrote:
:
> for ( i=0; i<0x3600; i++) // Delay for reference start-up
> {
> }
:

Ok, the same questions as on the TI community: is this really a delay?
And how about testing with the internal temperature sensor?

Hardy
Reply by Martin September 23, 20102010-09-23
My question was trimmed . Don't know why.

#include

void main(void)
{
volatile unsigned int i;
WDTCTL = WDTPW+WDTHOLD; // Stop watchdog timer
P6SEL |= BIT0; // Enable A/D channel A0
ADC12CTL0 = ADC12ON+SHT0_2+REFON+REF2_5V; // Turn on and set up ADC12
ADC12CTL1 = SHP; // Use sampling timer
ADC12MCTL0 = SREF_1; // Vr+=Vref+

for ( i=0; i<0x3600; i++) // Delay for reference start-up
{
}

ADC12CTL0 |= ENC; // Enable conversions

while (1)
{
ADC12CTL0 |= ADC12SC; // Start conversion
while ((ADC12IFG & BIT0)==0);
_NOP(); // SET BREAKPOINT HERE
}
}

I watch the variable ADC12MEM0 and it shows the same result around 2800. I didnt apply any voltage to the pin or tried around 1V there. Question is what is wrong ? Why ADC is not working?

Reply by Hardy Griech September 13, 20102010-09-13
On 12.09.2010 22:24, s...@yahoo.com wrote:
:
> HEre is the code i use. Taken from IT code samples.
:

And where is the question?
Reply by smok...@yahoo.com September 12, 20102010-09-12
My board is olimex MSP430-P1611 with MSP430F1611. I'm trying to work with ADC12 .
HEre is the code i use. Taken from IT code samples.

#include // Specific device

void main(void)
{
volatile unsigned int i;
WDTCTL = WDTPW+WDTHOLD; // Stop watchdog timer
P6SEL |= 0x01; // Enable A/D channel A0
ADC12CTL0 = ADC12ON+SHT0_2+REFON+REF2_5V; // Turn on and set up ADC12
ADC12CTL1 = SHP; // Use sampling timer
ADC12MCTL0 = SREF_1; // Vr+=Vref+

for ( i=0; i