Hi all,
I want the ADC code for 89LPC925. I have developed it according to understanding. But i think i am missing some where. Here is my code
The serial data sending part is running fine. I think that the data are not been converted into the digital format. Can naybody pass me the sample code of the ADC for 89LPC925??
Thanks
I want the ADC code for 89LPC925. I have developed it according to understanding. But i think i am missing some where. Here is my code
Code:
include "stdio.h"
#include "reg925.h"
unsigned char converted_data;
void main()
{
int i;
ADMODB |= 0x40; //Configuring clock divider and selecting ADC mode
P0M1 |= 0x02; // configuring ADC chanel1 Port0.1 as input.
P0M2 &= ~0x02 ;
P1M1 = 0x00;
P1M2 = 0x00;
ADMODB &= ~0x08; // Disabling DAC
IP1 &= 0x7F; //Interrupt priorities
IP1H &= 0x7F;
EAD = 1 ; //Enabling ADC Interrupt
ADMODA |= 0x40; // ADC conversion mode autoscan and continous
ADINS &= 0x10; // Select ADC chanel 0.
ADCON1 |= 0x45; // Start conversion immediatly, enable ADC interrupt
while(1)
{
if (ADCON1 & 0x08) // Conversion Completed?
{
converted_data = AD1DAT0; // save the result
ADCON1 &= ~0x08; // clear ADCI1 flag
serial(converted_data); // send the data serially
for (i=0;i<300;i++)
{
}
}
}
}
The serial data sending part is running fine. I think that the data are not been converted into the digital format. Can naybody pass me the sample code of the ADC for 89LPC925??
Thanks