amirtafrishi
Junior Member level 1
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
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