CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

ccs calculation

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
chava



Joined: 07 Sep 2003
Posts: 56

View user's profile Send private message Send e-mail

ccs calculation
PostPosted: Sun Apr 04, 2004 3:27 am     Reply with quote

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?
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group