USB Implementation to Communicate with a Nintendo Game Boy Advance Author: Robert Meerman (0219795) Supervisor: Roger Packwood Year of Study: 2004-5
Total Page:16
File Type:pdf, Size:1020Kb
COPY 1 USB Implementation to communicate with a Nintendo Game Boy Advance Author: Robert Meerman (0219795) Supervisor: Roger Packwood Year of Study: 2004-5 Abstract This project aimed to enable a Nintendo Game Boy Advance (GBA) to be used as a personal digital assistant by creating a USB communication interface between a Windows PC and a GBA, which would require no hardware-specific drivers or user-configuration. USB v1.1 is implemented on a Microchip PIC16F877 micro-controller (using the CCS compiler add-on) and a Philips Semiconductor PDIUSBD12 low-level USB chip which handles interactions with the USB bus. An interface with GBA is achieved via UART and then use the USB implementation by means of the (USB-IF defined) Human Interface Device (HID) class to transfer user-data. Keywords USB, Embedded System, PIC, Game Boy Advance, Hardware, PDIUSBD12, PIC16F877 Table of Contents 1 - Introduction...................................................................................................................................1 1.1 - Introduction to Game Boy.......................................................................................................2 1.2 - Introduction to Universal Serial Bus.......................................................................................4 USB Classes................................................................................................................................5 USB Speed & Traffic..................................................................................................................6 2 - Author's assessment of the project..............................................................................................8 2.1 - What is the technical contribution of this project?..................................................................8 2.2 - Why should this contribution be considered relevant / important to computer science?........8 2.3 - How can others make use of the work in this project?............................................................8 2.4 - Why should this project be considered an achievement?........................................................9 2.5 - What are the weaknesses of this project?................................................................................9 3 - Getting Started............................................................................................................................10 3.1 - Evaluating USB.....................................................................................................................10 3.2 - The GBA Communications Port...........................................................................................11 Choosing a tool-chain...............................................................................................................12 DevKit Advance...................................................................................................................13 HAM.....................................................................................................................................13 General Purpose Mode..............................................................................................................14 Pin-out and Voltages.................................................................................................................14 Running code on a GBA...........................................................................................................16 3.3 - Choosing a micro-controller..................................................................................................17 A brief introduction to PIC micro-controllers...........................................................................18 4 - Preparing the Hardware.............................................................................................................20 4.1 - GBA UART communications...............................................................................................20 4.2 - PC Debugging Tools.............................................................................................................21 Advanced Serial Port Monitor..................................................................................................22 USB Command Verifier............................................................................................................23 Snoopy Pro................................................................................................................................23 HHD USB Monitor...................................................................................................................24 4.3 - System Hardware...................................................................................................................25 PDIUSBD12 USB Interface Device with Parallel Bus.............................................................25 SoftConnect..........................................................................................................................25 GoodLink..............................................................................................................................26 PIC16F877 40-Pin 8-bit CMOS FLASH Micro-controller.......................................................26 Assembling the Hardware.........................................................................................................28 Verifying the System.................................................................................................................30 5 - Learning enough to Enumerate.................................................................................................32 5.1 - The USB Enumeration Process.............................................................................................32 USB STALLs and Bus-resets....................................................................................................34 5.2 - USB Control Transfers..........................................................................................................34 The Setup Stage.........................................................................................................................34 bmRequestType....................................................................................................................35 bRequest...............................................................................................................................35 wValue..................................................................................................................................35 wIndex..................................................................................................................................35 wLength................................................................................................................................35 The Data Stage..........................................................................................................................35 The Status Stage........................................................................................................................36 5.3 - USB Enumeration Requests..................................................................................................36 Set Address...............................................................................................................................36 Get Descriptor...........................................................................................................................36 Set Configuration......................................................................................................................37 5.4 - USB Descriptors....................................................................................................................37 Example: The Device Descriptor..............................................................................................38 5.5 - The Human Interface Device (HID) Class............................................................................40 Firmware Requirements............................................................................................................41 Report structures and descriptors..............................................................................................42 6 - Firmware Design and Development..........................................................................................44 6.1 - The USB Interrupt Service Routine.......................................................................................44 6.2 - Development..........................................................................................................................46 6.3 - Notable problems encountered..............................................................................................47 PIC16F877 Memory Limitations..............................................................................................47 Debugging issues......................................................................................................................48 PDIUSBD12 Reset issue...........................................................................................................48 Undocumented PDIUSBD12 Set Address command behaviour..............................................49 7 - Evaluation....................................................................................................................................51