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 sample program for ADC

Status
Not open for further replies.

amirtafrishi

Junior Member level 1
Joined
Dec 16, 2011
Messages
19
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,449
Hey guys
I am using lpc1768 as ADC input for cheking input voltage by keil program but i've faced with problem.actually i'm new in cortex-m3 too.This is my code below.could u please tell my problems in program ?am i need header file becuase of using GPIO?

#include "lpc17xx.h"
#include "type.h"
#include "adc.h"
{
LPC_GPIO2->FIODIR = 0x000000FF;
LPC_ADC->ADCR |= 1 << 24;
while((LPC_ADC->ADDR0 & (1 << 31)) == 0);
int curVal=( LPC_ADC->ADDR0 >> 4 ) & 0xFFF;
float volt = (float)(((VREFP-VREFN)*curVal)/ADC_MAX); //result in volts.
if ( volt >= 1.6 )
LPC_GPIO2->FIOSET = 1;
if ( volt =< 1.6)
LPC_GPIO2->FIOCLR = 0x000000FF;
return; /* the ADC reading is done inside the handler, return 0. */
}

- - - Updated - - -

Also this is the error : adc.c(25): error: #169: expected a declaration
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top