ADC LPC1768 . simple question

Go To Last Post
2 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hi
this is my code

#include "LPC17xx.h"                    // Device header<br />
#include "GPIO_LPC17xx.h"               // Keil::Device:GPIO</p>
<p>
uint32_t voltag1 = 0 ;<br />
uint32_t voltag2 = 0 ;<br />
volatile uint32_t adstat;<br />
int blink=1;<br />
int main()<br />
{<br />
    //Config timer<br />
    LPC_TIM1->MCR=2;                         <br />
    LPC_TIM1->MR0=20000000;                 //Match Resgister<br />
  LPC_TIM1->TCR=1; <br />
    LPC_TIM1->EMR = 0x00000030 ;<br />
    <br />
    //Config ADC<br />
    LPC_PINCON->PINSEL1 |= (1 << 14) | (1 << 16);    // connect pin to ADC<br />
    LPC_SC->PCONP |= ((1 << 12));                       //enable power of ADC    <br />
    LPC_ADC->ADCR    =  0x06202001;                  //initialaze ADC<br />
    LPC_ADC->ADINTEN =  0x00000100;                  // global interup        <br />
    NVIC_EnableIRQ(ADC_IRQn);                          <br />
    </p>
<p>    GPIO_SetDir(3,25,GPIO_DIR_OUTPUT);                   <br />
    <br />
    while(1)<br />
        {</p>
<p>        }<br />
}</p>
<p>void ADC_IRQHandler(void) <br />
{<br />
    <br />
    <br />
        adstat = LPC_ADC->ADSTAT;                        /* Read ADC clears interrupt     */<br />
    <br />
      <br />
        blink++;<br />
        GPIO_PinWrite(3,25,blink%2);<br />
        voltag1 = (LPC_ADC->ADGDR >> 4) & 0xFFF; <br />
    <br />
        //voltag2 = (LPC_ADC->ADDR1 >> 4) & 0xFFF; <br />
        <br />
        <br />
    </p>
<p>}<br />

when i use LPC_ADC->ADGDR it work fine but when i use LPC_ADC->ADDR1 its not working , why?

Last Edited: Tue. Jun 16, 2015 - 09:48 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Wrong forum. We don't do NXP here. This site is owned by Atmel. Take your question to:

 

http://www.lpcware.com/forum

 

Locked.

 

Moderator

Topic locked