Freescale Semiconductor MC9S12 User Manual

Usb2.0 card reader

Advertisement

Quick Links

USB2.0 Card Reader
Designer Reference Manual
MC9S12
Microcontrollers
DRM065
Rev. 0.1
01/2005
freescale.com

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the MC9S12 and is the answer not in the manual?

Questions and answers

Summary of Contents for Freescale Semiconductor MC9S12

  • Page 1 USB2.0 Card Reader Designer Reference Manual MC9S12 Microcontrollers DRM065 Rev. 0.1 01/2005 freescale.com...
  • Page 3 The following revision history table summarizes changes contained in this document. For your convenience, the page number designators have been linked to the appropriate location. Revision History Revision Page Date Description Level Number(s) 01/2005 Initial release MC9S12UF32 Card Reader Reference Design User Manual, Rev. 0.1 Freescale Semiconductor...
  • Page 4 Revision History MC9S12UF32 Card Reader Reference Design User Manual, Rev. 0.1 Freescale Semiconductor...
  • Page 5: Table Of Contents

    Initialization the USB Module ........... 18 MC9S12UF32 Card Reader Reference Design User Manual, Rev. 0.1 Freescale Semiconductor TOC-5...
  • Page 6 Mini-Kernel Project ............35 Chapter 9 Glossary MC9S12UF32 Card Reader Reference Design User Manual, Rev. 0.1 TOC-6 Freescale Semiconductor...
  • Page 7: System Overview 1.1 Introduction

    DVD-ROM drives. The UF32 also enables controls of different common Flash memory devices including: CompactFlash, Secure Digital, MultiMediaCard, SmartMedia and Memory Stick memory cards. The availability of up to 75 programmable I/O lines helps to minimize the system costs and enhance flexibility. MC9S12UF32 Card Reader Reference Design User Manual, Rev. 0.1 Freescale Semiconductor...
  • Page 8: Mc9S12Uf32 Feature List

    PORTE VDDR 3.3V 2.5V PORTQ REF3V 2.5V PORTP PORTM SD/MMC 3.3V 3.3V VDD3X 5/3.3V PORTJ PORTT S12 Core PORTU PORTS PORTR PORTB VDDX 5/3.3V PORTA Figure 1-1. Block Diagram MC9S12UF32 Card Reader Reference Design User Manual, Rev. 0.1 Freescale Semiconductor...
  • Page 9: Voltage Regulation

    The UF32 contains CF, MS, SM and SD host controller interfaces that can direct connect to the memory cards. Only pullup and pulldown resistors are needed to connect the UF32 to the memory cards. MC9S12UF32 Card Reader Reference Design User Manual, Rev. 0.1 Freescale Semiconductor...
  • Page 10 System Overview MC9S12UF32 Card Reader Reference Design User Manual, Rev. 0.1 Freescale Semiconductor...
  • Page 11: Hardware

    UF32, a 12V to 5V DC-DC converter, a RS-232 transceiver and some other glue logics. It has built-in sockets for the mass storage memory cards. Please refer to the user manual of the board for detail operations. Figure 2-1. M68EVB912UF32 Evaluation Board MC9S12UF32 Card Reader Reference Design User Manual, Rev. 0.1 Freescale Semiconductor...
  • Page 12: Modifications

    Connect JP16 pin 14 and JP9 pin 9 for Secure Digital card write protect detection • Connect JP16 pin 16 and JP9 pin 8 for Memory Stick card detection MC9S12UF32 Card Reader Reference Design User Manual, Rev. 0.1 Freescale Semiconductor...
  • Page 13: Software Overview

    Timer, Voltage Regulator, IQUEUE RAM, IQUEUE, and USB Controller. The main program continually checks and serves different event tasks. The memory card host controller will be initialized after the card is inserted. MC9S12UF32 Card Reader Reference Design User Manual, Rev. 0.1 Freescale Semiconductor...
  • Page 14: Main Software Flow

    100ms. The time interval is defined in the timer hook function. If any card is detected to be inserted, the handler will enable and initialize the card host controller. If any card is detected to be removed, the handler will disable the card host controller. MC9S12UF32 Card Reader Reference Design User Manual, Rev. 0.1 Freescale Semiconductor...
  • Page 15: Timer Interrupt

    $2600 ↓ RESERVED $3FFF $4000 ↓ 16K BYTES OF FLASH $7FFF $8000 ↓ RESERVED $BFFF $C000 ↓ 16K BYTES OF FLASH $FEFF $FF00↓ VECTORS $FFFF Figure 3-3. Memory Map MC9S12UF32 Card Reader Reference Design User Manual, Rev. 0.1 Freescale Semiconductor...
  • Page 16 Software Overview MC9S12UF32 Card Reader Reference Design User Manual, Rev. 0.1 Freescale Semiconductor...
  • Page 17: Usb Module

    USB Device Requests are sent and completed through Control Transfer using endpoint 0. The requests and the parameters are sent to the device in the setup packet. There are two kinds of requests. They are called standard requests and class specific requests. MC9S12UF32 Card Reader Reference Design User Manual, Rev. 0.1 Freescale Semiconductor...
  • Page 18: Initialization The Usb Module

    USB Bulk IN and OUT endpoints, set the Queue channels for USB transmit and receive, enable USB Bulk IN and OUT endpoint interrupts, and set the maximum buffer sizes of the Bulk-IN and OUT endpoints depending on the USB speeds. MC9S12UF32 Card Reader Reference Design User Manual, Rev. 0.1 Freescale Semiconductor...
  • Page 19: Intelligence Queue Module

    When reading data from a memory card, QC1REQ is set to USB receive and QC2REQ is set to Memory Card transmit. When writing data to the device, QC3REQ is set to USB transmit and QC4REQ is set to Memory Card receive. MC9S12UF32 Card Reader Reference Design User Manual, Rev. 0.1 Freescale Semiconductor...
  • Page 20 QRAM -> MS QC2REQ = 7 QRAM <- SD QC4REQ = 8 QRAM -> SD QC2REQ = 9 QRAM <- SM QC4REQ = 10 QRAM -> SM QC2REQ = 11 MC9S12UF32 Card Reader Reference Design User Manual, Rev. 0.1 Freescale Semiconductor...
  • Page 21: Usb Mass Storage Driver

    The host shall send out a Command Block Wrapper through an OUT endpoint before sending out data or requesting the device to return data. The device then responses with the Command Status Wrapper. Figure 6-1 shows the command data status flow. MC9S12UF32 Card Reader Reference Design User Manual, Rev. 0.1 Freescale Semiconductor...
  • Page 22: Usb Command Block Wrapper

    8 — 11 dCBWDataTransferLength (number of bytes of data transfer expected) bmCBWFlags Reserved (0) bCBWLUN (logical device number) Reserved (0) bCBWCBLength (Command Block length) 15 — 30 bCBWCB (Command Block) MC9S12UF32 Card Reader Reference Design User Manual, Rev. 0.1 Freescale Semiconductor...
  • Page 23: Usb Command Status Wrapper

    Logical Block Address (if required) (LSB byte 5) Reserved (0) (MSB byte 7) Transfer Length (if required) Parameter List Length (if required) Allocation length (if required) (LSB byte 8) Control MC9S12UF32 Card Reader Reference Design User Manual, Rev. 0.1 Freescale Semiconductor...
  • Page 24 Logical Block Address (if required) (LSB byte 9) (MSB byte 10) Transfer Length (if required) Parameter List Length (if required) (LSB byte 13) Allocation length (if required) Reserved Control MC9S12UF32 Card Reader Reference Design User Manual, Rev. 0.1 Freescale Semiconductor...
  • Page 25: Example Of Command Block Wrapper

    Each card has its individual mass storage processor file. For example, the “CFMS_Processor.c” handles the USB command block wrapper for CompactFlash card. The “USBMS_Process.c” contains common routines that are used for all the card mass storage processors. MC9S12UF32 Card Reader Reference Design User Manual, Rev. 0.1 Freescale Semiconductor...
  • Page 26: Commands Without Data Transfer

    HANDLING NEED TO CALL ComapctFlash CFMS_SCSIList[]() DEVICE DRIVER? Memory Stick MSMS_SCSIList[]() USBMS_SendCSW() Security Digit SDMS_SCSIList[]() MultiMediaCard SmartMedia SMMS_SCCIList[]() RETURN PASS, FAILED, OR PHASE ERROR Figure 6-2. CBW Command Handling MC9S12UF32 Card Reader Reference Design User Manual, Rev. 0.1 Freescale Semiconductor...
  • Page 27 COMMAND = Failed SUCCESS? = Failed SUCCESS? RETURNS ZERO DEVICE RETURNS CSW LENGTH DATA DATAx 13 BYTE CSW DATAx DATA Figure 6-3. Three Groups of CSW Command Handling MC9S12UF32 Card Reader Reference Design User Manual, Rev. 0.1 Freescale Semiconductor...
  • Page 28: Class Specific Request

    (bRequest = 0x00 to 0xFD) (bRequest = 0xFE) (bRequest = 0xFF) DEVICE RETURNS LUN RESET DEVICES STALL STALL DATAx 1 BYTE LUN STALL RETURN Figure 6-4. Software Flow of Class Specific Request MC9S12UF32 Card Reader Reference Design User Manual, Rev. 0.1 Freescale Semiconductor...
  • Page 29: Memory Cards Mass Storage Drivers

    512 bytes plus 16 extra bytes. Block is the memory erase unit and a block equals 16 pages (8K bytes) or 32 pages (16K bytes). In MS and SM, the block address to access data is called the Physical MC9S12UF32 Card Reader Reference Design User Manual, Rev. 0.1 Freescale Semiconductor...
  • Page 30 After that, the block of physical address 4 will be marked as an empty block. The block of physical address 7 will become the cluster 3 with logical block addresses from 96 to 127. MC9S12UF32 Card Reader Reference Design User Manual, Rev. 0.1 Freescale Semiconductor...
  • Page 31: Memory Card Mass Storage Drivers

    “LogToPhyTbl” is updated if necessary. The PBA is then retrieved from the “LogToPhyTbl”. The data is written to the PBA. For CF and SD, the data is written to the LBA directly. MC9S12UF32 Card Reader Reference Design User Manual, Rev. 0.1 Freescale Semiconductor...
  • Page 32: Host Receives Data From Card Reader

    SCSI command read packet. The data of the corresponding LBA will be sent to host once the UF32 received the SCSI read command. The logical to physical block address translation is needed for SM and MS only. MC9S12UF32 Card Reader Reference Design User Manual, Rev. 0.1 Freescale Semiconductor...
  • Page 33 Decode LBA to PBA Get data from Card LBA Send out data to host via IQUEU Finish reading all LBAs ? RETURN Figure 7-5. SCSI Command Read Packet MC9S12UF32 Card Reader Reference Design User Manual, Rev. 0.1 Freescale Semiconductor...
  • Page 34 Memory Cards Mass Storage Drivers MC9S12UF32 Card Reader Reference Design User Manual, Rev. 0.1 Freescale Semiconductor...
  • Page 35: Testing And Customization

    The mini-kernel project creates mini-kernel library file for the Card Reader project use. If this project is modified, the new library file can be copied for the Card Reader project use by running the “copyfile.bat” batch file. MC9S12UF32 Card Reader Reference Design User Manual, Rev. 0.1 Freescale Semiconductor...
  • Page 36 Testing and Customization MC9S12UF32 Card Reader Reference Design User Manual, Rev. 0.1 Freescale Semiconductor...
  • Page 37 For example, 234 (decimal) = 0010 0011 0100 (BCD) bit — A binary digit. A bit has a value of either logic 0 or logic 1. MC9S12UF32 Card Reader Reference Design User Manual, Rev. 0.1 Freescale Semiconductor...
  • Page 38 The outputs of the control unit drive the execution unit, which contains the arithmetic logic unit (ALU), CPU registers, and bus interface. COP — See “computer operating properly module (COP).” MC9S12UF32 Card Reader Reference Design User Manual, Rev. 0.1 Freescale Semiconductor...
  • Page 39 (ECT) — The HC12 Enhanced Capture Timer module has the features of the HC12 Standard Timer module enhanced by additional features in order to enlarge the field of applications. MC9S12UF32 Card Reader Reference Design User Manual, Rev. 0.1 Freescale Semiconductor...
  • Page 40 — The time lag between instruction completion and data movement. least significant bit (LSB) — The rightmost digit of a binary number. logic 1 — A voltage level approximately equal to the input power voltage (V MC9S12UF32 Card Reader Reference Design User Manual, Rev. 0.1 Freescale Semiconductor...
  • Page 41 — A binary code that instructs the CPU to perform an operation. open-drain — An output that has no pullup transistor. An external pullup device can be connected to the power supply to provide the logic 1 output voltage. MC9S12UF32 Card Reader Reference Design User Manual, Rev. 0.1 Freescale Semiconductor...
  • Page 42 RAM address is in the stack pointer. pullup — A transistor in the output of a logic gate that connects the output to the logic 1 voltage of the power supply. MC9S12UF32 Card Reader Reference Design User Manual, Rev. 0.1 Freescale Semiconductor...
  • Page 43 — A portion of RAM reserved for storage of CPU register contents and subroutine return addresses. stack pointer (SP) — A 16-bit register in the CPU containing the address of the next available storage location on the stack. MC9S12UF32 Card Reader Reference Design User Manual, Rev. 0.1 Freescale Semiconductor...
  • Page 44 — Connection of circuit outputs so that if any output is high, the connection point is high. word — A set of two bytes (16 bits). write — The transfer of a byte of data from the CPU to a memory location. MC9S12UF32 Card Reader Reference Design User Manual, Rev. 0.1 Freescale Semiconductor...
  • Page 46 Freescale Semiconductor assume any liability arising out of the application or use of any Japan: product or circuit, and specifically disclaims any and all liability, including without Freescale Semiconductor Japan Ltd.

This manual is also suitable for:

Mc9s12uf32

Table of Contents