AN2673 Application note

Similar documents
AN2667 Application note

AN2676 Application note

AN2672 Application note

AN4113 Application note

STEVAL-CCM002V1. TFT-LCD panel demonstration board based on the STM32 as LCD controller. Features. Description

STEVAL-SPBT4ATV3. USB dongle for the Bluetooth class 1 SPBT2632C1A.AT2 module. Features. Description

AN2737 Application note Basic in-application programming example using the STM8 I 2 C and SPI peripherals Introduction

AN3996 Application Note

STEVAL-PCC010V1. ST802RT1A Ethernet PHY demonstration board with STM32F107 controller add-on board. Features. Description

AN626 Application note

STM32-MP3NL/DEC. STM32 audio engine MP3 decoder library. Description. Features

AN2143 Application note

STM3210B-SK/KEIL STR91X-SK/KEI, STR7-SK/KEIL

AN3279 Application Note

AN2470 Application note TS4871 low voltage audio power amplifier Evaluation board user guidelines Features Description

UM0792 User manual. Demonstration firmware for the DMX-512 communication protocol transmitter based on the STM32F103Zx.

AN3354 Application note

STM32-SK/KEIL STR91X-SK/KEI, STR7-SK/KEIL

AN2855 Application note

STM8 I 2 C optimized examples

UM0693 User manual. 1 Introduction. STM8L101-EVAL demonstration firmware

AN3980 Application note

ST19WR08 Dual Contactless Smartcard MCU With RF UART, IART & 8 Kbytes EEPROM Features Contactless specific features

UM1572 User manual. STEVAL-IPE020V1: ST energy meter application based on the Android platform. Introduction

STM3220G-SK/KEI. Keil starter kit for STM32F2 series microcontrollers (STM32F207IG MCU) Features. Description

EV-VNQ5E050AK VNQ5E050AK evaluation board

AN2240 Application note

STA bit single chip baseband controller for GPS and telematic applications. Features

AN2474 Application note

UM0401 User manual. User manual for eight bit port expander STMPE801 demonstration board. Introduction

OSPlus USB Extension. OSPlus USB 2.0 extension. Description. Features. Application. TCP/IP stack NexGenOS NexGenIP VFS. FAT Ext2 LVM Device layer

AN3965 Application note

AN2261 APPLICATION NOTE

EVAL6235PD. L6235 three-phase brushless DC motor driver demonstration board. Features. Description

AN3154 Application note

STTS V memory module temperature sensor. Features

STM32-SK/RAIS,STR91X-SK/RAI,STR7-SK/RAIS STM32-D/RAIS,STR9-D/RAIS,STR7-D/RAIS

AN2825 Application Note

STLC2500D. Bluetooth V2.1 "Lisbon" + EDR. Features. Description

AN2792 Application note

STICE CF/Stice_Connect AD/Stice_Connect AS/Stice_Connect

STM32 embedded target for MATLAB and Simulink release 3.1. Summary for STM32 embedded target for MATLAB and Simulink release 3.1:

ST33F1M. Smartcard MCU with 32-bit ARM SecurCore SC300 CPU and 1.25 Mbytes high-density Flash memory. Features. Hardware features.

AN2361 Application note

AN4274 Application note

EMIF02-MIC01F2 2-line IPAD, EMI filter including ESD protection Features Application Description Complies with the standards:

AN2734 Application note S-Touch design procedure Introduction

TN0189 Technical note

AN3265 Application note

AN3250 Application note

STEVAL-IHM028V1. 2 kw 3-phase motor control demonstration board featuring the IGBT intelligent power module STGIPS20K60. Features.

EMIF01-SMIC01F2 IPAD. Single line EMI filter including ESD protection. Main application. Description. Benefits. Pin configuration (Bump side view)

UM1488 User manual. STPMC1 evaluation software. Introduction

AN2592 Application note

SOT23-6L ESDALCL6-2SC6

ST21NFCB. Near field communication controller. Features. RF communications. Hardware features. Communication interfaces. Electrical characteristics

AN2202 Application note

ST19NP18-TPM-I2C Trusted Platform Module (TPM) with I²C Interface Features

