Fujitsu FR80 Series User Manual
Fujitsu FR80 Series User Manual

Fujitsu FR80 Series User Manual

32-bit microcontroller bits pot black usb board
Table of Contents

Advertisement

Quick Links

FR80 Family
32-BIT MICROCONTROLLER
MB91F662
bits pot black
USB board
User's Manual
Downloaded from
Elcodis.com
electronic components distributor

Advertisement

Table of Contents
loading
Need help?

Need help?

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

Questions and answers

Subscribe to Our Youtube Channel

Summary of Contents for Fujitsu FR80 Series

  • Page 1 FR80 Family 32-BIT MICROCONTROLLER MB91F662 bits pot black USB board User's Manual Downloaded from Elcodis.com electronic components distributor...
  • Page 2: Disclaimer And Legal Notice

    Therefore, if you make a design based on the information in this document, you must assume responsibility for it; FUJITSU MICROELECTRONICS assumes no liability for any damage or loss from use of the information.
  • Page 3 Control Law of Japan and US export control laws. The company names and product names mentioned in this document are a trademark or registered trademark of their respective owners. Copyright(c) 2008 FUJITSU MICROELECTRONICS LIMITED all rights reserved Downloaded from Elcodis.com...
  • Page 4: Revision History

    Revision History Revisions Date Description Version 1.0 2008/09/25 First issue Downloaded from Elcodis.com electronic components distributor...
  • Page 5: Table Of Contents

    Table of Contents Disclaimer and Legal Notice......................1 Revision History..........................3 Table of Contents........................... 4 Preparations......................... 11 Checking package contents ..................11 Other items required ....................12 Required software ......................12 External appearance of the starter kit board and major components ......14 Starter kit parts ......................
  • Page 6 5.2.2 Device request (PC -> Starter kit)................. 72 5.2.3 Descriptor (PC <- Starter kit) ................75 Sample program sequence ..................80 5.3.1 Main routine ......................80 5.3.2 USB initialization process ..................82 5.3.3 USB interrupt processing..................83 5.3.4 EP0 data receive process..................85 5.3.5 Setup command receive process .................
  • Page 7 Installation and usage of the PC writer ................129 Monitor debugger....................... 138 Explanation of the monitor debugger ................. 138 Resources used by monitor debugger ............... 139 Memory map with monitor debugger installed ............140 Monitor debugger limitations ..................141 Stand-alone operation of the sample program............142 Downloaded from Elcodis.com electronic components distributor...
  • Page 8 Introduction Thank you for purchasing bits pot black (hereafter, starter kit). This starter kit is a USB microcontroller training kit equipped with Fujitsu's microcontroller MB91F662 (certified USB*). This starter kit provides an easy-to-understand training system for USB microcontrollers, and is intended for students who need to know "What is a USB?", "How is it used?", and "What is it used for?"...
  • Page 9 Contact For inquiries about this starter kit, contact the following address. Zip code: 105-8420 2-5-3 Nishi-Shinbashi, Minatoku, Tokyo E-mail: pd-bitspot@tsuzuki-densan.co.jp bits pot URL: http://www.tsuzuki-densan.co.jp/bitspot/ Downloaded from Elcodis.com electronic components distributor...
  • Page 10 Part and material suppliers This board was made possible through the cooperation of these suppliers. We express our sincere appreciation for their help. In addition, many individuals provided tremendous help in the planning and realization of this board. To all of you, we express our sincere appreciation for your help. Murata Manufacturing Co., Ltd.
  • Page 11 @@@ Fujitsu Microelectronics Limited Provided free of charge: Microcontroller MB91F662           Sensor Conditioner IC MB42M131 FRAM MB85RS256 Power Voltage Monitoring IC with Watchdog Timer MB3793-30A           Integrated Development Environment SOFTUNE Workbench           Sample programs Downloaded from Elcodis.com...
  • Page 12: Preparations

    Make sure your package contains all items listed in Table 1.1-1, Starter kit package contents. Figure 1.1-1 shows a photo of the contents. Table 1.1-1 Starter kit package contents Name Qty. Specifications/Remarks Main board FUJITSU 32-bit Microcontroller, MB91F662 (certified USB) and peripherals mounted USB A to Mini-B cable (1) Main board USB A⇔Mini-B cable...
  • Page 13: Other Items Required

    Other items required Please have ready these additional items not included with the starter kit, as listed in Table 1.2-1. Table 1.2-1 List of additional items required Name Qty. Specifications/Remarks OS: Windows XP or Windows VISTA Requires two or more USB ports. Software See "1.3 Required software".
  • Page 14 The sample programs are organized as shown in the diagram below. (The sample program provided by INTERFACE Co., Ltd., is beyond the scope of this manual.) [bits_pot_black_e] [sample_program] sample_program_e.zip : Sample programs [monitor]             moitor.mhx : Monitor programs [manual] users_manual_e.pdf...
  • Page 15: External Appearance Of The Starter Kit Board And Major Components

    External appearance of the starter kit board and major components Figure 1.4-1 shows the external appearance of the starter kit board, and Table 1.4-1 lists the major components. (11) USB Mini-B connector (2) FRAM (10) Slider SW (8) Pushbutton SW  (12) USB (3) Humidity sensor B connector...
  • Page 16 Table 1.4-1 Major components on the starter kit board Component Description Reference Main MCU FUJITSU 32-bit Microcontroller ― MB91F662 (certified USB) FRAM FUJITSU MB85RS256 Chapters 10, 11 Humidity sensor Measures humidity. Chapter 9 Terminal block Connects to plastic board (mounted with strain Chapter 7 gauge) to make an electronic scale.
  • Page 17: Starter Kit Parts

    Starter kit parts   Table 1.5-1 lists the parts in the starter kit. Table 1.5-1 Starter kit parts Part number Name Model Manufacturer C1,C2,C4,C6,C9, C10,C12,C13, Murata Manufacturing C18,C19,C37, Monolithic ceramic capacitor 0.1uF GCM188R11E104KA42D Co., Ltd. C36,C56,C58, C60,C61 Murata Manufacturing C3,C5 Monolithic ceramic capacitor 18pF GCM1552C1H180JZ0D...
  • Page 18 Part number Name Model Manufacturer P_SW1,P_SW2, P_SW3,P_SW4, P_SW5,P_SW6, Push switch B3S-1000 OMRON Corporation P_SW7,P_SW8, P_SW9,P_SW10 Digital transistor DTA114TUA ROHM R1,R3,R4,R5,R7,R8, R27,R28,R29,R30, R31,R32,R33,R34, Chip resistor 10 KΩ MCR03EZPF103 ROHM R42,R44,R45,R49, R70,R76,R89 R9,R10,R17,R78, R79,R84,R85, Chip resistor 0Ω MCR03EZPJ000 ROHM R86,R87,R88 R11,R13,R15,R26,R77 Chip resistor 330Ω...
  • Page 19 Name Model Manufacturer Power selector switch (3 pole) MHS131 Fujisoku Corporation Chip NTC thermistor NTCG164BH103J TDK Corporation FRAM MB85RS256 FUJITSU Microcontroller MB91F662 FUJITSU Sensor conditioner IC MB42M131 FUJITSU U4,U5 Through hole 0.8 dia. x 9 pitch:2.54 mm Terminal block PA001-2P...
  • Page 20: Power Supply Methods

    Power supply methods There are three methods for supplying power to the board, each selected using SW6 as shown below. The Power LED lights up red when power is supplied. Power supply Silk printing on board Remarks USB Mini-B USB Mini-B Draws bus power from the PC via the USB connector A to Mini-B cable.
  • Page 21 Power supply selector SW Lights up when power is ON  1. via USB Mini-B connector    3. External power supply (5V)  2. via USB B connector !! Caution !! • Do not change the power supply selector switch while the microcontroller is operating. •...
  • Page 22: Setting Up The Pc

    Setting up the PC Install the software required to operate this starter kit to your PC. Be sure to download the required software before starting the installation process. The setup procedures are as follows. Setup procedures: - Installation of the integrated development environment SOFTUNE (bits pot dedicated version) (Refer to Section 2.1) - Installation of USB drivers (Refer to Section 2.2) Downloaded from...
  • Page 23: Installing The Integrated Development Environment Softune (Bits Pot Dedicated Version)

    What is SOFTUNE? SOFTUNE is the integrated development environment (IDE) for developing programs and evaluating FUJITSU Microcontrollers. Developing programs for microcontrollers commonly used in embedded devices is a repetitive cycle of coding the source, building the executable, checking program operation (debug), and reflecting the debug results into the source code again. The SOFTUNE IDE is a tool designed to support the development process by integrating these tasks into a seamless systematic flow.
  • Page 24 Click "Next". Click "Next". Downloaded from Elcodis.com electronic components distributor...
  • Page 25 If you agree with the usage license, click "Yes". Click "Next". Downloaded from Elcodis.com electronic components distributor...
  • Page 26 Click "Next". Leave the destination folder at the default, "C:¥Softune6". Confirm the components selected for installation. "Customize Bar" is not checked by default so place a check in it. Downloaded from Elcodis.com electronic components distributor...
  • Page 27 Verify the details of the installation are acceptable. If there are no problems, click "Next". Wait for the installation to complete. Downloaded from Elcodis.com electronic components distributor...
  • Page 28 Click the "Finish" button to complete the installation of SOFTUNE. Downloaded from Elcodis.com electronic components distributor...
  • Page 29: Installing The Usb Driver

    Installing the USB driver The starter kit is equipped with a USB-to-serial converter IC (made by FTDI) between the USB Mini-B connector and microcontroller. This USB driver must be downloaded from the FTDI website. Download the driver software to a folder on your PC from the URL listed below beforehand. FTDI (Future Technology Devices International Ltd.) Virtual COM Port Drivers http://www.ftdichip.com/Drivers/VCP.htm...
  • Page 30 Once the driver has been downloaded and unpacked, the starter kit is ready to be connected to the PC using the supplied USB cable. However, before doing so, check the switch settings on the board. Figure 2.2-1 and Table 2.2-1 show the switch settings to use when installing the USB driver.
  • Page 31 After setting the switches on the board, connect the PC and board using the USB A to Mini-B cable supplied with the starter kit. To USB Mini-B connector Do not connect the cable to "USB FUNC" or "USB HOST". When you connect the board to the PC, the PC will recognize the new hardware and display messages prompting you to install the driver.
  • Page 32 This procedure will explain how to install the driver software previously downloaded instead of connecting to Windows Update. Select "Install from a list or specific location (Advanced)", and click "Next". Click "Browse" and specify the folder "CDM 2.04.06 WHQL Certified" downloaded earlier, then click "Next".
  • Page 33 Wait for the "USB Serial Converter" installation to complete. Click "Finish" to complete the installation of "USB Serial Converter". Downloaded from Elcodis.com electronic components distributor...
  • Page 34 Next, install the "USB Serial Port". Select "Install from a list or specific location (Advanced)", and click "Next". Click "Browse" and specify the folder "CDM 2.04.06 WHQL Certified" downloaded earlier, then click "Next". Downloaded from Elcodis.com electronic components distributor...
  • Page 35 Wait for the "USB Serial Port" installation to complete. Click "Finish" to complete the installation of "USB Serial Port". This completes the installation of the USB driver. Downloaded from Elcodis.com electronic components distributor...
  • Page 36: Launching Softune And Using The Monitor Debugger

    Launching SOFTUNE and using the monitor debugger Launching SOFTUNE After installing SOFTUNE and the USB driver, launch SOFTUNE by clicking Windows [Start] - [All Programs] - [SOFTUNE V6] - [FR Family SOFTUNE Workbench]. Figure 3.1-1 shows the screen layout when SOFTUNE starts up. Menu bar Tool bar Project...
  • Page 37 Menu bar Contains menu items for the SOFTUNE application. Tool bar The tool bar has groups of buttons for frequently used commands. You can move the tool bar anywhere on the screen by clicking inside the group frame with the left mouse button and dragging it.
  • Page 38 Unpack the downloaded sample programs. Open "sample.wsp (*)". From the "File (F)" menu, click "Open (O)", select "Workspace/project file", then select "sample.wsp" and click OK. (*) bits_pot_black/sample_program/project/sample.wsp !! HINT !! You can also open a workspace file by dragging and dropping the "sample.wsp" file from Explorer onto the SOFTUNE window.
  • Page 39 In order to confirm everything has been setup properly, we will use the sample program "sample_LED" to flash the letters "FJ" on the 7-segment LED on the starter kit board. Make sure "sample_LED.abs – “sample_LED.prj”[Debug]” is set as the active project and appears in bold type.
  • Page 40 Next, we will compile the program. Click the "Build" button to compile, and verify there were no errors in the compilation results in the output window. "Build" button If the compilation was successful, proceed to setup and launch the monitor debugger. Downloaded from Elcodis.com electronic components distributor...
  • Page 41: Setting And Launching The Monitor Debugger

    Setting and launching the monitor debugger Explanation of the monitor debugger The monitor debugger allows developers to debug the program loaded on a production microcontroller with built-in FLASH memory. Installing a monitor program with the application program provides access to debug functions. (Read also the monitor debugger explanation given in the Appendix at the end of the manual.) Click the + next to "Debug"...
  • Page 42 The setup wizard for the debugger starts up. Click "Next". Select "Monitor Debugger" for debugger type. Click "Next". Downloaded from Elcodis.com electronic components distributor...
  • Page 43 Select "RS" as the Type and specify the COM port the board is connected to. Leave the baud rate at "256000". Click "Next".   Refer to Appendix 2 in this manual to verify COM ports. Downloaded from Elcodis.com electronic components distributor...
  • Page 44 Click "Next". Make sure the option "Auto load when starting debug." has a check in it, and that the batch file for "Before" is set to "FshLdWrt.prc".   "FshLdWrt.prc" is a batch file for writing user programs to the FLASH memory on the board. Check the settings and click "Finish"...
  • Page 45 Before launching the debugger, check the switch settings on the board and the connection with the PC. If the settings and connections are correct, press the Reset switch. !! Caution !! Be sure to always press the Reset switch before launching the monitor debugger. This applies to other sample programs as well.
  • Page 46 From the SOFTUNE "Debug" menu, select "Start debug". If the settings were made correctly, the batch file for "Before " in the setup wizard will run. When the dialog bar is showing, the program is being downloaded to the FLASH memory on the microcontroller.
  • Page 47 If the debugger does not launch Check the following. Board settings. • Is the USB cable properly connected to the board and PC? • Are the switches on the board set properly? Setup wizard settings. • Are the COM port and baud rate settings correct? If both 1 and 2 are correct but the debugger still does not launch, the monitor program may be corrupt.
  • Page 48: Using The Monitor Debugger

    Using the monitor debugger The debugger will launch when the download to the FLASH memory on the microcontroller completes. The debugger should be pointing to the starting address of the user program. Downloaded from Elcodis.com electronic components distributor...
  • Page 49 Run the program by clicking the "Run continuously" button in the upper left of the SOFTUNE window. Downloaded from Elcodis.com electronic components distributor...
  • Page 50 Execution is successful if the letters "FJ" appear flashing on the 7-segment LED. Downloaded from Elcodis.com electronic components distributor...
  • Page 51 To stop program execution, press the "DEBUG STOP" button on the board. The flashing "FJ" will stop when the DEBUG STOP button is depressed. Depending on the timing, the program may stop with FJ still showing. Program stops by pressing DEBUG STOP To resume program execution, click "Run Continuously"...
  • Page 52 (5),(6) (1),(2),(3),(4) (8),(9) (10) Function Description Run Continuously Executes program continuously from the current position in the program counter (PC). Step In Executes the step and moves the PC to the address of the next instruction and stops. Step Over Executes the step and moves the PC to the beginning of the next instruction and stops.
  • Page 53 Make Compiles/assembles only the source files that have changed. Then, links all objects and libraries to generate the target program. Build Compiles/assembles all source files registered in the project, whether they have changed or not, then links all objects and libraries to generate the target file.
  • Page 54 (11)    (12)      (13) (11) Memory window Shows the memory contents during debug. If the window is not showing, click "View" - "Memory" to show it. (12) Register window Shows the register contents during debug. If the window is not showing, click "View"...
  • Page 55: Exiting Monitor Debug

    Exiting monitor debug To end debugging, always stop the program execution by pressing the DEBUG STOP button on the board . Then, click "Debug" - "End Debug". Refer to the monitor debugger limitations provided in the Appendix. Downloaded from Elcodis.com electronic components distributor...
  • Page 56: What Is A Usb

    What is a USB? What is a USB? USB stands for Universal Serial Bus. In 1993, engineers from Compaq, Intel, Microsoft, and NEC gathered and jointly developed a peripherals interface for next-generation PCs. This led to their release of the first USB 1.0 specifications (standards) in 1996.
  • Page 57: Connection Formats

    host in each of these examples, the system is called a single master system. Today, printers and digital cameras are also equipped with USB, not just the PC. These devices can transfer data between themselves without going through a host PC using a hosting function called USB Mini-Host.
  • Page 58: Plug

    Keyboard Printer Digital camera   PC  Mouse Web camera USB memory (Host)  Hub  Hub  Figure 4.3-1 USB Connection Example Plug Each end of the USB has a plug with a different shape. One end is called the A plug, the other the B plug.
  • Page 59: Transfer Rate

    Transfer rate USB transfer rates are standardized as shown below. Table 4.5-1. USB Transfer rates Low Speed Full Speed High Speed USB  1.0/1.1 1.5 Mbps 12 Mbps USB 2.0 1.5 Mbps 12 Mbps 480 Mbps The MB91F662 supports only Full Speed. Transfer rate detection The USB standard requires that USB devices allow for the automatic detection of their data transfer rate when connected to the host by using a pull-up resistor.
  • Page 60: Transfer Methods

    Transfer methods   Several transfer methods are specified for the USB. Table 4.7-1 below summarizes the USB transfer methods. Table 4.7-1 USB transfer methods Isochronous transfer Interrupt transfer Bulk transfer Control transfer This is the most A feature of this This method is This method is preferred transfer method...
  • Page 61: Configuration Of A Device

    Configuration of a device The host communicates by specifying addresses and endpoint numbers that it assigns to each USB device. When the USB device is connected, the host assigns a unique address to each function and hub. At the beginning of the connection, the device is always assigned to address "0". Thereafter, the host assigns an address from 1 to 127.
  • Page 62: Enumeration

    Enumeration Enumeration refers to the process that begins by the host recognizing the device connected to the bus, specifying an address, and fixating the descriptor information received from the device. The USB device uses the descriptor to inform the host of its attributes. There are several types of descriptors that the host can request.
  • Page 63 USB transmissions are managed by dividing time into frames that repeat every 1 ms, and allocating small portions of this transmission time to each device within each frame. The host starts a frame by sending the SOF packet every 1 ms. This is followed by a token packet sent from the host, which informs the device of the transfer type, device address, and end point.
  • Page 64 The packets shown in Figure 4.9-3 are combined to form a frame for transferring over the USB. Each packet will be explained. All packets begin with a SYNC field. This is an 8-bit field used to synchronize the input data and local clock on the input circuit.
  • Page 65: Device Class

    Table 4.9-1 shows the PID types (which indicates the status of the packet being sent) defined for USB. Table 4.9-1 PID types PID type PID name PID[3:0] Description Notification from the host to the function that it is about to send 0001b data.
  • Page 66: Let's Make A Usb Mouse

    Let's make a USB mouse This sample program will provide USB communications that a USB mouse uses (HID class) by utilizing the USB function controller in the microcontroller (MB91F662) installed on the starter kit. When the starter kit board is connected to the PC, the PC will recognize the board as a USB mouse (HID class).
  • Page 67 <Sample program target project> sample_USB.abs - “sample_USB.prj” [Debug] < Sample program execution procedures> Set the switches on the board to execute the program in debug mode, then connect the starter kit to the PC using the USB cable. Press the reset switch. Launch the monitor debugger and execute the USB sample program.
  • Page 68 Part name Silk printing on Description board Pushbutton SW P_SW3 Moves PC cursor left Pushbutton SW P_SW4 Moves PC cursor up Pushbutton SW P_SW5 Moves PC cursor right Pushbutton SW P_SW6 Moves PC cursor down Pushbutton SW P_SW7 Left button click Pushbutton SW P_SW8 Right button click...
  • Page 69: Overview Of Usb Communications Flow

    Overview of USB communications flow This section explains the USB communications flow performed by the sample program. Details on the USB communications protocol have been omitted. Refer to the USB and HID class specifications for details. 5.2.1 Overview of USB communications flow This sample program provides communications with the PC (USB host) as shown in the following flow diagrams.
  • Page 70 Starter kit (USB Function) PC (USB host)  [EP0]  USB connection (bus connection) The USB sample program recognizes the USB connection using the V-bus connection terminal (PH3).  Get Descriptor (Device) request Device Descriptor response Issue bus reset signal The MB91F662 USB function controller responds to the SET_ADDRESS request automatically at the hardware level. ...
  • Page 71 Starter kit (USB Function) PC (USB host)  [EP0] Get Descriptor (Configuration) request Configuration Descriptor response Interface Descriptor response HID Class Descriptor response Endpoint Descriptor response The MB91F662 USB function controller responds to the SET_CONFIGURATION request automatically at the hardware level. Set Configuration request 0 byte data response Set Idle request...
  • Page 72 Starter kit (USB Function) PC (USB host)  [EP1] Configuration completed (recognizes board as a USB mouse)  Notification of Report data :  Notification of Report data :  The PC (USB host) periodically issues interrupt (IN) transfer requests. If the status of the USB device has changed (mouse pointer information, etc.), the : ...
  • Page 73: Device Request (Pc -> Starter Kit)

    5.2.2 Device request (PC -> Starter kit) In this sample program, the data received by the starter kit is called a device request. The format of data in a device request is standardized. The device requests received by the starter kit are shown below. Table 5.2.2-1 Device request (GET_DESCRIPTOR (Device)) Byte Item...
  • Page 74 Table 5.2.2-3 Device request (GET_DESCRIPTOR (Configuration)) Byte Item Description Value BmRequestType Type of request (Transfer direction: Device -> host / type: standard/ receive: device : 80h) Brequest Request (GET_DESCRIPTOR: 06h) WValue Requested descriptor type and index value (Descriptor type (configuration): 02h) Windex 0 or language ID WLength...
  • Page 75 Table 5.2.2-5 Device request (SET_IDLE) Byte Item Description Value BmRequestType Type of request (Transfer direction: Host -> device / type: class/ receive: interface : 21h) Brequest Request (SET_IDLE: 0Ah) WValue WIndex WLength Table 5.2.2-6 Device request (GET_DESCRIPTOR (Report)) Byte Item Description Value BmRequestType...
  • Page 76: Descriptor (Pc <- Starter Kit)

    Subclass code bDeviceProtocol Protocol code (00h: unique protocol unused) bMaxPacketSize0 Max. packet size for endpoint 0 idVendor Vendor ID (04C5h: Fujitsu) idProduct Product ID (2019h: USB starter kit) bcdDevice Device version iManufacture Index of a string descriptor that represents the manufacturer...
  • Page 77 Table 5.2.3-2 Configuration Descriptor Byte Item Description Value bLength Descriptor size (09h) bDescriptorType Descriptor type (configuration: 02h) wTotalLength Descriptor size returned for this configuration (Total size including configuration, interface, HID class, and endpoint descriptor) bNumInterfaces Number of interfaces supported bConfigurationValue Parameter to pass to Set_Configuration, which is used to select this descriptor iConfiguration...
  • Page 78 Table 5.2.3-4 HID Class Descriptor Byte Item Description Value bLength Descriptor size (09h) bDescriptorType Descriptor type (HID descriptor: 21h) bcdHID HID class version (Ver. 1.01 -> 01h01h) bCountryCode Country identification code (00h: no identification) bNumDescriptors Number of class descriptors bDescriptorType Class descriptor type (22h: HID report) wDescriptorLength Remote descriptor size...
  • Page 79 Table 5.2.3-6 Report Descriptor 1 Byte Item Description Value UsagePage Page usage (Generic Desktop Control) Usage Item usage (Mouse) Collection Collection item tag (Application) UsagePage Page usage (Pointer) Collection Collection item tag (Physical) UsagePage Page usage (Button) UsageMinimum Minimum number of items used (1) UsageMaximum Maximum number of items used (3) LogicalMinimum...
  • Page 80 Table 5.2.3-7 Report Descriptor 2 Byte Item Description Value Input Input item tag (Data, Variable, Absolute) UsagePage Page usage (Generic Desktop Control) Usage Item usage (X direction) Usage Item usage (Y direction) Usage Item usage (Wheel) LogicalMinimum Minimum value the item can report (-127) LogicalMaximum Maximum value the item can report (127) ReportSize...
  • Page 81: Sample Program Sequence

    Sample program sequence This section describes the operation of the sample program. 5.3.1 Main routine The operation of the main routine is shown below. Note that the following conditions are assumed when operating this sample program. <MB91F662 operating conditions> FLASH access settings  ...
  • Page 82 Start *1 Flash wait setting (1 wait) Set USB clock Enable interrupt Initialize I/O port - SW port: input - Slider SW port: Use A/D (ch 15) - USB port: use USB Initialize A/D converter (use ch0, conversion time: 32.625 us, interrupt unused) ...
  • Page 83: Usb Initialization Process

    5.3.2 USB initialization process The figure below shows the details of the USB initialization process. Start USB operation enabled (USBEN=1) Bus reset (RST=1) USB register initial settings - Bus power supply (PWC=0) - EP0 setting (64 bytes) - EP1 setting (INT-IN transfer/ 64 bytes)  Release bus reset (RST=0) Clear EP0/EP1 receive buffer Set V-BUS detection pin (PH3)
  • Page 84: Usb Interrupt Processing

    5.3.3 USB interrupt processing The figure below shows the details of the USB interrupt processing. The USB function in the MB91F662 processes status interrupts and interrupts EP1 to EP5. However, this sample program uses only the status interrupt. After connecting to the PC, the status interrupt routine in the USB function will process responses to requests from the PC (USB host) to EP0.
  • Page 85 ① Suspend interrupt? Clear SOF flag SOF interrupt? Clear SOF flag Bus reset interrupt? Clear BRST flag Figure 5.3.3-2 Status interrupt 2 (usb_mouse_ctrl.c) Downloaded from Elcodis.com electronic components distributor...
  • Page 86: Ep0 Data Receive Process

    5.3.4 EP0 data receive process The figure below shows the details for the EP0 data receive process. EP0 data receive process Get length of received data bytes Get received data (read from EP0DT register) Clear DRQ0 flag   Figure 5.3.4-1 EP0 data receive process (usb_mouse_ctrl.c) Downloaded from Elcodis.com electronic components distributor...
  • Page 87: Setup Command Receive Process

    5.3.5 Setup command receive process The figure below shows the details for the EP0 Setup command receive process. The Setup command receive process also handles responses for the received Setup command. Setup command receive process Get received data byte length Get receive data (read from EP0DT register) Clear SETP flag...
  • Page 88 ① ② GET DESCRIPTOR (device) received? Return Device Descriptor (write to EP1DT register) Clear DRQI flag GET DESCRIPTOR (config) received? Return Configuration Descriptor (write to EP1DT register) Clear DRQI flag GET DESCRIPTOR (report) received? Return Report Descriptor (write to EP1DT register) Clear DRQI flag Figure 5.3.5-2 Setup command receive processing 2 (usb_mouse_ctrl.c) Downloaded from...
  • Page 89: Switch Operation Detection Process

    5.3.6 Switch operation detection process The figures below show the details of the switch (pushbuttons and slider) operation detection process. The device issues an HID data notification to the PC when it detects switch operation. The sample program ignores simultaneous operation of multiple switches. Start Get SW input status SW4 (up) input?
  • Page 90 ① SW9 (left click) input?   Update click information (Bottom = 01h) SW10 (left click) input?   Update click information (Bottom = 00h) Update click information (Bottom = 02h) ② Figure 5.3.6-2 Switch operation detection process 2 (main.c) Downloaded from Elcodis.com electronic components distributor...
  • Page 91 ② A/D conversion start (AD-ch15) A/D conversion complete? Get A/D conversion value (ad_data=(A/D conversion value & 0x03E0) >> 23) ad̲data > ad̲data̲old?  Update scroll data (wheel = 50) ad̲data̲old = ad̲data  ad̲data > ad̲data̲old?  Update scroll data (wheel = -50) Update scroll data (wheel = 0) ad̲data̲old = ad̲data ...
  • Page 92: Hid Data Notification Process

    5.3.7 HID data notification process The figure below shows the details of the HID data notification process. Start Configuration completed? IN requested to EP1? DRQ=1? HID data updates? Write HID data to be notified to PC (Host) in the EP1DT register (button information, X/Y travel, wheel movement) Clear IN request flag to EP1 (DRQ=0) Figure 5.3.7-1 HID data notification process (usb_mouse_ctrl.c)
  • Page 93: Humidity Sensor

    Humidity sensor 6.1 What is humidity? In the winter, our hands and skin tend to dry, and our throats easily become sore. Conversely, in areas where rain season occurs, the humidity tends to cause discomfort. And those who hang dry their laundry no doubt pay attention to the humidity level in weather reports.
  • Page 94 affected by changes in its own materials caused by substances in the air, sometimes leading to performance loss. The material used in the sensor to detect humidity defines its type, such as high-molecular, metallic oxide, or electrolytic. We will explain the most common type of humidity sensor, the high-molecular sensor. The high-molecular film absorbs and releases moisture, thus creating a change in its permittivity which is used to measure the relative humidity in air.
  • Page 95 The starter kit board has a humidity sensor device (HOKURIKU ELECTRIC INDUSTRY CO., LTD) mounted to it. This is a resistance changing humidity sensor that uses a moisture sensitive polymer. This device must be driven by an alternating voltage as a constantly applied direct voltage can affect the device's properties. In the next Chapter, we will explain the hygrometer program and power driving method as well as some cautionary notes.
  • Page 96: Let's Make A Hygrometer

    Let's make a hygrometer This sample program will create a hygrometer using the AD converter and base timer (PPG) in the microcontroller (MB91F662) installed on the starter kit, and the humidity sensor also mounted on the starter kit. 7.1 Overview of the sample program This sample program measures humidity using the AD converter and base timer (PPG) in the microcontroller (MB91F662), and the humidity sensor mounted on the starter kit.
  • Page 97 <Sample program target project> sample_humidity.abs - “sample_humidity.prj” [Debug] < Sample program execution procedures> 1. Connect the starter kit to the PC with the USB cable. 2. Run the humidity sensor sample program. 3. The humidity is displayed in the 7-SEG LED. You can view how the humidity changes by touching the sensor.
  • Page 98: Details On The Humidity Sensor

    7.2 Details on the humidity sensor 7.2.1 Wiring the humidity sensor The humidity sensor on the starter kit board is wired as shown below. 3.3V(Vin) PPG0 output port Humidity sensor A/D9 MB91F662 input port Resistor 47 kΩ (Rs) PPG1 output port Figure 9.2.1-1 Schematics of humidity sensor Downloaded from Elcodis.com...
  • Page 99: Driving The Humidity Sensor

    7.2.2 Driving the humidity sensor The humidity sensor must be driven as follows. 1kHz (Duty:50%) +3.3V PPG0 output waveform +3.3V PPG1 output waveform 1/2 to 2/3 of the timing when PPG0 is high A/D conversion timing (PPG2) Start A/D on lead edge of PPG2 A/D conversion Figure 9.2.2-1 Driving the humidity sensor Downloaded from...
  • Page 100: Humidity Sensor Characteristics

    Based on a setting in the MB91F662, PPG0 will output a pulse waveform at 1 kHz, 50% duty. PPG1 will output the phase-inverted waveform of PPG0. This will produce an alternating current of ±3.3 volts at the equivalent of 1 kHz between the output pins of PPG0 and PPG1.
  • Page 101       This sample program is designed for a fixed temperature of 22°C.       The voltage dividing characteristics at 22°C is given below. Table 9.2.3-2 Humidity sensor voltage dividing characteristics table 2 Voltage Voltage Voltage Voltage Relative Relative Relative Relative...
  • Page 102: Sample Program Operating Details

    7.3 Sample program operating details This section describes the operating details of the sample program. 7.3.1 Main routine The operating conditions (setting conditions) for the peripheral functions of the MB91F662 used in this sample program are outlined below. The figure below shows the details of the main routine.
  • Page 103 Figure 9.3-1 shows the flow of the main routine. This sample program measures time using the interrupt of reload timer ch0. Processing for humidity calculation and LED display alternate every two seconds so that changes can be observed in the LED display. Start Set Flash wait Enable interrupt...
  • Page 104: A/D Converter Interrupt Processing

    7.3.2 A/D converter interrupt processing When 10 converted data values are written to the FIFO buffer, an A/D interrupt is generated so that interrupt processing can take place. The interrupt processing routine fetches 10 A/D conversions from the FIFO buffer, and averages them. This is treated as the acquired value (value used to determine humidity) from the humidity sensor.
  • Page 105: Humidity Calculation Process

    7.3.3 Humidity calculation process The figure below shows the details of the humidity calculation process. The voltage divisor is obtained by multiplying the A/D conversion average by 0.00322 (= 3.3 volts / 2 ), because the A/D converter has 10 bits of resolution. The humidity is found by looking up the voltage divisor in Table 9.2.3-2, Humidity sensor voltage dividing characteristics table 2 Humidity calculation process Calculate voltage divisor.
  • Page 106: What Is An Fram

    What is an FRAM?   Do you know what FRAM is?   Although many types of memory devices are available today, they are largely separated into two groups. (1) memory that loses its contents when power is lost (volatile) : SRAM, SDRAM, etc. (2) memory that retains its contents even when power is lost (non-volatile) : EEPROM, FLASH memory FRAM (Ferroelectric Random Access Memory) is non-volatile like (2) and can be used as...
  • Page 107 The characteristics of the FRAM are the very reason they are ideal for security-dependant applications such as those in the figure below (train and bus passes, electronic money, membership cards used to record profiles and preferences in addition to member information, etc.).
  • Page 108   To learn more about FRAM, Visit the Fujitsu website listed below. http://jp.fujitsu.com/microelectronics/   The starter board is equipped with a stand-alone FRAM MB85RS256.   In the next Chapter, we will explain a program that accesses the FRAM using microcontroller communications.
  • Page 109: Let's Make A Counter

    Let's make a counter This sample program explains how to make a simple counter using FRAM. The counter functionality is achieved by using the SPI communications function on the multifunction serial interface (MFS), on the microcontroller (MB91F662) on this starter kit, to access the stand-alone FRAM ...
  • Page 110 <Sample program target project> sample_FRAM_SPI.abs - “sample_FRAM_SPI.prj” [Debug] < Sample program execution procedures> Connect the starter kit to the PC with the USB cable. Run the FRAM sample program. Pressing the pushbutton switch increments the count. (The count is retained even after power is turned OFF.) For debug Counter readout...
  • Page 111 Part name Silk printing on Description board FRAM FRAM Stores data. Pushbutton SW P_SW7 Increments data by 1. Pushbutton SW P_SW8 Clears data. Pushbutton SW P_SW10 Toggles 7-SEG LED display ON/OFF. Flashes while program is running. 7-segment LED 7-SEG LED Displays counter value.
  • Page 112: Details On The Fram  Mb85Rs256

    9.2 Details on the FRAM  MB85RS256 The MB85RS256 is a stand-alone FRAM device with a 256-Kbit capacity that supports the SPI interface. The features are listed below. <Features> - Bit configuration: 32,768 words x 8 bits - Operating power supply voltage: 3.0 V to 3.6 V - Operating frequency: 15 MHz (Max) - Serial Peripheral Interface: SPI - Operating temperature range: -20°C to 85°C...
  • Page 113 The commands listed above are input to the FRAM synchronized with the clock (SCK) after the trailing edge of the CS signal. Reading is done by inputting the READ command followed by a 16-bit address. In response, MB85RS256 outputs the 8-bit data synchronized with the clock. Thereafter, the address can be incremented automatically to read 8 more bits of data repeatedly by inputting 8 clock pulses before raising the CS signal.
  • Page 114 Writing is done by inputting the WRITE command followed by a 16-bit address, followed the data to write in 8-bit units synchronized to the clock bit. Thereafter, the address can be incremented automatically to continuously write 8 more bits of data by inputting data for every 8 clock pulses before raising the CS signal.
  • Page 115: Explanation Of The Sample Program

    9.3 Explanation of the sample program This section explains the program for writing data to the FRAM using the SPI multifunction serial interface on the MB91F662. Also refer to the actual sample program. This sample program is only intended for a simple operation check and thus does not use the multifunction serial interrupt function.
  • Page 116: Main Routine

    9.3.1 Main routine The operation of the main routine is shown below. Note that the following conditions are assumed when operating this sample program. <MB91F662 setting conditions> FLASH access settings FLASH access size setting: 32 bits (no changes to default value) FLASH wait setting: 1 wait MCU clock setting (set in the monitor debugger/no setting necessary) CLKB (CPU): 32 MHz (External clock 4 MHz x PLL-8 multiplier setting)
  • Page 117 Start interrupt routine Set CPU interrupt level (external interrupt level mask) Read from FRAM address 0x0000 SW7 input? Clear interrupt flag SW8 input? LED̲data <  99?  ① Clear interrupt flag LED_data = LED_data +1 LED_data = 0 Issue WREN command to FRAM Issue WREN command to FRAM ②...
  • Page 118 ① SW10 input? Clear interrupt flag Lighting  =  0  ?  Lighting = 1  Lighting = 0  Issue WREN command to FRAM Write Lighting to FRAM address 0x0001 ② Figure 11.3.1-3 Counter operation flow (Extint.c, sio.tx.c) Downloaded from Elcodis.com electronic components distributor...
  • Page 119: Appendix

    Appendix Creating projects/sample programs as new projects This Appendix will explain the settings to be made in order to create and debug new projects and sample programs using the monitor debugger. The "Sample_skeleton" project file supplied with the sample programs will be used for this explanation. Sample project configuration  ...
  • Page 120: Explanation Of The Program

      Launch SOFTUNE WORKBENCH, then from "File" - "Open Workspace" select sample.wsp in the sample folder, or drag and drop the sample.wsp file onto the SOFTUNE workspace. Clicking the + button next to "sample_skeleton.abs" will reveal the registered files as shown below.
  • Page 121 (2) main.c   The user program executes from the main () function.   Type your program from the line after the comment /* user program */.   Do not delete the code for internal FLASH memory access or the interrupt settings. Set Flash wait ...
  • Page 122   The monitor program is designed to allow communications with the PC at a peripheral clock speed of 32 MHz.   Two header files are defined at the beginning of the program.   _fr.h defines the I/O registers for MB91F662. (For details, refer to "ioregj.txt"...
  • Page 123: Softune Settings

    (Project file name).abs will be generated after the make/build process. The (project file name).bin file will be created from the mhx file using the converter program, which in turn, will be created from the abs file. (This process will be described later) This instruction in the FshLdWrt.prc file specifies the offset address of the user interrupt vector area.
  • Page 124 (1)-2 "Linker" tab In the [Deployment/Link] category, press the "Section settings" button. The window shown in the figure will appear. In "ROM/RAM area" select "_INROM01", and in section name specify "@INIT". Then select "const" for the content type and press the "Set" button. This area is where initial values for the variables with initial values (INIT area) will be located.
  • Page 125 (1)-3 "Converter" tab Place a check in the "Launch load module converter", and specify "Motorola S format (f2ms)" as the conversion format. This setting will automatically generate an mhx file from the abs file every time the make/build command is executed. (The mhx file is created inside the ABS folder.) (2) Customize build settings From the menu, select "Project"...
  • Page 126   From the "Converter" folder in the tree view, select "After" and click the icon next to "New file". Enter the name as shown below.   Title: M2BS (Any name may be specified) Execution file name: C:¥Softune6¥Bin¥M2BS.EXE Options: %X.mhx -o %X.bin -ran 0x00080000, 0x000FC000 Working directory: %x¥Debug¥ABS After entering the above, click "OK"...
  • Page 127 (4) Customize bar After starting debugging on SOFTUNE, click "View" - "Customize bar" and specify "start.prc". You can either type "start.prc" in the "Entry" box, or specify the file by clicking the button to the right of the text box. Click "Add" to register the prc file to the corresponding number. This will enable the customize bar icon for the registered number.
  • Page 128: Verifying Com Ports

    Verifying COM ports This Section will explain how to verify the COM ports allocated on your PC. For Windows XP Right-click "My Computer" and then select "Properties". In the "System properties" window, select the "Hardware" tab and click the button "Device Manager". In the device manager window, expand the "Ports (COM and LPT)"...
  • Page 129 In this example, the COM port is assigned to "COM2". Downloaded from Elcodis.com electronic components distributor...
  • Page 130: Installation And Usage Of The Pc Writer

    Installation and usage of the PC writer This starter kit is shipped with the monitor program written in the FLASH area of the microcontroller. The monitor program must be running in order to connect to SOFTUNE, and to use the continuous run and stop functions. If for some reason the monitor program fails to operate correctly, the PC Writer must be used to rewrite it to the memory.
  • Page 131 Click "Next". Click "Install". Downloaded from Elcodis.com electronic components distributor...
  • Page 132 Wait for the installation to complete. Click the "Finish" button to complete the installation of the PC writer. After installing the PC writer, check the switch settings on the board before launching the software. Downloaded from Elcodis.com electronic components distributor...
  • Page 133 (2) Set MODE0 to "PROG". (3) MODE1 to "Debug". (1) Set to "USB Mini-B". (4) Set to "FUNC". Downloaded from Elcodis.com electronic components distributor...
  • Page 134 After setting the switches on the board, connect the PC and board using the USB B to Mini-B cable supplied with the starter kit. To USB Mini-B connector Do not connect the cable to "USB FUNC" "USB HOST". Downloaded from Elcodis.com electronic components distributor...
  • Page 135 After setting the switches on the board and connecting to the PC, launch PC Writer from the Windows Start menu. Click the "Set Environment" button and select the COM port being used. Refer to Appendix 12.1 to verify the COM port. Select the COM port and click "OK"...
  • Page 136 Click "Open", or drag and drop the file from Explorer onto the GUI to specify the file to write. The monitor program file is "monitor.mhx (*)". (*) bits_pot_black/monitor/monitor.mhx Click "Full Operation (D+E+B+P)". Downloaded from Elcodis.com electronic components distributor...
  • Page 137 When the following window appears, press the reset button on the board, and then click OK on the screen. After pressing reset button on the board, click "OK" on the PC application. To USB Mini-B connector Do not connect the cable to "USB FUNC"...
  • Page 138 Wait for the monitor program to finish writing to the microcontroller FLASH memory. Writing to FLASH is complete when the message "Full Operation OK!" appears. Click "OK" to close the window. Downloaded from Elcodis.com electronic components distributor...
  • Page 139: Monitor Debugger

    Monitor debugger Explanation of the monitor debugger Microcontrollers are usually made available as an evaluation device for program development and test evaluation (debugging), and as a production device. The evaluation device connects to the PC via an ICE (in-circuit emulator) that allows program development and debugging using SOFTUNE on the PC.
  • Page 140: Resources Used By Monitor Debugger

    Resources used by monitor debugger The resources used by the monitor debugger on this starter kit are listed in the following Table. Resource Condition Remarks Approximately 8 Kbytes 0x3E000 to 0x3FFFF FlashROM Approximately 8 Kbytes Monitor vector table is placed at 0xFE000 to 0xFFFFF 0xFFC00 to 0xFFFFF Multifunction...
  • Page 141: Memory Map With Monitor Debugger Installed

    Memory map with monitor debugger installed The figure below shows the memory map when the monitor debugger is installed on this starter kit. MB91F662  Built-in RAM  (48Kbyte)  Built ‒in ROM  (512Kbyte)  Downloaded from Elcodis.com electronic components distributor...
  • Page 142: Monitor Debugger Limitations

    Monitor debugger limitations The monitor debugger provided on this starter kit is functionally limited compared to an ICE as listed below. - "Program stop", "Reset" must be done by pressing the switch on the board. (This cannot be controlled from SOFTUNE on the PC.) - The operating clock for the CPU must not be changed as the monitor debugger program performs data communications internally with the PC using asynchronous communications.
  • Page 143: Stand-Alone Operation Of The Sample Program

    Stand-alone operation of the sample program The starter kit can run sample programs without launching the debugger. To run a program stand-alone, follow these procedures. Make sure the program operates normally using monitor debugger. Stop the monitor debugger Change the microcontroller operation mode switch settings on the board from debug mode to stand-alone mode.

This manual is also suitable for:

Mb91f662

Table of Contents