12 usb communication module u08usb.c, Usb communication module u08usb.c – Motorola USB08 User Manual

Page 56

Advertising
background image

Designer Reference Manual

USB08 Evaluation Board

56

Software Module Descriptions

MOTOROLA

Software Module Descriptions

disables any interrupts. Also, in an application with permanent interrupt
use, the software SCI should run in an interrupt-controlled way. Since
the receiving of a character is performed using port pin PTA7, the use of
the keyboard interrupt associated with this pin would be possible for the
recognition of the start bit. The timing for the scanning of the following
received data bits could be made using the available main timer (TIM) of
the MC68HC908JB8 as well as the sending of characters using the
PTC0 pin.

3.12 USB Communication Module U08USB.C

The USB communication module

U08USB.C

demonstrates how data

can be exchanged between the microcontroller and host PC over an
USB connection. This module can be linked (alternatively to the RS232
communication module

U08232.C

) into the USB08 application when the

macro USE_USB_PIPE in the main module

U08MAIN.C

is activated.

Just like RS232, the USB uses serial streams for the data
communication. The substantially more complex operational sequence
of the USB can be encapsulated so that the integration into existing
projects is possible without problems. Therefore, the USB
implementation shown here is just as simple to manage for the firmware
programmer as the classical RS232 version. Only three interface
functions are needed:

initUSB() — initialization of the USB communication module

getUSB() — receiving a character

putUSB() — transmitting a character

The integrated USB peripheral module of the MC68HC908JB8 is
controlled using some control registers within the address range of
0x020 to 0x03F; the function initUSB() takes care of the initialization of
these registers. In addition, the status of the USB equipment is set to the
initial status (Powered) and the two software buffers which buffer the
sending and/or the receiving of data in the application are initialized.

If data should be received, the routine getUSB() is called by the
application. First, this routine stays in a waiting loop until data from the

Advertising