can someone help me correct this C code?

psycobreed

Member
Dec 7, 2000
102
0
0
#include <stdio.h>
#include <hc11.h>

unsigned int volt;
unsigned char adcData;

void main(){
initialization();
while(1){
input();
calculate();
output();
}
}

void initialization(){
OPTION = 0x80;
}

void input() {
ADCTL = 0x10;
while (!(ADCTL & 0x80));
adcData = ADR2;
}

void calculate () {
volt = (125*adcData) / 64;
}
void output () {
printf("voltage = %d%d \r ", volt/100, volt%100);
}
 

Descartes

Lifer
Oct 10, 1999
13,968
2
0
Could you post this in the incorrect forum and also not give us any indication as to what is incorrect?
 

Rapidskies

Golden Member
May 27, 2003
1,165
0
0
Originally posted by: psycobreed
#include <stdio.h>
#include <hc11.h>

unsigned int volt;
unsigned char adcData;

void main(){
initialization();
while(1){
input();
calculate();
output();
}
}

Though I'm no expert, isn't the while with a (1) going to be an infinite loop? Need to decrement or increment you loop for one thing.