Seven Segment display source code AID plz help !!

naturist's Avatar, Join Date: Dec 2009
Newbie Member
I've been asked to make a Seven segment display based project:


Interface segments display components with HCS12 controller, chose port A for carrying data and port E for segment activation.

I need this (Interface a keypad in port B and write program to restart the display content when there is a key press.)

Display all Alphabets and numerals in scrolling mode.

I've done so far this much and am lost with the keypad part will you please help me out !!

Source Code:
#include <hidef.h>      /* common defines and macros */
#include <mc9s12e128.h>     /* derivative information */

#pragma LINK_INFO DERIVATIVE "SampleS12"

void delay (int);
void delay (int x) {
  int y;
  while (x>0)  {
    for (y=0;y<5000;y++) {

void portInit (void) ;
  void portInit() {
    PORTE = 0X00;
    DDRE = 0XFF;
    PORTA= 0X00;
    DDRA = 0XFF;

void main(void) {
void segment_display(char s ) ; 

char alpha[] = {0X08,0X03,0X46,0X21,0X06,0X0E,0X10,0X09,0X79,0X71,0X7F,0X47,
char segment[]={0X80,0X00};
char size ;
unsigned int disp;

portInit() ;


  /* put your own code here */
  for(;;) {
  for(size=0;name [size] !='\0';size++) {
    for (disp=0;disp<34;disp++){
      PORTE = segment[0] |alpha[name[size]-65];
      PORTA = segment[1] |alpha[name[size+1]-65];
      delay (20);
      PORTE = segment[2] |alpha[name[size]-65];
       delay (20);
      PORTA = segment[3] |alpha[name[size+1]-65];
      delay (20);
      PORTE = segment[4] |alpha[name[size]-65];
       delay (20);
      PORTA = segment[5] |alpha[name[size+1]-65];
       delay (02);
      PORTE = segment[6] |alpha[name[size]-65];
       delay (20);
        PORTA = segment[7] |alpha[name[size+1]-65];
       delay (20);
  } /* wait forever */
please mail me the solution to:

thank you in advance

Last edited by shabbir; 1Dec2009 at 21:58.. Reason: Code blocks
Gene Poole's Avatar, Join Date: Nov 2009
Is this microcontroller code?
naturist's Avatar, Join Date: Dec 2009
Newbie Member
Originally Posted by Gene Poole View Post
Is this microcontroller code?

yes it is, i just want a start point and ill finish it up myself, it's like it's bit different that the original C#...thnx