Pleiku
05-08-01, 02:21 PM
I'm using NMIX/T-0020 board and having problem convert from A to D.
After compile and download to the board and execute it, the program always stop at the second while loop.
Could someone help me please?
Thanks,
HT
***
#include <stdio.h>
#define ADCTL *(unsigned char*)(1030)
#define ADR1 *(unsigned char*)(1031)
main()
{
int adc;
float voltage;
while(1)
{
ADCTL=0x10;
while((ADCTL&0x80)==0){};
adc=ADR1;
voltage=(5.0/255.0)*adc;
printf("ADC output is %d. Voltage is %d. \n\r",adc,voltage);
}
}
After compile and download to the board and execute it, the program always stop at the second while loop.
Could someone help me please?
Thanks,
HT
***
#include <stdio.h>
#define ADCTL *(unsigned char*)(1030)
#define ADR1 *(unsigned char*)(1031)
main()
{
int adc;
float voltage;
while(1)
{
ADCTL=0x10;
while((ADCTL&0x80)==0){};
adc=ADR1;
voltage=(5.0/255.0)*adc;
printf("ADC output is %d. Voltage is %d. \n\r",adc,voltage);
}
}