chava
Joined: 07 Sep 2003 Posts: 56
|
ccs calculation |
Posted: Sun Apr 04, 2004 3:27 am |
|
|
Hello
I wrote this code in which I display the number 35 on a 7 segment display
Code: | void display(){
char dig_righ,dig_midd,dig_left;
struct my_float displayed_val;
char temp;
//disable display to check PINB0 for who_disp
output_low(PIN_C5); output_low(PIN_C6); output_low(PIN_C7);
set_trisb(0xff); set_trisc(0xff);
displayed_val._int=35;//fsns._int;
displayed_val._fraction=fsns._fraction;
dig_righ=displayed_val._fraction;
calculation:
dig_left=0;
temp=displayed_val._int;
while(temp>=10){
dig_left+=1;
temp=temp-10;
}
dig_midd=displayed_val._int;
dig_midd-=(10*dig_left);
if((disp_dig1==0)&(disp_dig0==0))
{//left digit
displayed_val._int=dig_left;
output_high(PIN_C5);
disp_dig1=0;
disp_dig0=1;
goto set_display;
}
if((disp_dig1==0)&(disp_dig0==1))
{//middle digit
displayed_val._int=dig_midd;
output_high(PIN_C6);
disp_dig1=1;
disp_dig0=0;
goto set_display;
}
if((disp_dig1==1)&(disp_dig0==0))
{//right digit
displayed_val._int=dig_righ;
output_high(PIN_C7);
disp_dig1=0;
disp_dig0=0;
goto set_display;
}
set_display:
*display_port=letter_table[displayed_val._int];
if((disp_dig1==1)&(disp_dig0==0))
output_low(PIN_B7);
set_trisb(0x00);
set_trisc(0x18);
} |
now, pay attention to part after the label "calculation": for some reason the variable dig_midd=3 allthough it should be 5.
what's wrong? |
|