ADAMSON UNIVERSITY
COLLEGE OF ENGINEERING
ELECTRONICS AND COMMUNICATIONS ENGINEERING DEPARTMENT
MICROPROCESSOR SYSTEM
Prelim Requirements
Class Schedule:
TTh 9-10:30
Quiz individual --------------------------- D&E
Seatwork by group----------------------- F&G
Take Home Quiz by Group-------------- H
Francisco, Princess G.
BS ECE / 5th year
TTh 9-10:30
Cs215
URL: http://puffprincess10.blogs.friendster.com/my_blog/
Engr. Lailan de Padua
Instructor
PROBLEMS:
D
Write a program for the z8encore microcontroller to use it as a shift register. Use PA0 as the clock terminal and all pins of port B as output.
PROGRAM:
#include
#include
void main (void) // returns no value
{ // start of the program
int led_out; // integer
unsigned int x,y; // declaration of variables
PBDD=0xFFFF; // port B data direction
PADD=0x00; // port A data direction
PAAF=0x00; // port A alternate function
PAOC=0x00; // port A output control
PAHDE=0x00; // port A high drive enable
while(1) // while(1)
{ // start of the program under the statement while true
led_out=0x80; // led out at the 1st led (left)
for (y=0;y<8;y++) // for loop
{ // start of program (for loop)
PBOUT=led_out; // Port B output
for (x=0;x<0xFFFF;x++); // delay
for (x=0;x<0xFFFF;x++); // delay
for (x=0;x<0xFFFF;x++); // delay
for (x=0;x<0xFFFF;x++); // delay
led_out=led_out>>1; // one step to the right
led_out|=0x80; // XOR operation
} // end of program (for loop)
} // end of program during while(1)
} // end of the program
SHEMATIC DIAGRAM:
E
Write a program for the z8encore microcontroller to use it as a 3-to-8 decoder. Use port A as an input and port B as output.
PROGRAM:
#include
#include
void main (void) // returns no value
{ // start of the program
int led_out; // integer
unsigned int x,y; // declaration of variables
PBDD=0xFFFF; // port B data direction
PADD=0x00; // port A data direction
PAAF=0x00; // port A alternate function
PAOC=0x00; // port A output control
PAHDE=0x00; // port A high drive enable
while(1) // while(1)
{ // start of the program under the statement while true
led_out=0x80; // led out at the 1st led (left)
for (y=0;y<8;y++) // for loop
{ // start of program (for loop)
PBOUT=led_out; // Port B output
for (x=0;x<0xFFFF;x++); // delay
for (x=0;x<0xFFFF;x++); // delay
for (x=0;x<0xFFFF;x++); // delay
for (x=0;x<0xFFFF;x++); // delay
led_out=led_out>>1; // one step to the right
led_out|=0x80; // XOR operation
} // end of program (for loop)
} // end of program during while(1)
} // end of the program
SCEMATIC DIAGRAM:
G
Write a program for the z8encore micro controller to use it as a L293D motor driver. Assume that the microcontroller can drive a DC Motor.
PROGRAM:
#include
#include
void main (void) // returns no value
{ // start of the program
int a,b; // integer
unsigned int x,y; // declaration of variables
PBDD=0xFFFF; // port B data direction
PADD=0x00; // port A data direction
PAAF=0x00; // port A alternate function
PAOC=0x00; // port A output control
PAHDE=0x00; // port A high drive enable
while(1) // while(1)
{ // start of the program under the statement while true
a=0x80; // led out at the 1st led (left)
a=on; // let a be the on-state of the motor
b=0000; // LEDs are all off
b=off; // let b be the off-state of the motor
if(a=0x80) // conditional statement, if
{ // start of program under the conditional statement
PBOUT=0xFF; // Port B output
for (x=0;x<0xFFFF;x++); // delay
for (x=0;x<0xFFFF;x++); // delay
PBOUT=0XF0; // Port B output
for (x=0;x<0xFFFF;x++); // delay
for (x=0;x<0xFFFF;x++); // delay
PBOUT=0x0F; // Port B output
for (x=0;x<0xFFFF;x++); // delay
for (x=0;x<0xFFFF;x++); // delay
} // end of program under the conditional statement
else // conditional statement, else
{ // start of program under the conditional statement
PBOUT=0x00; // Port B output
for (x=0;x<0xFFFF;x++); // delay
for (x=0;x<0xFFFF;x++); // delay
for (x=0;x<0xFFFF;x++); // delay
for (x=0;x<0xFFFF;x++); // delay
} // end of program under the conditional statement
} // end of program under the while(1) statement
} // end of program
SCEMATIC DIAGRAM:
H
Write a program for the z8encore microcontroller to use it as a controller to use it as a four-bit adder/subtractor. Use port A as input and port B as output.
PROGRAM:
#include
#include
void main (void) // returns no value
{ // start of the program
int led_1,led_2,led_out; // integer
unsigned int x,y; // declaration of variables
PBDD=0xFFFF; // port B data direction
PADD=0x00; // port A data direction
PAAF=0x00; // port A alternate function
PAOC=0x00; // port A output control
PAHDE=0x00; // port A high drive enable
while(1) // while(1)
{ // start of the program under the statement while true
led_1=0x80; //led from the left
led_2=0x01; // led from the right
for(y=0;y<3;y++) // conditional statement
{ // start of the program for conditional statement, for
led_out=led_2; // led output is equivalent to led from the right
led_out|=led_1; // led output is XOR= to led from the left
for (x=0;x<0xFFFF;x++); // delay
for (x=0;x<0xFFFF;x++); // delay
PBOUT=led_out; // Port B output
led_2=led_2>>1;
led_1=led_1<<1;
} // end of program under the conditional statement
} // end of program under the while(1) statement
} // end of program
SCHEMATIC DIAGRAM:
ADAMSON UNIVERSITY
COLLEGE OF ENGINEERING
ELECTRONICS AND COMMUNICATIONS ENGINEERING DEPARTMENT
MICROPROCESSOR SYSTEM
Prelim Requirements
GROUP:
Carpio, Ruth Ann O.
Francisco, Princess G.
Rosete, Ruby Rose P.
Engr. Lailan de Padua
Instructor
Posted by puffyprincessten
at 4:36 AM EST