• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

can someone help me correct this C code?

#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);
}
 
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.
 
Back
Top