attempt at updated code
Code:
void pause( unsigned short usvalue ); //Establish pause routine function
void msecbase( void ); //Establish millisecond base function
unsigned long capture_interval(unsigned int prescale); //
unsigned long period2, RPM, SPEED;
unsigned short period, vhigh, vlow;
unsigned int advalue = 0; //Create A/D storage value and clear it
unsigned char digit, digit1, digit2;
int x,y;
main()
{
ANSEL = 0; // No analog inputs yet.
CM1CON0 = 0; // Initialize Comparator 1 off
CM2CON0 = 0; // Initialize Comparator 2 off
PORTA = 0; //Clear PortA
TRISA = 0xFF; //All PortA I/O inputs
ANSEL = 0b00000000; //Analog input AN0 (potentiometer)
ADCON0 = 0b00000001; //AtoD on, Left justified, Channel AN0/RA0 selected initially
ADCON1 = 0b00111000; //Internal RC clock for A/D conversion
PORTC = 0x0F; //Initialize PortC port
TRISC = 0x00; //All PortC I/O outputs
CCP1CON = 0b00000101; // configure capture feature (every rising edge)
T1CON = 0b00110000; // configure timer 1 (prescale by 8)
while(1==1) //loop forever
{
for(x=0;x<=99;x++)
{
ADCON0 = 0b00000001; //AtoD on, Left justified, Channel AN0/RA0 selected initially
pause(1);
GODONE = 1; //Start A/D process; need to account for overhead of ADC.
while (GODONE ==1) //wait for A/D to finish (average time?)
{
}
period2 = 64*capture_interval(8);
RPM = 60000000/period2;
SPEED = RPM*60*0.00043495983 //rpm * 60min per hour * wheel circumference (0.000434 miles)
advalue = SPEED;
for(y=0;y<=advalue;y++)
{
digit1=0;
digit2=0;
digit = x;
while(digit >= 10)
{
digit2++;
digit=digit-10;
}
digit1=digit;
digit = digit1<<4;
digit = (digit|0b00000111)&0b11111110;
PORTC = digit;
pause(1);
digit = digit2<<4;
digit = (digit|0b00000111)&0b11111101;
PORTC = digit;
pause(10);
}
}
continue;
} //End while
} //end main
anything, or rather, what am i doing wrong?
thanks