Jump to content

Recommended Posts

The simplest version i did was an internal counter and a four bit port that output

to a transistor which switched digits, fairly standard first programming exercise.

 

Only difference from yours is that mine was for 4 digits, so yours would be easier.

Link to post
Share on other sites
can you please give example on how the program is done??how we define a switch as an input for the counter??

 

You seemed to have missed what i mean by switching as it is for output and it uses some

type of oscillator to "switch" between digits on the display. It is a form of multiplexing.

 

As for the program it was just a basic counter type with a loop to detect the switch input.

 

if(portb.4)
{
 counter++
}

switch(counter)
{
  case 0:
    lata = 0x77;
    break;

  case 1:
    lata = 0x60;
    break;

  default:
    break;
}

blah blah blah

Link to post
Share on other sites
what is rtfm??i'm kinda new with this programming thing

It stands for Read The Manual. On polite forums the 'f' word is silent. :rolleyes:

 

The original use comes from the *nix world and stands for "Read the fscking manual",

and no fscking is not what you think it is, it stands for "file system check". fsck is a command

used to repair the ext/ext2/ext3 file systems which have been in use for around 10-12 years

in Linux. The term was commonly told to "newbie" users who were too lazy to try and find

an answer to basic admin questions (like how to repair a fragmented filesystem).

 

Lame windows users picked up on it long ago and have distorted it's meaning to the more

crude form that most people recognise it as.

Edited by emte
Link to post
Share on other sites
what is rtfm??i'm kinda new with this programming thing

It stands for Read The Manual. On polite forums the 'f' word is silent. :rolleyes:

 

The original use comes from the *nix world and stands for "Read the fscking manual"

It would seem that your world view is a bit *NIX centered.

 

I was told to RTFM when first starting to program a Data General Nova12 minicomputer in 1970. That pre-dates the first "official" release of UNIX by almost a year.

 

And yes, back in the day, the world was in fact ALL CAPS. The ASR33 TTY really did suck even then.

Link to post
Share on other sites

Aww c'mon we all know AOL invented the CAPS key to make themselves sound

smarter :P

 

I must say that if you heard it in the 70's that predates my information, and probably

means you were also military or WAY too rich :rolleyes:

Link to post
Share on other sites
The original use comes from the *nix world and stands for "Read the fscking manual"

Yeah, I'd like to believe that, but it sounds like a bad urban legend email forward to me. You ever seen that one about "plucking the yew"? *gag*

 

Well i can only tell you it was used this way in my experiance on BBS and early IRC before

windows users adopted using the term.

Link to post
Share on other sites
  • 2 weeks later...

char run;

char x;

 

//Endless loop

while( 1 )

}

 

