Application Note AN_191. Vinculum-II Interrupts

Similar documents
Application Note AN_163. Vinculum-II USB Slave Disconnect Detection

Technical Note TN_173. UMFT4222PROG-IC Errata

Application Note AN_207 USB-DUO

Application Note AN_302. Comparison of Device / Software features for FT313H and ST- Ericsson ISP1763

Future Technology Devices International Ltd. Application Note AN_172. Vinculum-II. Using the USB Slave Driver

Future Technology Devices International Ltd. TN_142 FT120 Errata Technical Note

FTDI Chip. VI800A-232U Datasheet Plug in accessory for VM800P Embedded Video Engine Plus module. 1.1 Features. 1 Introduction

Application Note AN_423 FT_App_Imageviewer

Future Technology Devices International Ltd. TN_145 FT311D Errata Technical Note

Application Note AN_193. Vinculum-II SPI Master to USB HID Class Host Bridge

Technical Note TN_175 FT4222H Revision D

Application Note AN_144. VINCULUM-II IO_Mux Configuration Utility User Guide

Application Note AN_145. Vinculum-II Toolchain. Installation Guide

Future Technology Devices International

TN_130 FT232H Errata Technical Note

Future Technology Devices International Limited

AN_357. Android Java D2xx Demo Application for FT4222

Application Note AN_182. Vinculum-II UART to FT232Host Bridge

Future Technology Devices International Ltd. TN_118 Vinculum-II Errata Technical Note

Future Technology Devices International Ltd

Future Technology Devices International Ltd. TN_124 FT2232D Errata Technical Note

Future Technology Devices International Ltd. TN_137 FT220X Errata Technical Note

Future Technology Devices International Ltd. TN_140 FT231X Errata Technical Note

Future Technology Devices International Ltd. Application Note AN_168. Vinculum-II USB Slave. Customizing an FT232 Device

FT4232H-56Q Mini Module. USB Hi-Speed FT4232H Evaluation Module. Datasheet

Future Technology Devices International

Future Technology Devices International Ltd

Technical Note. TN_134 FTDI Android D2XX Driver

Future Technology Devices International Ltd. TN_161 FT4222H Errata Technical Note

TN_120 FT232R Errata Technical Note

UMFT4222PROG FT4222 Programmer Module

Application Note AN_164. Vinculum-II USB Slave. Writing a Function Driver

UMFT4222PROG FT4222 Programmer Module

Future Technology Devices International Ltd

Application Note AN_189. Vinculum-II Using the LFAT Driver

V2DIP2-32. VNC2-32Q Development Module Datasheet

Technical Note TN_107

Future Technology Devices International Limited

Application Note AN_335. FT801 Graph Application

Future Technology Devices International Limited

TTL-234X. TTL234X Series Range of Cables. Datasheet

Future Technology Devices International Ltd

Future Technology Devices International Ltd. FTDI Drivers Installation guide for. Windows 7

Vinculum-II Debug Interface Description

Future Technology Devices International Ltd

C232HD. USB 2.0 Hi-Speed to UART Cable. Datasheet

Migrating Vinculum Designs From VNC1L to VNC2-48L1A

Future Technology Devices International

Application Note AN_146. USB Hardware Design Guidelines for FTDI ICs

TTL-232R-PCB. TTL to USB Serial Converter PCB. Datasheet

V2DIP2-48. VNC2-48 Development Module. Datasheet

Future Technology Devices International Ltd. V-Eval USB Missile Launcher. Application Note

Future Technology Devices International

FTDI Chip VA800A-SPI USB 2.0 Hi-Speed to MPSSE SPI Module

V2DIP1-64. VNCL2-64Q Development Module Datasheet

FTDI Chip. VI800A-PoE Datasheet Plug in accessory for VM800P Embedded Video Engine Plus module. 1.1 Features. 1 Introduction

FTDI Chip. VA800A PROG Datasheet Programmer for VM800P Embedded Video Engine Plus module. 1.1 Features. 1 Introduction

V2DIP1-48. VNC2-48 Development Module. Datasheet

TTL-232R. TTL to USB Serial Converter Range of Cables. Datasheet

FT2232H Mini Module. USB Hi-Speed FT2232H Evaluation Module. Datasheet

Future Technology Devices International Ltd. OSX. Document Reference No.: FT_ Version 1.0 Issue Date:

Future Technology Devices International Ltd