EMIF02-SPK02F2. 2-line IPAD, EMI filter and ESD protection. Features. Application. Description. Complies with the following standards

AN2408 Application note

AN2557 Application note

Obsolete Product(s) - Obsolete Product(s)

AN2781 Application note

Main components USB charging controller with integrated power switch

UM1084 User manual. CR95HF development software user guide. Introduction. Reference documents

Description SPC564A-DISP. March 2014 DocID Rev 3 1/5

Main components 1 A, high efficiency adjustable single inductor dual mode buckboost DC-DC converter


AN2548 Application note

AN4321 Application note

AN3975 Application note

STM8-SK/RAIS STM8-D/RAIS ST7-SK/RAIS ST7-D/RAIS

AN3001 Application note

AN3362 Application note

STMicroelectronics. STxP70-4 assembler. User manual Rev A. October

LD A very low drop adjustable positive voltage regulator. Description. Features

AN2430 Application note

TN0132 Technical note

ST33F1M, ST33F1M0, ST33F896, ST33F768, ST33F640, ST33F512

L6460. SPI configurable stepper and DC multi motor driver. Features. Description

Getting started with DfuSe USB device firmware upgrade STMicroelectronics extension

STM8L-PRIMER STM32-PRIMER STMPRIMER

AN4440 Application note

SMP75. Trisil for telecom equipment protection. Features. Description. Applications. Benefits

AN2594 Application note

RN0046 Release note. 1 Introduction. SimpleMAC library for STM32W108xx kits. About this release note

AN3988 Application note

Description of STM8 LIN software package (STSW-STM8A-LIN) release 4.1. Table 1. Release information. STM8 LIN package

AN3174 Application note

AN3155 Application note

AN3140 Application note

ST10F271B/E, ST10F272B/E Errata sheet

AN2860 Application note

AN3991 Application note

How to interpret the LPS331AP pressure and temperature readings. Main components mbar absolute barometer with digital output

STM8L-PRIMER STM32-PRIMER STMPRIMER

AN2936 Application note

AN2768 Application note LIS331DL 3-axis digital MEMS accelerometer: translates finger taps into actions Introduction

UM0212 User manual. STOTG04 USB OTG full-speed transceiver demonstration board. Introduction

AN3099 Application note

Transcription:

Application note STM8A SPI application examples Introduction This application note is one of a set of application notes giving examples of how to use the various blocks of the STM8A microcontroller family and the STM8 firmware library. It is intended to provide three practical application examples of the use of the SPI peripheral in the STM8A device. The examples are: STM8A SPI in full-duplex communication with an LCD display. STM8A SPI in full-duplex communication with a MicroSD (MSD) card. STM8A SPI in full-duplex communication with an STM8A USART. The SPI is an extremely flexible peripheral which can simultaneously manage more than one type of communication and concurrently be a master and a slave in the same application. For further information on the STM8A family features, pinout, electrical characteristics, mechanical data and ordering information, please refer to the STM8AF61xx, STM8AF51xx datasheet. This document, its associated firmware, and other such application notes are written to accompany the STM8 firmware library. Please contact STMicroelectronics for information on the STM8 firmware library. April 2008 Rev 2 1/10 www.st.com

Contents AN2673 Contents 1 Example 1: STM8A SPI in full-duplex communication with an LCD display.................................................... 3 1.1 Overview.................................................. 3 1.2 Hardware description......................................... 3 1.3 Firmware description......................................... 4 2 Example 2: STM8A SPI in full-duplex communication with an MSD card....................................................... 5 2.1 Overview.................................................. 5 2.2 Hardware description......................................... 5 2.3 Firmware description......................................... 6 3 Example 3: STM8A SPI in full-duplex communication with an STM8A USART.................................................... 7 3.1 Overview.................................................. 7 3.2 Hardware description......................................... 7 3.3 Firmware description......................................... 8 4 Revision history............................................ 9 2/10