{

if(porta.0==0x01) // define input button

{

x=run++; // pass count value to x

switch(x) // select which case will be done

{

{

case(0):

portb=0x80;//for number 0;

portd=0x0f;

delay_ms(2);

portb=0x40;

portd=0x6f;

delay_ms(2);

portb=0x20;

portd=0x6f;

delay_ms(2);

portb=0x10;

portd=0x6f;

delay_ms(2);

portb=0x08;

portd=0x6f;

delay_ms(2);

portb=0x04;

portd=0x6f;

delay_ms(2);

portb=0x02;

portd=0x0f;

delay_ms(2);

portb=0x00;

portd=0xff;

delay_ms(2);

break;

}

 

{

case(1):

portb=0x80;//for number 1;

portd=0x7f;

delay_ms(2);

portb=0x40;

portd=0x7f;

delay_ms(2);

portb=0x20;

portd=0x7f;

delay_ms(2);

portb=0x10;

portd=0x7f;

delay_ms(2);

portb=0x08;

portd=0x7f;

delay_ms(2);

portb=0x04;

portd=0x7f;

delay_ms(2);

portb=0x02;

portd=0x7f;

delay_ms(2);

portb=0x00;

portd=0xff;

delay_ms(2);

break;

}

 

 

{

case(2):

portb=0x80;//for number 2;

portd=0x0f;

delay_ms(2);

portb=0x40;

portd=0x7f;

delay_ms(2);

portb=0x20;

portd=0x7f;

delay_ms(2);

portb=0x10;

portd=0x0f;

delay_ms(2);

portb=0x08;

portd=0xef;

delay_ms(2);

portb=0x04;

portd=0xef;

delay_ms(2);

portb=0x02;

portd=0x0f;

delay_ms(2);

portb=0x00;

portd=0xff;

delay_ms(2);

break;

}

 

{

case(3):

portb=0x80;//for number 3;

portd=0x0f;

delay_ms(2);

portb=0x40;

portd=0x7f;

delay_ms(2);

portb=0x20;

portd=0x7f;

delay_ms(2);

portb=0x10;

portd=0x0f;

delay_ms(2);

portb=0x08;

portd=0x7f;

delay_ms(2);

portb=0x04;

portd=0x7f;

delay_ms(2);

portb=0x02;

portd=0x0f;

delay_ms(2);

portb=0x01;

portd=0xff;

delay_ms(2);

}

 

{

case(4):

portb=0x80;//for number 4;

portd=0x6f;

delay_ms(2);

portb=0x40;

portd=0x6f;

delay_ms(2);

portb=0x20;

portd=0x6f;

delay_ms(2);

portb=0x10;

portd=0x0f;

delay_ms(2);

portb=0x08;

portd=0x7f;

delay_ms(2);

portb=0x04;

portd=0x7f;

delay_ms(2);

portb=0x02;

portd=0x7f;

delay_ms(2);

portb=0x00;

portd=0xff;

delay_ms(2);

break;

}

 

{

case(5):

portb=0x80;//for number 5;

portd=0x0f;

delay_ms(2);

portb=0x40;

portd=0xef;

delay_ms(2);

portb=0x20;

portd=0xef;

delay_ms(2);

portb=0x10;

portd=0x0f;

delay_ms(2);

portb=0x08;

portd=0x7f;

delay_ms(2);

portb=0x04;

portd=0x7f;

delay_ms(2);

portb=0x02;

portd=0x0f;

delay_ms(2);

portb=0x00;

portd=0xff;

delay_ms(2);

break;

}

 

{

case(6):

portb=0x80;//for number 6;

portd=0x0f;

delay_ms(2);

portb=0x40;

portd=0xef;

delay_ms(2);

portb=0x20;

portd=0xef;

delay_ms(2);

portb=0x10;

portd=0x0f;

delay_ms(2);

portb=0x08;

portd=0x6f;

delay_ms(2);

portb=0x04;

portd=0x6f;

delay_ms(2);

portb=0x02;

portd=0x0f;

delay_ms(2);

portb=0x00;

portd=0xff;

delay_ms(2);

break;

}

 

{

case(7):

portb=0x80;//for number 7;

portd=0x0f;

delay_ms(2);

portb=0x40;

portd=0x7f;

delay_ms(2);

portb=0x20;

portd=0x7f;

delay_ms(2);

portb=0x10;

portd=0x7f;

delay_ms(2);

portb=0x08;

portd=0x7f;

delay_ms(2);

portb=0x04;

portd=0x7f;

delay_ms(2);

portb=0x02;

portd=0x7f;

delay_ms(2);

portb=0x00;

portd=0xff;

delay_ms(2);

break;

}

 

{

case(8):

portb=0x80;//for number 8;

portd=0x0f;

delay_ms(2);

portb=0x40;

portd=0x6f;

delay_ms(2);

portb=0x20;

portd=0x6f;

delay_ms(2);

portb=0x10;

portd=0x0f;

delay_ms(2);

portb=0x08;

portd=0x6f;

delay_ms(2);

portb=0x04;

portd=0x6f;

delay_ms(2);

portb=0x02;

portd=0x0f;

delay_ms(2);

portb=0x00;

portd=0xff;

delay_ms(2);

break;

}

 

{

case(9):

portb=0x80;//for number 9;

portd=0x0f;

delay_ms(2);

portb=0x40;

portd=0x6f;

delay_ms(2);

portb=0x20;

portd=0x6f;

delay_ms(2);

portb=0x10;

portd=0x0f;

delay_ms(2);

portb=0x08;

portd=0x7f;

delay_ms(2);

portb=0x04;

portd=0x7f;

delay_ms(2);

portb=0x02;

portd=0x0f;

delay_ms(2);

portb=0x00;

portd=0xff;

delay_ms(2);

break;

}

 

 

{

case(10):

portb=0x80;//for number 10;

portd=0x0b;

delay_ms(2);

portb=0x40;

portd=0x6b;

delay_ms(2);

portb=0x20;

portd=0x6b;

delay_ms(2);

portb=0x10;

portd=0x6b;

delay_ms(2);

portb=0x08;

portd=0x6b;

delay_ms(2);

portb=0x04;

portd=0x6b;

delay_ms(2);

portb=0x02;

portd=0x0b;

delay_ms(2);

portb=0x00;

portd=0xff;

delay_ms(2);

break;

}

 

 

{

case(11):

portb=0x80;//for number 11;

portd=0x77;

delay_ms(2);

portb=0x40;

portd=0x77;

delay_ms(2);

portb=0x20;

portd=0x77;

delay_ms(2);

portb=0x10;

portd=0x77;

delay_ms(2);

portb=0x08;

portd=0x77;

delay_ms(2);

portb=0x04;

portd=0x77;

delay_ms(2);

portb=0x02;

portd=0x77;

delay_ms(2);

portb=0x00;

portd=0xff;

delay_ms(2);

break;

}

 

{

case(12):

portb=0x80;//for number 12;

portd=0x0b;

delay_ms(2);

portb=0x40;

portd=0x7b;

delay_ms(2);

portb=0x20;

portd=0x7b;

delay_ms(2);

portb=0x10;

portd=0x0b;

delay_ms(2);

portb=0x08;

portd=0xeb;

delay_ms(2);

portb=0x04;

portd=0xeb;

delay_ms(2);

portb=0x02;

portd=0x0b;

delay_ms(2);

portb=0x00;

portd=0xff;

delay_ms(2);

break;

}

 

{

case(13):

portb=0x80;//for number 13;

portd=0x0b;

delay_ms(2);

portb=0x40;

portd=0x7b;

delay_ms(2);

portb=0x20;

portd=0x7b;

delay_ms(2);

portb=0x10;

portd=0x0b;

delay_ms(2);

portb=0x08;

portd=0x7b;

delay_ms(2);

portb=0x04;

portd=0x7b;

delay_ms(2);

portb=0x02;

portd=0x0b;

delay_ms(2);

portb=0x00;

portd=0xff;

delay_ms(2);

break;

}

 

{

case(14):

portb=0x80;//for number 14;

portd=0x6b;

delay_ms(2);

portb=0x40;

portd=0x6b;

delay_ms(2);

portb=0x20;

portd=0x6b;

delay_ms(2);

portb=0x10;

portd=0x0b;

delay_ms(2);

portb=0x08;

portd=0x7b;

delay_ms(2);

portb=0x04;

portd=0x7b;

delay_ms(2);

portb=0x02;

portd=0x7b;

delay_ms(2);

portb=0x00;

portd=0xff;

delay_ms(2);

break;

}

 

{

case(15):

portb=0x80;//for number 15;

portd=0x0b;

delay_ms(2);

portb=0x40;

portd=0xeb;

delay_ms(2);

portb=0x20;

portd=0xeb;

delay_ms(2);

portb=0x10;

portd=0x0b;

delay_ms(2);

portb=0x08;

portd=0x7b;

delay_ms(2);

portb=0x04;

portd=0x7b;

delay_ms(2);

portb=0x02;

portd=0x0b;

delay_ms(2);

portb=0x00;

portd=0xff;

delay_ms(2);

break;

}

 

{

case(16):

portb=0x80;//for number 16;

portd=0x0b;

delay_ms(2);

portb=0x40;

portd=0xeb;

delay_ms(2);

portb=0x20;

portd=0xeb;

delay_ms(2);

portb=0x10;

portd=0x0b;

delay_ms(2);

portb=0x08;

portd=0x6b;

delay_ms(2);

portb=0x04;

portd=0x6b;

delay_ms(2);

portb=0x02;

portd=0x0b;

delay_ms(2);

portb=0x00;

portd=0xff;

delay_ms(2);

break;

}

 

{

case(17):

portb=0x80;//for number 17;

portd=0x0b;

delay_ms(2);

portb=0x40;

portd=0x7b;

delay_ms(2);

portb=0x20;

portd=0x7b;

delay_ms(2);

portb=0x10;

portd=0x7b;

delay_ms(2);

portb=0x08;

portd=0x7b;

delay_ms(2);

portb=0x04;

portd=0x7b;

delay_ms(2);

portb=0x02;

portd=0x7b;

delay_ms(2);

portb=0x00;

portd=0xff;

delay_ms(2);

break;

}

 

{

case(18):

portb=0x80;//for number 18;

portd=0x0b;

delay_ms(2);

portb=0x40;

portd=0x6b;

delay_ms(2);

portb=0x20;

portd=0x6b;

delay_ms(2);

portb=0x10;

portd=0x0b;

delay_ms(2);

portb=0x08;

portd=0x6b;

delay_ms(2);

portb=0x04;

portd=0x6b;

delay_ms(2);

portb=0x02;

portd=0x0b;

delay_ms(2);

portb=0x00;

portd=0xff;

delay_ms(2);

break;

}

 

{

case(19):

portb=0x80;//for number 19;

portd=0x0b;

delay_ms(2);

portb=0x40;

portd=0x6b;

delay_ms(2);

portb=0x20;

portd=0x6b;

delay_ms(2);

portb=0x10;

portd=0x0b;

delay_ms(2);

portb=0x08;

portd=0x7b;

delay_ms(2);

portb=0x04;

portd=0x7b;

delay_ms(2);

portb=0x02;

portd=0x0b;

delay_ms(2);

portb=0x00;

portd=0xff;

delay_ms(2);

break;

}

{

case(20):

portb=0x80;//for number 20;

portd=0x00;

delay_ms(2);

portb=0x40;

portd=0x67;

delay_ms(2);

portb=0x20;

portd=0x67;

delay_ms(2);

portb=0x10;

portd=0x60;

delay_ms(2);

portb=0x08;

portd=0x6e;

delay_ms(2);

portb=0x04;

portd=0x6e;

delay_ms(2);

portb=0x02;

portd=0x00;

delay_ms(2);

portb=0x00;

portd=0xff;

delay_ms(2);

break;

}

 

{

case(21):

portb=0x80;//for number 21;

portd=0x70;

delay_ms(2);

portb=0x40;

portd=0x77;

delay_ms(2);

portb=0x20;

portd=0x77;

delay_ms(2);

portb=0x10;

portd=0x70;

delay_ms(2);

portb=0x08;

portd=0x7e;

delay_ms(2);

portb=0x04;

portd=0x7e;

delay_ms(2);

portb=0x02;

portd=0x70;

delay_ms(2);

portb=0x00;

portd=0xff;

delay_ms(2);

break;

}

 

}

}

}

 

 

