Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

lpc1768 adc 'done' bit never set's

Status
Not open for further replies.

h.galeh

Member level 3
Joined
Apr 16, 2008
Messages
66
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
Tehran, Iran, Iran
Activity points
1,690
I am working with adc pripherial of lpc1768(cortexm3)
we read in datasheet that after convertion is done. the 'done' bit of adgdr will set to 1
but there is no 'setting' when convertion is finished
 

main routine
Code:
#include "lpc17xx.h"
#include "gpio.h"

uint32_t m;

void main(){
  SystemInit();
  SystemCoreClockUpdate();

  while(1){
     init_adc(0);
     m=get_adc(0); 
  }
}
adc.c
Code:
#include "gpio.h"
enumPending Int0_Stat(){
  return GPIOINT->P0Int;
}
enumPending Int2_Stat(){
  return GPIOINT->P2Int;
}
adc.h
Code:
#ifndef __ADC_H_
#define __ADC_H_

#include "lpc17xx.h"
/*
typedef struct
{
  __IO uint32_t ADCR;
  __IO uint32_t ADGDR;
       uint32_t RESERVED0;
  __IO uint32_t ADINTEN;
  __I  uint32_t ADDR0;
  __I  uint32_t ADDR1;
  __I  uint32_t ADDR2;
  __I  uint32_t ADDR3;
  __I  uint32_t ADDR4;
  __I  uint32_t ADDR5;
  __I  uint32_t ADDR6;
  __I  uint32_t ADDR7;
  __I  uint32_t ADSTAT;
  __IO uint32_t ADTRM;
} LPC_ADC_TypeDef;
#define LPC_ADC               ((LPC_ADC_TypeDef       *) LPC_ADC_BASE      )
*/
typedef struct{
  union{
    struct{
      unsigned SEL:8;
      unsigned CLKDIV:8;
      unsigned BURST:1;
      unsigned :4;
      unsigned PDN:1;
      unsigned :2;
      unsigned START:3;
      unsigned EDGE:1;
    };
    uint32_t IADCR;
  };
}defADCR;
typedef struct{
  union{
    struct{
      unsigned :4;
      unsigned RESULT:12;
      unsigned :8;
      unsigned CHN:3;
      unsigned :3;
      unsigned OVERRUN:1;
      unsigned DONE:1;
    };
    unsigned IADGDR;
  };
}defADGDR;

typedef enum{
  no_start=0,
  now=1,
  p210=2,
  p127=3,
  mat01=4,
  mat03=5,
  mat10=6,
  mat11=7,
}enumstarter;
typedef enum{
  rising=0,
  falling=1,  
}enumedge;

typedef struct{
  union{
    struct{
      unsigned :4;
      unsigned RESULT:12;
      unsigned :14;
      unsigned OVERRUN:1;
      unsigned DONE:1;
    };
    uint32_t IADDR;
  };
}defADDR;
typedef struct{
  union{
    struct{
      unsigned INTEN0:1;
      unsigned INTEN1:1;
      unsigned INTEN2:1;
      unsigned INTEN3:1;
      unsigned INTEN4:1;
      unsigned INTEN5:1;
      unsigned INTEN6:1;
      unsigned INTEN7:1;
      unsigned ADGINTEN:1;
    };
    uint8_t ints;
    uint32_t IINT;
  };
}defINT;
#define ADCR ((defADCR *)&LPC_ADC->ADCR)
#define ADGDR ((defADGDR *)&LPC_ADC->ADGDR)
#define ADDR0 ((defADDR*)&LPC_ADC->ADDR0)
#define ADDR1 ((defADDR*)&LPC_ADC->ADDR1)
#define ADDR2 ((defADDR*)&LPC_ADC->ADDR2)
#define ADDR3 ((defADDR*)&LPC_ADC->ADDR3)
#define ADDR4 ((defADDR*)&LPC_ADC->ADDR4)
#define ADDR5 ((defADDR*)&LPC_ADC->ADDR5)
#define ADDR6 ((defADDR*)&LPC_ADC->ADDR6)
#define ADDR7 ((defADDR*)&LPC_ADC->ADDR7)
#define ADC_INT ((defINT*)&LPC_ADC->ADINTEN)

#endif
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top