WR Home      Topic Home      Chapter:  1  2  3  4 
<Previous Next>

Chapter 04

Developing a Utility Library for the Propeller PCB

Page 4

Questions
onSequence is a 16-bit word, which defines which LEDs will glow
onSeq

You can also write a function:
unsigned int convertToOnSequence(unsigned char portC, unsigned char portB, unsigned char portD)

Q5 Can you write a function void init_LEDs(void) which will initialize PORTB, PORTC, PORTD to define which pins will be output pins for LEDs.
Hint: Re-tink how many pins, will be output pins for LEDs.
Hint: Do not forget the DDR register

Q6 Can you write a function void switch_LEDs(unsigned int onSequence, unsigned char color) which will switch ON the LEDs defined by the variable onSequence, with the given color. The value of color can be from 0 to 7 as explained earlier.

Q7 What LED pattern will emerge when the following code is executed ?
unsigned int onSequence = 0xFFFF;
unsigned char color =0x00;
switch_LEDs(onSequence, color);

Q8 What LED pattern will emerge when the following code is executed ?
unsigned int onSequence = 0xFFFF;
unsigned char color =0x01;
switch_LEDs(onSequence, color);


WR Home      Topic Home      Chapter:  1  2  3  4 
<Previous Next>