this is my program for the display,unfortunately 'missing semicolon' error occured..any suggestion??correction??anything??anyone??

Link to post
Share on other sites
this is my program for the display,unfortunately 'missing semicolon' error occured..any suggestion??correction??anything??anyone??

You could start by using the CODE tags when posting code.

 

Then a more convential style of indentation for a C program would help.

void function (void)
{
 
 char run;
 char x;
 
 //Endless loop
 while( 1 )
 {
   if(porta.0==0x01) // define input button 
   {
     x=run++; // pass count value to x
     switch(x) // select which case will be done
     {
     case(0):
       {
         portb=0x80;//for number 0;
         portd=0x0f;
         delay_ms(2);
         portb=0x40;
         portd=0x6f;
         delay_ms(2);
         portb=0x20;
         portd=0x6f;
         delay_ms(2);
         portb=0x10;
         portd=0x6f;
         delay_ms(2);
         portb=0x08;
         portd=0x6f;
         delay_ms(2);
         portb=0x04;
         portd=0x6f;
         delay_ms(2);
         portb=0x02;
         portd=0x0f;
         delay_ms(2);
         portb=0x00;
         portd=0xff;
         delay_ms(2);
       }
       break;

     case(1):
       {
         portb=0x80;//for number 1;
         portd=0x7f;
         delay_ms(2);
         portb=0x40;
         portd=0x7f;
         delay_ms(2);
         portb=0x20;
         portd=0x7f;
         delay_ms(2);
         portb=0x10;
         portd=0x7f;
         delay_ms(2);
         portb=0x08;
         portd=0x7f;
         delay_ms(2);
         portb=0x04;
         portd=0x7f;
         delay_ms(2);
         portb=0x02;
         portd=0x7f;
         delay_ms(2);
         portb=0x00;
         portd=0xff;
         delay_ms(2);
       }
       break;

     case(2):
       {
         portb=0x80;//for number 2;
         portd=0x0f;
         delay_ms(2);
         portb=0x40;
         portd=0x7f;
         delay_ms(2);
         portb=0x20;
         portd=0x7f;
         delay_ms(2);
         portb=0x10;
         portd=0x0f;
         delay_ms(2);
         portb=0x08;
         portd=0xef;
         delay_ms(2);
         portb=0x04;
         portd=0xef;
         delay_ms(2);
         portb=0x02;
         portd=0x0f;
         delay_ms(2);
         portb=0x00;
         portd=0xff;
         delay_ms(2);
       }
       break;
       
     case(3):
       {
         portb=0x80;//for number 3;
         portd=0x0f;
         delay_ms(2);
         portb=0x40;
         portd=0x7f;
         delay_ms(2);
         portb=0x20;
         portd=0x7f;
         delay_ms(2);
         portb=0x10;
         portd=0x0f;
         delay_ms(2);
         portb=0x08;
         portd=0x7f;
         delay_ms(2);
         portb=0x04;
         portd=0x7f;
         delay_ms(2);
         portb=0x02;
         portd=0x0f;
         delay_ms(2);
         portb=0x01;
         portd=0xff;
         delay_ms(2);
       }
       break;
       
     case(4):
       {
         portb=0x80;//for number 4;
         portd=0x6f;
         delay_ms(2);
         portb=0x40;
         portd=0x6f;
         delay_ms(2);
         portb=0x20;
         portd=0x6f;
         delay_ms(2);
         portb=0x10;
         portd=0x0f;
         delay_ms(2);
         portb=0x08;
         portd=0x7f;
         delay_ms(2);
         portb=0x04;
         portd=0x7f;
         delay_ms(2);
         portb=0x02;
         portd=0x7f;
         delay_ms(2);
         portb=0x00;
         portd=0xff;
         delay_ms(2);
       }
       break;
       
     case(5):
       {
         portb=0x80;//for number 5;
         portd=0x0f;
         delay_ms(2);
         portb=0x40;
         portd=0xef;
         delay_ms(2);
         portb=0x20;
         portd=0xef;
         delay_ms(2);
         portb=0x10;
         portd=0x0f;
         delay_ms(2);
         portb=0x08;
         portd=0x7f;
         delay_ms(2);
         portb=0x04;
         portd=0x7f;
         delay_ms(2);
         portb=0x02;
         portd=0x0f;
         delay_ms(2);
         portb=0x00;
         portd=0xff;
         delay_ms(2);
       }
       break;
       
     case(6):
       {
         portb=0x80;//for number 6;
         portd=0x0f;
         delay_ms(2);
         portb=0x40;
         portd=0xef;
         delay_ms(2);
         portb=0x20;
         portd=0xef;
         delay_ms(2);
         portb=0x10;
         portd=0x0f;
         delay_ms(2);
         portb=0x08;
         portd=0x6f;
         delay_ms(2);
         portb=0x04;
         portd=0x6f;
         delay_ms(2);
         portb=0x02;
         portd=0x0f;
         delay_ms(2);
         portb=0x00;
         portd=0xff;
         delay_ms(2);
       }
       break;
       
     case(7):
       {
         portb=0x80;//for number 7;
         portd=0x0f;
         delay_ms(2);
         portb=0x40;
         portd=0x7f;
         delay_ms(2);
         portb=0x20;
         portd=0x7f;
         delay_ms(2);
         portb=0x10;
         portd=0x7f;
         delay_ms(2);
         portb=0x08;
         portd=0x7f;
         delay_ms(2);
         portb=0x04;
         portd=0x7f;
         delay_ms(2);
         portb=0x02;
         portd=0x7f;
         delay_ms(2);
         portb=0x00;
         portd=0xff;
         delay_ms(2);
       }
       break;
       
     case(8):
       {
         portb=0x80;//for number 8;
         portd=0x0f;
         delay_ms(2);
         portb=0x40;
         portd=0x6f;
         delay_ms(2);
         portb=0x20;
         portd=0x6f;
         delay_ms(2);
         portb=0x10;
         portd=0x0f;
         delay_ms(2);
         portb=0x08;
         portd=0x6f;
         delay_ms(2);
         portb=0x04;
         portd=0x6f;
         delay_ms(2);
         portb=0x02;
         portd=0x0f;
         delay_ms(2);
         portb=0x00;
         portd=0xff;
         delay_ms(2);
       }
       break;
       
     case(9):
       {
         portb=0x80;//for number 9;
         portd=0x0f;
         delay_ms(2);
         portb=0x40;
         portd=0x6f;
         delay_ms(2);
         portb=0x20;
         portd=0x6f;
         delay_ms(2);
         portb=0x10;
         portd=0x0f;
         delay_ms(2);
         portb=0x08;
         portd=0x7f;
         delay_ms(2);
         portb=0x04;
         portd=0x7f;
         delay_ms(2);
         portb=0x02;
         portd=0x0f;
         delay_ms(2);
         portb=0x00;
         portd=0xff;
         delay_ms(2);
       }
       break;
       
       
     case(10):
       {
         portb=0x80;//for number 10;
         portd=0x0b;
         delay_ms(2);
         portb=0x40;
         portd=0x6b;
         delay_ms(2);
         portb=0x20;
         portd=0x6b;
         delay_ms(2);
         portb=0x10;
         portd=0x6b;
         delay_ms(2);
         portb=0x08;
         portd=0x6b;
         delay_ms(2);
         portb=0x04;
         portd=0x6b;
         delay_ms(2);
         portb=0x02;
         portd=0x0b;
         delay_ms(2);
         portb=0x00;
         portd=0xff;
         delay_ms(2);
       }
       break;
       
     case(11):
       {
         portb=0x80;//for number 11;
         portd=0x77;
         delay_ms(2);
         portb=0x40;
         portd=0x77;
         delay_ms(2);
         portb=0x20;
         portd=0x77;
         delay_ms(2);
         portb=0x10;
         portd=0x77;
         delay_ms(2);
         portb=0x08;
         portd=0x77;
         delay_ms(2);
         portb=0x04;
         portd=0x77;
         delay_ms(2);
         portb=0x02;
         portd=0x77;
         delay_ms(2);
         portb=0x00;
         portd=0xff;
         delay_ms(2);
       }
       break;
       
     case(12):
       {
         portb=0x80;//for number 12;
         portd=0x0b;
         delay_ms(2);
         portb=0x40;
         portd=0x7b;
         delay_ms(2);
         portb=0x20;
         portd=0x7b;
         delay_ms(2);
         portb=0x10;
         portd=0x0b;
         delay_ms(2);
         portb=0x08;
         portd=0xeb;
         delay_ms(2);
         portb=0x04;
         portd=0xeb;
         delay_ms(2);
         portb=0x02;
         portd=0x0b;
         delay_ms(2);
         portb=0x00;
         portd=0xff;
         delay_ms(2);
       }
       break;
       
     case(13):
       {
         portb=0x80;//for number 13;
         portd=0x0b;
         delay_ms(2);
         portb=0x40;
         portd=0x7b;
         delay_ms(2);
         portb=0x20;
         portd=0x7b;
         delay_ms(2);
         portb=0x10;
         portd=0x0b;
         delay_ms(2);
         portb=0x08;
         portd=0x7b;
         delay_ms(2);
         portb=0x04;
         portd=0x7b;
         delay_ms(2);
         portb=0x02;
         portd=0x0b;
         delay_ms(2);
         portb=0x00;
         portd=0xff;
         delay_ms(2);
       }
       break;
       
     case(14):
       {
         portb=0x80;//for number 14;
         portd=0x6b;
         delay_ms(2);
         portb=0x40;
         portd=0x6b;
         delay_ms(2);
         portb=0x20;
         portd=0x6b;
         delay_ms(2);
         portb=0x10;
         portd=0x0b;
         delay_ms(2);
         portb=0x08;
         portd=0x7b;
         delay_ms(2);
         portb=0x04;
         portd=0x7b;
         delay_ms(2);
         portb=0x02;
         portd=0x7b;
         delay_ms(2);
         portb=0x00;
         portd=0xff;
         delay_ms(2);
       }
       break;
       
     case(15):
       {
         portb=0x80;//for number 15;
         portd=0x0b;
         delay_ms(2);
         portb=0x40;
         portd=0xeb;
         delay_ms(2);
         portb=0x20;
         portd=0xeb;
         delay_ms(2);
         portb=0x10;
         portd=0x0b;
         delay_ms(2);
         portb=0x08;
         portd=0x7b;
         delay_ms(2);
         portb=0x04;
         portd=0x7b;
         delay_ms(2);
         portb=0x02;
         portd=0x0b;
         delay_ms(2);
         portb=0x00;
         portd=0xff;
         delay_ms(2);
       }
       break;
       
     case(16):
       {
         portb=0x80;//for number 16;
         portd=0x0b;
         delay_ms(2);
         portb=0x40;
         portd=0xeb;
         delay_ms(2);
         portb=0x20;
         portd=0xeb;
         delay_ms(2);
         portb=0x10;
         portd=0x0b;
         delay_ms(2);
         portb=0x08;
         portd=0x6b;
         delay_ms(2);
         portb=0x04;
         portd=0x6b;
         delay_ms(2);
         portb=0x02;
         portd=0x0b;
         delay_ms(2);
         portb=0x00;
         portd=0xff;
         delay_ms(2);
       }
       break;
       
     case(17):
       {
         portb=0x80;//for number 17;
         portd=0x0b;
         delay_ms(2);
         portb=0x40;
         portd=0x7b;
         delay_ms(2);
         portb=0x20;
         portd=0x7b;
         delay_ms(2);
         portb=0x10;
         portd=0x7b;
         delay_ms(2);
         portb=0x08;
         portd=0x7b;
         delay_ms(2);
         portb=0x04;
         portd=0x7b;
         delay_ms(2);
         portb=0x02;
         portd=0x7b;
         delay_ms(2);
         portb=0x00;
         portd=0xff;
         delay_ms(2);
       }
       break;
       
     case(18):
       {
         portb=0x80;//for number 18;
         portd=0x0b;
         delay_ms(2);
         portb=0x40;
         portd=0x6b;
         delay_ms(2);
         portb=0x20;
         portd=0x6b;
         delay_ms(2);
         portb=0x10;
         portd=0x0b;
         delay_ms(2);
         portb=0x08;
         portd=0x6b;
         delay_ms(2);
         portb=0x04;
         portd=0x6b;
         delay_ms(2);
         portb=0x02;
         portd=0x0b;
         delay_ms(2);
         portb=0x00;
         portd=0xff;
         delay_ms(2);
       }
       break;
       
     case(19):
       {
         portb=0x80;//for number 19;
         portd=0x0b;
         delay_ms(2);
         portb=0x40;
         portd=0x6b;
         delay_ms(2);
         portb=0x20;
         portd=0x6b;
         delay_ms(2);
         portb=0x10;
         portd=0x0b;
         delay_ms(2);
         portb=0x08;
         portd=0x7b;
         delay_ms(2);
         portb=0x04;
         portd=0x7b;
         delay_ms(2);
         portb=0x02;
         portd=0x0b;
         delay_ms(2);
         portb=0x00;
         portd=0xff;
         delay_ms(2);
       }
       break;

     case(20):
       {
         portb=0x80;//for number 20;
         portd=0x00;
         delay_ms(2);
         portb=0x40;
         portd=0x67;
         delay_ms(2);
         portb=0x20;
         portd=0x67;
         delay_ms(2);
         portb=0x10;
         portd=0x60;
         delay_ms(2);
         portb=0x08;
         portd=0x6e;
         delay_ms(2);
         portb=0x04;
         portd=0x6e;
         delay_ms(2);
         portb=0x02;
         portd=0x00;
         delay_ms(2);
         portb=0x00;
         portd=0xff;
         delay_ms(2);
       }
       break;
       
     case(21):
       {
         portb=0x80;//for number 21;
         portd=0x70;
         delay_ms(2);
         portb=0x40;
         portd=0x77;
         delay_ms(2);
         portb=0x20;
         portd=0x77;
         delay_ms(2);
         portb=0x10;
         portd=0x70;
         delay_ms(2);
         portb=0x08;
         portd=0x7e;
         delay_ms(2);
         portb=0x04;
         portd=0x7e;
         delay_ms(2);
         portb=0x02;
         portd=0x70;
         delay_ms(2);
         portb=0x00;
         portd=0xff;
         delay_ms(2);
       }
       break;
     } // end switch
   } // end if
 } // end while
}

Link to post
Share on other sites

I came at this problem using my computer graphics background (first single chip geometry accelerator at HP in 1993). What I did was allocate a section of memory to be my "frame buffer" where I could "render" characters, pictures whatever at whatever rate I wanted. Then I set up an interrupt routine to "refresh" the display a periodic rates. This simplifies the main code so that it does not worry how the display is drawn.

 

This display was connected up in row/column format so that each time the interrupt handler is called (controlled by a timer) the column data for the current row is output. Then, the row counter is advanced to the next row for the next interrupt.

 

pseudo code for a 5x7 display:

 

unsigned char Row = 0;
unsigned char FrameBuffer[7];

interrupt handler()
{
   portb = ~(1<<Row);  // Row enable is active low
   portc = FrameBuffer[Row];  // Column data is active high
   Row++;
   if(Row>6) Row = 0;
}

main()
{
   set up interrupts at 10ms rate

   while(1){
       Draw cool pictures into FrameBuffer 
   }
}

Edited by trossin
Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...