Example 1: STM8A SPI in full-duplex communication with an LCD display 1 Example 1: STM8A SPI in full-duplex communication with an LCD display 1.1 Overview This section describes how to set an STM8A SPI in full-duplex communication using software slave management with an LCD display. This type of communication management allows master to slave and slave to master adjustment without any hardware modification. Effectively, hardware constraints are removed in such devices. In the current example, the device SPI is the master and an LCD display is the slave. 1.2 Hardware description Figure 1 shows a typical connection, in full-duplex mode, between the STM8A SPI and an HXM122032-GB1 TM LCD display. The data output (MOSI) and clock (SCK) lines of the STM8A SPI are connected respectevely to the data input (SID) and clock (CLK) lines of the LCD display. However, the NSS pin is kept unconnected when using software slave management. Communication between the device and LCD display is thus managed using only the MOSI and CLK pins. A potentiometer can be used to adjust the contrast of the LCD display. Figure 1. STM8A SPI in full-duplex communication with an LCD display +5 V Potentiometer +5 V Key 4.7 kω PC0 Master SPI_MOSI VD SID Slave 100 nf SPI_SCK CLK 100 Ω LD1, LD2, LD3 and LD4 PH3:0 STM8A PFO +5 V CS A K LCD display HXM122032-GB1 600 Ω ai15025a 3/10

Example 1: STM8A SPI in full-duplex communication with an LCD display AN2673 1.3 Firmware description The STM8 firmware library includes the SPI driver which supports all SPI communications through a set of functions. The current example is provided as SPI example 1 in the STM8 firmware library. By default, the LCD display is the slave. A data buffer of commands is sent from the SPI master (STM8A) to the SPI slave. The LCD executes the commands and displays data on the screen. The following actions are then performed: The LCD display is cleared The ST logo is displayed The LCD prints output data Note: The key button can be used to turn the board LEDs on/off. 4/10

Example 2: STM8A SPI in full-duplex communication with an MSD card 2 Example 2: STM8A SPI in full-duplex communication with an MSD card 2.1 Overview This section describes how to set an STM8A SPI in full-duplex communication using software slave management with an MSD card. This type of communication can also be achieved through the LCD display of example 1, as both an LCD display and an MSD card can be managed by SPI protocol. The current example focusses on SPI management of an MSD card. 2.2 Hardware description Figure 2 shows a typical connection, between the STM8A SPI and the PJS008-2000 TM MSD card through an MAX3378EEUD TM level translator. Figure 2. STM8A SPI in full-duplex communication with an MSD card SPI_MOSI SPI_MISO SPI_SCK PE5 PE4 STM8A IOVCC_4 IOVCC_2 IOVCC_3 IOVCC_1 +5 V IOVL_1 IOVL_2 IOVL_4 IOVL_3 Level translator MAX33 78EEUD 10 kω +3.3 V 4.7 kω Pin 2 Pin 3 Pin 7 Pin 5 Pin 10 MSD connector PJS008-2000 ai15026a 5/10

Example 2: STM8A SPI in full-duplex communication with an MSD card AN2673 2.3 Firmware description The current example is provided as SPI example 2 in the STM8 firmware library. By default the MSD card is the slave. An external interrupt signals that the MSD card is plugged and has been detected. This initiates STM8A SPI-MSD card comunication and the following actions are performed: Buffer block_tx is filled with the value 0x00 which is sent from the STM8A SPI to the MSD card. The data received are stored in the MSD card block 0. The MSD card block 0 is read and stored in buffer block_rx. These read data in buffer block Rx are then compared with the written values in buffer block_tx. The results of this comparison are stored in the "TransferStatus1" variable. Several blocks that have been writen by buffer block_tx and read by buffer block_rx, are compared to check that all data have been correctly exchanged. The results of these comparisons are stored in the "TransferStatus2" and "TransferStatus3" variables. Severel messages are displayed on the LCD display to guide the user through the different steps. Refer to Figure 1 for LCD connections. 6/10

Example 3: STM8A SPI in full-duplex communication with an STM8A USART 3 Example 3: STM8A SPI in full-duplex communication with an STM8A USART 3.1 Overview This section describes how to set an STM8A SPI in full-duplex communication with an STM8A USART using software slave management to control the key button. DataRx and DataTx are displayed on an LCD screen. 3.2 Hardware description Figure 3 shows a typical connection between the STM8A SPI and the STM8A USART. The data input (MISO), data output (MOSI) and clock (SCK) lines from the device SPI are connected respectively to the USART_Rx, USART_Tx and clock (USART_CLK) of the device USART. The NSS pin is kept unconnected due to software slave management. Figure 3. STM8A SPI in full-duplex synchronous communication with an STM8A USART SPI_MOSI SPI_MISO SPI_SCK USART_CK USART_Rx USART_Tx STM8A 7/10

