beautypg.com

Digilent 410-116P User Manual

Page 2

background image

Digilent, Inc.

PmodJSTK Reference Manual

www.digilentinc.com

Copyright Digilent, Inc.

page 2 of 3

The two least significant bits of the upper byte,
along with the entire lower byte, make up the
10-bit value that was calculated.

By referring to the Joystick Axis Map located
above, it is possible to know what X and Y
values to expect from the PmodJSTK, based
on the current position of the joystick.

The X and Y position data make up the first
four bytes of the five byte series. The last byte
contains the positions of the three buttons,
indicated by the three least significant bits in
the byte.


Communication

The serial peripheral interface (SPI) mode 0
method of communication is used to
communicate between the PmodJSTK and the
master board

To receive data from the PmodJSTK using
SPI, a byte must be shifted into the
PmodJSTK. As the byte is shifted into the
PmodJSTK, it shifts out a data byte to the
master. This communication is accomplished
via the master-in slave-out (MISO) and master-
out slave-in (MOSI) lines of the communication
bus. This communication must be
synchronously clocked using the serial clock
(SCK) line of the communication bus.

The PmodJSTK is enabled on the SPI bus by
lowering the slave select (SS) pin. The SS pin
is active low. The maximum recommended
SPI clock speed is 1 MHz. The minimum
recommended amount of time between the SS
pin going low and the start of data transmission
on the bus is 15µs. The minimum
recommended amount of time between the
end of one byte being shifted and the
beginning of the next is 10µs. The SS pin
should be returned high after communication
has been completed.

After lowering the SS pin, the master should
shift 5 bytes to the PmodJSTK in order to
receive data from the PmodJSTK. After each

of these bytes is shifted in, the master will have
received a byte of data from the PmodJSTK.

The two programmable LEDs located on the
PmodJSTK are turned on or off based on the
status of the first of the five bytes shifted into
the PmodJSTK. The two least significant bits
of the first byte determine the status of the
LEDs. For example, if the first byte shifted into
the PmodJSTK is 0b00 (0x00), then both LEDs
will be off. If the first byte is 0b01 (0x01), only
LED1 will be on and similarly if 0b10 (0x02) is
shifted in, then only LED2 will be on. Both will
be turned on if 0b11 (0x03) is shifted in as the
first byte. Write to the LEDs using the
following format:

Figure 3 LED Command


The remaining four bytes that are shifted in are
ignored by the PmodJSTK. After each byte
has been completely shifted in, the PmodJSTK
will have finished shifting out a byte of data to
the master.

The order of the bytes being transferred from
the PmodJSTK to the master is as follows:

1

2

3

4

5

X (low) X(high) Y (low) Y(high) Buttons


The buttons are reported in the last byte in the
following format:

Figure 4 Byte 5


A bit written to a ‘1’ indicates that the
corresponding button is being depressed, and
a ‘0’ indicates that it is not being depressed.