USB-COM232-PLUS1. Datasheet

USB-COM232-PLUS1. Datasheet

Vinculo Development Module. Datasheet

Future Technology Devices International Ltd

Bridgetek Pte Ltd. Datasheet CleO35-WIFI Module. 1 Introduction. 1.1 Features. CleO35-WIFI Module Datasheet Version 1.0

Future Technology Devices International Ltd

Future Technology Devices International Ltd Vinculum Firmware Tools User Manual

TTL-232RG. TTL to USB Serial Converter Generic Cables. Datasheet

Vinculo Development Module. Datasheet

Application Note AN_342. FT90x Assembly Language Programming Guide

Future Technology Devices International Ltd USB TO RS485 UART SERIAL CONVERTER PCB. Datasheet

USB-COM485-PLUS1. Datasheet

Future Technology Devices International Ltd

Application Note AN_124. User Guide For FTDI FT_Prog Utility

Future Technology Devices International Ltd

Bridgetek Pte Ltd. CleOIO-Shield Module Datasheet. 1 Introduction. 1.1 Features. CleOIO-Shield Module Datasheet Version 1.0

Future Technology Devices International Ltd. DB9-USB Family of UART Converter Modules Datasheet

TTL-232R-PCB. TTL to USB Serial Converter PCB. Datasheet

USB-COM232-PLUS1. Datasheet

UB232R. USB Mini-B FT232R Evaluation Module. Datasheet

Future Technology Devices International Limited

APPLICATION NOTE AN_261. FT_App_Clocks

Future Technology Devices International Ltd

FTDI Chip. VM800P Datasheet Embedded Video Engine Plus Module. VM800P Embedded Video Engine Plus Module Datasheet Version 1.3

Future Technology Devices International

The DB9-USB Family of USB to. UART Converter Modules. Datasheet

USB-COM422-PLUS4. Datasheet

Bridgetek Pte Ltd. Datasheet MM930Mini Module High Speed USB-Serial MCU Development Module. 1 Introduction. 1.1 Features

TTL-232R. TTL to USB Serial Converter Range of Cables. Datasheet

Future Technology Devices International

Future Technology Devices International

Future Technology Devices International Ltd UMFT4222EV. USB2.0 to QuadSPI/I2C Bridge Development Module Datasheet

Future Technology Devices International Ltd UMFT313EV Development Module Datasheet

Application Note AN_142 AN_142 Vinculum-II Tool Chain Getting Started Guide

FTDI Ltd DS_US232R-10(R-100) USB to RS232 Adapter cable. Data Sheet. Document Reference No.: FT_ Version 1.0 Issue Date:

Future Technology Devices International Ltd. FT602Q IC Datasheet. (FIFO to USB 3.0 UVC Bridge) Version 1.2

EasySync Ltd. ES-R-2x01-M RS232 to RS422 / RS485 Converter. User Guide. Document Reference No.: ES_ Version draft Issue Date:

Bridgetek Pte Ltd. VM816C Datasheet Embedded Video Engine Credit Card Board. 1 Introduction. 1.1 Features

Transcription:

AN_191 Vinculum-II Interrupts Issue Date: 2012-06-22 This application note introduces interrupts, and how they are implemented in the FTDI Vinculum-II device. A hardware example is provided. Use of FTDI devices in life support and/or safety applications is entirely at the user s risk, and the user agrees to defend, indemnify and hold FTDI harmless from any and all damages, claims, suits or expense resulting from such use. Future Technology Devices International Limited (FTDI) Unit 1, 2 Seaward Place, Glasgow G41 1HH, United Kingdom Tel.: +44 (0) 141 429 2777 Fax: + 44 (0) 141 429 2758 Web Site: http://ftdichip.com

Table of Contents 1 Introduction... 2 1.1 Hardware used to demonstrate GPIO interrupt... 2 1.2 Available VNC2 Interrupts... 3 1.3 Levels and Edges... 3 2 Firmware Details... 4 2.1 Configure IOMux... 5 2.2 Configure GPIO Interrupts... 6 2.3 Wait for Interrupt... 7 3 Using IDE to Monitor Thread States... 8 4 Conclusion... 9 5 Contact Information... 10 Appendix A References... 11 Document References... 11 Acronyms and Abbreviations... 11 Appendix B List of Tables & Figures... 12 List of Tables... 12 List of Figures... 12 Appendix C Revision History... 13 1