Example 3: STM8A SPI in full-duplex communication with an STM8A USART AN2673 3.3 Firmware description The current example is provided as SPI example 3 in the STM8 firmware library. The STM8A SPI is set as both a master and a slave in the same application. To print interactive messages, the STM8A SPI is set as the master and the LCD display is set as the slave. To communicate with the USART in synchronous mode, the STM8A SPI is set as the slave and the STM8A USART is set as the master. When the key button (see Figure 1) is pressed by the user an interrupt is generated and the following actions are performed: The STM8A USART sends data (DataTx) to the STM8A SPI. The device SPI receives data (DataTx) from the device USART The device SPI sends data (DataTx), that can be received from the device USART, to the LCD display. The LCD prints data that can be sent by the device USART on line 1 and prints data that can be received by the device SPI on line 2. Data (DataTx) to be sent are incremented after each event on the key button. Note: Refer to Figure 1 for the LCD connections. 8/10

Revision history 4 Revision history Table 1. Document revision history Date Revision Changes 14-Mar-2008 1 Initial release 08-Apr-2008 2 Removed all references to the standard version of the STM8 9/10

Please Read Carefully: Information in this document is provided solely in connection with ST products. STMicroelectronics NV and its subsidiaries ( ST ) reserve the right to make changes, corrections, modifications or improvements, to this document, and the products and services described herein at any time, without notice. All ST products are sold pursuant to ST s terms and conditions of sale. Purchasers are solely responsible for the choice, selection and use of the ST products and services described herein, and ST assumes no liability whatsoever relating to the choice, selection or use of the ST products and services described herein. No license, express or implied, by estoppel or otherwise, to any intellectual property rights is granted under this document. If any part of this document refers to any third party products or services it shall not be deemed a license grant by ST for the use of such third party products or services, or any intellectual property contained therein or considered as a warranty covering the use in any manner whatsoever of such third party products or services or any intellectual property contained therein. UNLESS OTHERWISE SET FORTH IN ST S TERMS AND CONDITIONS OF SALE ST DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY WITH RESPECT TO THE USE AND/OR SALE OF ST PRODUCTS INCLUDING WITHOUT LIMITATION IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE (AND THEIR EQUIVALENTS UNDER THE LAWS OF ANY JURISDICTION), OR INFRINGEMENT OF ANY PATENT, COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT. UNLESS EXPRESSLY APPROVED IN WRITING BY AN AUTHORIZE REPRESENTATIVE OF ST, ST PRODUCTS ARE NOT DESIGNED, AUTHORIZED OR WARRANTED FOR USE IN MILITARY, AIR CRAFT, SPACE, LIFE SAVING, OR LIFE SUSTAINING APPLICATIONS, NOR IN PRODUCTS OR SYSTEMS, WHERE FAILURE OR MALFUNCTION MAY RESULT IN PERSONAL INJURY, DEATH, OR SEVERE PROPERTY OR ENVIRONMENTAL DAMAGE. Resale of ST products with provisions different from the statements and/or technical features set forth in this document shall immediately void any warranty granted by ST for the ST product or service described herein and shall not create or extend in any manner whatsoever, any liability of ST. ST and the ST logo are trademarks or registered trademarks of ST in various countries. Information in this document supersedes and replaces all information previously supplied. The ST logo is a registered trademark of STMicroelectronics. All other names are the property of their respective owners. 2008 STMicroelectronics - All rights reserved STMicroelectronics group of companies Australia - Belgium - Brazil - Canada - China - Czech Republic - Finland - France - Germany - Hong Kong - India - Israel - Italy - Japan - Malaysia - Malta - Morocco - Singapore - Spain - Sweden - Switzerland - United Kingdom - United States of America www.st.com 10/10