1 Introduction This document explains what interrupts are, why they are useful for embedded programmers, and how they are implemented in Vinculum-II (VNC2) firmware. A sample hardware application is used to demonstrate how interrupts are used in a real world example. The FTDI Vinco board and a 3 rd party LCD shield will be used in the example. The reader should be familiar with the VNC2 IDE and Vinco development board. It is also assumed that the reader has an understanding of the Vinculum Operating System (VOS). Interrupts are used in embedded systems to signal the processor that an external event has taken place. Examples could include the arrival of data on a bus, flipping a switch or if a specific amount of time has passed. Interrupts allow designers to isolate time critical operations from the main program to guarantee they are processed in a timely manner. Since interrupts are asynchronous, they can occur at any time when the main program is running. An interrupt mask is used to select the desired type of interrupt. After reading this app note, the reader will be able to understand and write interrupt based code for the Vinculum II. 1.1 Hardware used to demonstrate GPIO interrupt Vinco development board LCD Shield for Arduino/Vinco VNC2 Debugger module External pushbutton Appendix A has the datasheet links for the above hardware. Figure 1.1 LCD Shield for Vinco 2

1.2 Available VNC2 Interrupts The following VNC2 ports and interfaces have interrupt support: USB Port GPIO Port SPI Port PWM Interface FIFO Port USB Host 0 GPIO Port A SPI Master PWM FIFO USB Host 1 GPIO Port B SPI Slave 1 USB Slave 1 SPI Slave 2 USB Slave 2 Table 1.1 Available VNC2 Interrupts An interrupt mask is used to select one of the above interrupts. In this application note, GPIO Port pin B_0 (Pin 51) will be used as an interrupt. Multiple interrupts such as PWM and GPIO are allowed since they are different functions. For GPIO interrupts, Port B supports interrupts from a specified pin. Port A will trigger an interrupt if any of the Port A pins toggle. 1.3 Levels and Edges Level sensitive interrupts force the VNC2 to respond as long as the interrupt signal is at a specified level. Edge sensitive interrupts force the VNC2 to respond when the interrupt signal makes a transition. Levels can be logic low or logic high, edges can be rising or falling. Figure 1.2 shows a positive level sensitive interrupt and a falling edge sensitive interrupt. Figure 1.2 Interrupt Types 3

2 Firmware Details In this section, the function calls used to configure an interrupt and send the result to a LCD display will be discussed. The source code can be downloaded from the following link http://www.ftdichip.com/support/softwareexamples/vinculumiiprojects/an_191_source_code.zip Figure 2.1 shows the basic operation of the interrupt application code. Figure 2.1 Interrupt Application Flowchart 4

2.1 Configure IOMux The Vinco module needs to have its GPIO signals configured to interface with the LCD shield. A 16x2 monochrome LCD is used. The LCD control code is explained in more detail in Application Note AN_153, Vinco LCD Interface Example. Pin 51 is the interrupt input. To sensitize this input for a falling edge interrupt, it has been configured as: Schmitt Trigger Fast slew rate 75K Pull Up if (vos_get_package_type() == VINCULUM_II_64_PIN) { // GPIO_Port_A_0 to pin 57 as Output. vos_iomux_define_output(57, IOMUX_OUT_GPIO_PORT_A_0); //LCD DB4 input // GPIO_Port_A_1 to pin 58 as Output. vos_iomux_define_output(58, IOMUX_OUT_GPIO_PORT_A_1); //LCD DB5 input // GPIO_Port_A_2 to pin 59 as Output. vos_iomux_define_output(59, IOMUX_OUT_GPIO_PORT_A_2); //LCD DB6 input // GPIO_Port_A_3 to pin 60 as Output. vos_iomux_define_output(60, IOMUX_OUT_GPIO_PORT_A_3); //LCD DB7 input // GPIO_Port_A_6 to pin 17 as Output. vos_iomux_define_output(17, IOMUX_OUT_GPIO_PORT_A_6); //LCD RS input // GPIO_Port_A_7 to pin 18 as Output. vos_iomux_define_output(18, IOMUX_OUT_GPIO_PORT_A_7); //LCD EN input // GPIO_Port_C_3 to pin 23 as Output. //Port C is used to isolate this signal vos_iomux_define_output(23, IOMUX_OUT_GPIO_PORT_C_3); //Backlight for LCD // GPIO_Port_B_0 to pin 51 as Input. // Configure for Port B_0 Interrupt vos_iomux_define_input(51, IOMUX_IN_GPIO_PORT_B_0); vos_iocell_set_config(51, VOS_IOCELL_DRIVE_CURRENT_4MA, VOS _IOCELL_TRIGGER_SCHMITT, VOS_IOCELL_SLEW_RATE_FAST, VOS_IOCELL_PULL_UP_75K); } 5

2.2 Configure GPIO Interrupts To set up a GPIO interrupt, the following steps must take place: Set interrupt mask for interrupts on GPIO B Specify which pin on port B to monitor Specify if interrupt is level sensitive or edge sensitive Specify the polarity of the interrupt (high/low level, rising/falling edge) Enable/Disable the interrupt //Open GPIO Port B hgpiob = vos_dev_open(gpiob); // Setup Interrupt Mask for GPIO B gpio_iocb.ioctl_code = VOS_IOCTL_GPIO_SET_MASK; gpio_iocb.value = 0x00 ; //set all as input vos_dev_ioctl(hgpiob, &gpio_iocb); // Setup Interrupt for INT_0 on port B_0 gpio_iocb.ioctl_code = VOS_IOCTL_GPIO_SET_PROG_INT0_PIN; gpio_iocb.value = GPIO_PIN_0; // Port B_0 vos_dev_ioctl(hgpiob, &gpio_iocb); // Setup for Interrupt on falling edge transition gpio_iocb.ioctl_code = VOS_IOCTL_GPIO_SET_PROG_INT0_MODE; gpio_iocb.value = GPIO_INT_ON_NEG_EDGE; vos_dev_ioctl(hgpiob, &gpio_iocb); // Enable interrupt vos_enable_interrupts(vos_gpio_int_ien); 6

2.3 Wait for Interrupt The GPIO_B0 interrupt works by monitoring the state of this input. A Waiting on Interrupt message is sent to the LCD before configuring the interrupt. Before the interrupt triggers, the VOS_IOCTL_WAIT_ON_INT0 call blocks a 2 nd write to the LCD display. A pushbutton is connected between port B0 and a ground pin, as illustrated in Figure 1.1 When B0 makes a high to low transition (pushbutton is pressed), the rest of the thread is unblocked and is allowed to execute. To simplify the design of the interrupt, the state of port B is read by VOS_DEV_READ when the interrupt triggers. The default state of port has been set to 0xFF. When a B0 goes low, port B is no longer 0xFF, and an Interrupt Triggered message is sent to the LCD display. Pre-interrupt string to display: unsigned char *lcd_str ; unsigned char *lcd_str1, *lcd_str2; lcd_str1 = "Waiting..."; lcd_str2 = "For Interrupt"; Wait for interrupt code: gpio_iocb.ioctl_code = VOS_IOCTL_GPIO_WAIT_ON_INT0; vos_dev_ioctl(hgpiob, &gpio_iocb); //Code is blocked from executing until interrupt occurs //Read the state of Port B (preset to 0xFF) vos_dev_read(hgpiob, &B0,1,&num_read); // If Port B is not 0xFF, we have confirmed the interrupt // Write message to LCD indicating interrupt was triggered if (B0!= 0xFF) { lcd_str1 = "Interrupt B0 Has"; lcd_str2 = "Been Triggered"; } } } while (1); 7

3 Using IDE to Monitor Thread States The firmware thread in the code has been labeled as Interrupt Thread by the vos_create_thread_ex call. // create thread for firmware application (no parameters) tcbfirmware = vos_create_thread_ex(29, SIZEOF_THREAD_MEMORY, firmware, "Interrupt Thread", 0); This allows the IDE s Thread Manager to display the state of the interrupt thread before and after execution. The IDE must be used in debug mode for the Thread Manager to work. While waiting for interrupt on GPIO B0, thread is blocked: Figure 3.1 Thread Manager Pre-Interrupt After Interrupt has triggered on GPIO B0, thread is unblocked: Figure 3.2 Thread Manager Post-Interrupt 8

4 Conclusion This document has introduced basic GPIO interrupts with the Vinculum-II. Other Vinculum-II interfaces can initiate interrupts, such as pulse width modulation (PWM) and Serial Peripheral Interface (SPI). 9

5 Contact Information Head Office Glasgow, UK Future Technology Devices International Limited Unit 1, 2 Seaward Place, Centurion Business Park Glasgow G41 1HH United Kingdom Tel: +44 (0) 141 429 2777 Fax: +44 (0) 141 429 2758 E-mail (Sales) E-mail (Support) E-mail (General Enquiries) sales1@ftdichip.com support1@ftdichip.com admin1@ftdichip.com Branch Office Hillsboro, Oregon, USA Future Technology Devices International Limited (USA) 7235 NW Evergreen Parkway, Suite 600 Hillsboro, OR 97123-5803 USA Tel: +1 (503) 547 0988 Fax: +1 (503) 547 0987 E-Mail (Sales) E-Mail (Support) E-Mail (General Enquiries) us.sales@ftdichip.com us.support@ftdichip.com us.admin@ftdichip.com Branch Office Taipei, Taiwan Future Technology Devices International Limited (Taiwan) 2F, No. 516, Sec. 1, NeiHu Road Taipei 114 Taiwan, R.O.C. Tel: +886 (0) 2 8791 3570 Fax: +886 (0) 2 8791 3576 E-mail (Sales) E-mail (Support) E-mail (General Enquiries) asia.sales1@ftdichip.com asia.support1@ftdichip.co m asia.admin1@ftdichip.com Branch Office Shanghai, China Future Technology Devices International Limited (China) Room 1103, No. 666 West Huaihai Road, Shanghai, 200052 China Tel: +86 21 62351596 Fax: +86 21 62351595 E-mail (Sales) E-mail (Support) E-mail (General Enquiries) cn.sales@ftdichip.com cn.support@ftdichip.com cn.admin@ftdichip.com Web Site http://ftdichip.com System and equipment manufacturers and designers are responsible to ensure that their systems, and any Future Technology Devices International Ltd (FTDI) devices incorporated in their systems, meet all applicable safety, regulatory and system-level performance requirements. All application-related information in this document (including application descriptions, suggested FTDI devices and other materials) is provided for reference only. While FTDI has taken care to assure it is accurate, this information is subject to customer confirmation, and FTDI disclaims all liability for system designs and for any applications assistance provided by FTDI. Use of FTDI devices in life support and/or safety applications is entirely at the user s risk, and the user agrees to defend, indemnify and hold harmless FTDI from any and all damages, claims, suits or expense resulting from such use. This document is subject to change without notice. No freedom to use patents or other intellectual property rights is implied by the publication of this document. Neither the whole nor any part of the information contained in, or the product described in this document, may be adapted or reproduced in any material or electronic form without the prior written consent of the copyright holder. Future Technology Devices International Ltd, Unit 1, 2 Seaward Place, Centurion Business Park, Glasgow G41 1HH, United Kingdom. Scotland Registered Company Number: SC136640 10

Appendix A References Document References AN_142 Vinculum II Tool Chain Getting Started Guide AN_153 Vinco LCD Interface Example AN_151 Vinculum User Guide Arduino LCD Keypad Shield Web Page Arduino LCD Keypad Shield Technical Details Vinco Datasheet http://www.ftdichip.com/support/softwareexamples/vinculumiiprojects/an_191_source_code.zip Acronyms and Abbreviations Terms LCD Shield Interrupt Interrupt Mask Edge Sensitive Interrupt Level Sensitive Interrupt Description An Arduino compatible plug in LCD display that is easily adapted for use with the FTDI Vinco board. A signal that indicates an external event has taken place. A command that selects which type of hardware interrupt to process. An interrupt event triggered by a falling or rising edge An interrupt triggered by a high or low logic level. 11

Appendix B List of Tables & Figures List of Tables Table 1.1 Available VNC2 Interrupts... 3 List of Figures Figure 1.1 LCD Shield for Vinco... 2 Figure 1.2 Interrupt Types... 3 Figure 2.1 Interrupt Application Flowchart... 4 Figure 3.1 Thread Manager Pre-Interrupt... 8 Figure 3.2 Thread Manager Post-Interrupt... 8 12

Appendix C Revision History Document Title: AN_191 Vinculum 2 Interrupts Document Reference No.: FT_000531 Clearance No.: FTDI# 299 Product Page: http://www.ftdichip.com/ftproducts.htm Document Feedback: Send Feedback Revision Changes Date draft Initial draft subject to change 2012-05-16 1.0 First Release 2012-02-22 13