STM32 Primer2 Manual
STM32 Primer2 Manual
User manual
Document version
2009-03-19
Contents
1 Presentation.......................................................................................................................4 2 The STM32-Primer2 hardware..........................................................................................5
2.1 List of Contents...............................................................................................................................5 2.2 Description.....................................................................................................................................5 2.3 Opening the STM32-Primer2 case.................................................................................................6 2.4 Inserting and removing a MicroSD card.........................................................................................6 2.5 STM32 microcontroller features.....................................................................................................7 2.6 3D MEMS accelerometer...............................................................................................................7 2.7 Power supply..................................................................................................................................7 2.8 The extension connector................................................................................................................8 2.9 Application-specific daughter-boards...........................................................................................11 2.10 For further information................................................................................................................11
3 Getting started..................................................................................................................12
3.1 Connect battery, charge and power up.........................................................................................12 3.2 Play..............................................................................................................................................12 3.3 Install the Ride7 software toolset for ARM....................................................................................13 3.4 Play with an STM32 application example.....................................................................................13
-2-
6 Recycling..........................................................................................................................24
-3-
1 Presentation
1 Presentation
The STM32-Primer2 is an innovative, low-cost evaluation and development package that is designed to provide a fun and easy introduction to the features of the STM32 with ARM Cortex-M3 core. Based on the previous STM32-Primer (released in 2007), Raisonance developed the STM32-Primer2 thanks to an innovative design and a very active user community. With more user interface options, longer lasting Li-Ion power supply, more hardware peripherals and an STM32F103V with more memory (512 KB of Flash ROM, 64 KB of RAM) than before, the Primer2 is the complete, low-risk environment for starting your application.
The STM32-Primer2s ergonomic design with MEMS-based controls (navigate by tilting the tool left, right, backward or forward), touch-screen backlit LCD display, a joystick, 4 menu push buttons, CAN and IrDA a MicroSD memory card slot and an hardware audio codec with microphone/speaker/headphones interface provide fun and easy control of the included demonstration firmware that includes graphical user interface and games based on the resources of the STM32 microcontroller.
Illustration 1.1: STM32-Primer2 presentation The included firmware (CircleOS task scheduler, system services and demonstration applications) implements low level functions driving the various STM32 peripherals. In addition, it includes features for dynamic loading and management of new applications. All firmware, demos (C sources and projects) and more future applications are available for free download at the STM32-Primer2 dedicated site, http://www.stm32circle.com/. The STM32-Primer2 and Ride7 software toolset provide everything needed for programming the STM32 and debugging applications, including: 1. USB host connection for in-circuit programming and debugging 2. Ride7 integrated development environment for code editing, device programming and application debugging (debug up to 32K of code, with included version. For information about upgrade to an unlimited version of Ride, visit http://www.stm32circle.com/resources). 3. GNU C /C++ compiler (unlimited compiling)
-4-
2.2 Description
Here is a brief overview of the main components of the STM32-Primer2:
MicroSD slot Joystick USB debug connector 3D MEMS sensor 4 menu buttons Loudspeaker
Headphones jack
Microphone
-5-
The STM32-Primer2 provides the following devices: A touch-screen LCD color display (24-bits color, 128x160 pixels), 2 USB connectors: 1. One marked "Debug" to connect to a PC running Ride for application development, 2. One marked "STM32" that allows the embedded application to communicate with an external USB host. One 4-directions joystick with push button, 4 menu buttons, An on-board microphone and a loudspeaker providing sound recording and playback capabilities, an headphones connector, One accelerometer (MEMS) that captures the 3D-position information related to the STM32Primer2, and which is used to navigate through the menus, and to move the pointer, One IrDA transmitter that allows communication between two STM32-Primer2, One extra connector is linked to some unused I/O pins of the STM32 in order to add extra peripherals.
-6-
-7-
2 3
GND CX_I2CSCL.
GND PB.6
CX_I2CSDA.
PB.7
-8-
AUDIO_I2S2_WS
PB.12
Can be used either as a standard GPIO or considered as an alternate function: - SPI2_MOSI - TIM1_CH3N(6) Note that SPI2 is also connected to the audio device for recording audio data from the microphone. This feature must be disabled when SPI2 is used with the extension board.
9 10 11 12 13
Connected to the CAN transceiver. When the CAN transceiver is not soldered, these pins could be easily connected to PD.2-PD.3 on the STM32 by shortcutting the signals on the footprint of the CAN transceiver. Can be used either as a standard GPIO or considered as an alternate function: ADC12_IN14 Can be used either as a standard GPIO or considered as an alternate function: ADC12_IN15 Can be used either as a standard GPIO or considered as an alternate function: - ADC12_IN8 - TIM3_CH3 - TIM1_CH2N (if remapped) PA0/WKUP/ADC IN0Can be used either as a standard GPIO or considered as an alternate function: - WKUP - USART2_CTS - ADC12_IN0 - TIM2_CH1_ETR Can be used either as a standard GPIO or considered as an alternate function: - USART2_RTS - ADC12_IN1 - TIM2_CH2 Can be used either as a standard GPIO or considered as an alternate function: - USART2_TX - ADC12_IN2 - TIM2_CH3 Can be used either as a standard GPIO or considered as an alternate function: - SPI1_NSS - USART2_CK - ADC12_IN4
14
CX_USART_CTS
PA.0
15
CX_USART_RTS
PA.1
16
CX_USART_TX
PA.2
17
CX_USART_CK
PA.4
-9-
19 20
Ground
Notes: In case you need CAN connectivity, you will need to solder a CAN transceiver (model MAX3051ESA from Maxim). Its footprint is identified on the picture below. SPI2 is used for recording purposes on your Primer. Recording facilities must not be enabled in CircleOS if you need to use SPI2 through the extension connector.
The following picture shows the part of the printed circuit that contains the extension connector in order to help you identify the connector pinout; pins 1 and 2 of the extension connector have been identified on the picture. Also the footprint for the (unsoldered) CAN transceiver is shown on the picture.
- 10 -
- 11 -
3 Getting started
3 Getting started
3.1 Connect battery, charge and power up
Your STM32-Primer2 is initially shipped with the battery disconnected, in order to prevent discharging and potentially harming the battery. You need to connect the battery before operating your Primer2: 1. Open the STM32-Primer2s case by pulling the top and bottom halves of the case apart. There are no catches or releases that hold the case together. 2. Fit the jumper so that it straddles the two pins to connect the power supply. 3. Close the case. 4. Connect the Primer2 to the USB port on a PC to charge its battery. Only the Red LED (L4) will be lit if the battery is charging. The Green LED (L1) is lit when fully charged. 5. After charging the battery, press the push button to activate the Primer2.
3.2 Play
After the opening screen is displayed, press the push button to call the main menu. Tilt the Primer2 backward/forward or use the joystick to navigate in the menu, use the push button to select a menu command. Initial menu items include: Config Maze Applic About Shutdown Configure parameters for the Primer2 including the pointer, backlight for the LCD display and time This is an addictive game provided as an example. Full source is available from www.stm32circle.com. Select an application to run. The application that you choose will then appear in the main menu. Display information about the CircleOS version and available memory. Turn off the Primer2. To restart the Primer2, simply press the push button.
Note: When you receive the Primer2, the MEMS based controls are calibrated to a zero position that matches a 30 angle from the horizontal (corresponds to the position of a book when reading). To practice controlling the Primer2, move the blue dot around the main screen. It takes a little practice. Preinstalled applications The Primer2 includes preinstalled applications: Maze A game where the player navigates inside a labyrinth, eating dots to win points while avoiding ghosts.
- 12 -
3 Getting started
Breakout A game where the player uses a paddle to bounce a ball against a wall of blocks, destroying the block to win points. Win the game by destroying all the blocks. COMMTEST Tests the MicroSD card connector. EchoIrDA This is an IrDA echo application, which makes it easy to connect your Primer2 to another IrDA appliance such as a cell phone or another Primer2.
Configuration menu Configuration and test applications have been pre-installed in order to check your STM32-Primer2s capabilities. From the main menu of the STM32-Primer2, launch the Config command. The following parameters can be set: 1. CPU Freq. This lets you choose the speed of your STM32-Primer2. 2. Backlight. This lets you tune the backlight intensity. Note that the backlight is the main source of power consumption (with the LCD monitor itself). Reducing the backlight intensity allow to extend the duration when Primer2 is powered by the battery. 3. Time. This sets your STM32-Primer2 time. Note that the RTC clock will remain valid even if your STM32-Primer2 is shut off. 4. Test. This performs a quick factory test of the STM32-Primer2. You can add more applications to your STM32-Primer2 by downloading them on the web site www.stm32circle.com/projects. Refer to the chapter 4 Managing your CircleOS applications.
To install, just insert the Raisonance mini CD-ROM on your PC, a menu will appear. Just follow the online instructions for installing the software. Note: Ride7 should be installed before connecting to this USB port.
- 13 -
do_nothing
The (CPU_freq / SysTick = 24000) ratio is applied for all these values.
- 14 -
The periodic systick makes a call to the CircleOS systick interrupt handler. This interrupt handler will perform a short processing on each of the STM32-Primer2 components: LEDs, button, buzzer, LCD. Note that the MEMS handler is called from the Timer2 interrupt, which has a priority higher than the Systick interrupt. This ensures a fixed and precise measurement rate. I2S transfers towards the audio Codec chip are handled through the I2S interrupt.
The priority level of the timer2 is HIGHER than the SYSTICK priority. It is mandatory to keep this IRQ at the highest level in order to guarantee proper I2C communication behavior. Indeed, the I2C functions called from the Timer2 interrupt handler could loop for ever if they are themselves interrupted. Note that the frequency of the Timer2 overflow has been set to read a maximum number of measurements from the MEMS. However, this high rate is often useless, and you could easily change this frequency to save CPU time, or to get some more stable data from the MEMS.
- 15 -
FLASH
512KB (non debuggable part) 128KB ... Application k 24KB ... Application 3 8KB ... Application 2 4KB ...
0x80008000 0x80041000 0x80042000
Circle-OS
0x80080000
RAM
64KB OS 4KB Stack
0x20010000 0x2000F000
Circle-OS
0x80000000
0x20000000
- 16 -
- 17 -
Largest free block= 92KB Add Afilename Add a new application (object file). circle_mgr.exe Ac:\tmp\level.o Linking file C:\tmp\level.o... Link of C:\tmp\level.o succeeded... Hex file generated... Blank-checking the FLASH area...OK Programming file _tmp_.ld.hex to flash...OK Registering application in FAT... OK Erase Wait E* Eappname W circle_mgr.exe EMaze circle_mgr.exe E* /*remove only 'Maze'*/ /*remove ALL apps */
When a command list is launched through a batch file, the W command allows you to pause the execution and to check the intermediate results. Start CPU execution
Start
Caution: Any hex file can be programmed to the FLASH memory of your STM32-Primer2 using the cortex_pgm.exe utility. However, doing this will destroy your CircleOS firmware, and you will have to
- 18 -
reinstall it if you wish to use it later (refer to chapter4.7 "Restoring the factory configuration" for details).
Connect your STM32-Primer2s debug USB port to your PC. Power-up your STM32-Primer2 by pressing its button. Open a command prompt from Windows (Navigate to Start | Programs | Accessories | Command prompt) Reset your STM32-Primer2 using the cortex_pgm.exe utility installed in [RIDE7_INSTALL_DIR]\bin directory. This must be done with the following command:
cortex_pgm S
To reload the initial program, use the following command: cortex_pgm TSTM32F103VET6 PPrimer2_circle.hex S where Primer2_circle.hex is the full application, which is available on the web site.
- 20 -
- 21 -
5.2 Libraries
Some common services are offered to ease your development of CircleOS applications. 1. The STM32 libraries, written by ST, provide access to the embedded peripherals (such as timers, ADC, communication interfaces, thermometer, etc...) of the STM32 microcontroller. 2. The low-level CircleOS functions that provide an easy access to the STM32-Primer2s onboard peripherals: 3D accelerometer, LCD monitor, button, buzzer, battery, LEDs. 3. The graphical functions that provide powerful high-level functionality: Menu management, pointers (linked to the 3D accelerometer), character maps, sound. The source files of these libraries can be found: On the CD or on the ST web site for the STM32 libraries. Specific documentation about the STM32 library is also available. On the http://www.stm32circle.com/ web site for the CircleOS libraries (registration required). The libraries documentation is accessible from Ride7.
- 22 -
6 Recycling
6 Recycling
As part of our continuing efforts to proved the best service to our users an communities, Raisonance is actively defining take-back and recycling programs for EU customers as part of the implementation of the European WEEE directive.
This symbol is a reminder not to dispose of your electronic equipment in standard trash receptacles. For more information about disposal and recycling of electronic goods, please refer to http://www.raisonance.com/support/weee.php
- 23 -
6 Recycling
History
Date 14/11/08 17/11/08 05/01/09 13/01/09 Description Initial version. Corrected the memory mapping with the inclusion of the non-debuggable CircleOS part. Corrected the images and the document title. Fixed the memory map. Added the Timer2 handler description. Added description of the extension connector and daughter-board specifications. Some formatting updates. Added description of the extension connector. Corrected RAM size.
16/01/09 19/03/09
- 24 -
6 Recycling
Disclaimer
Disclaimer Information in this document is subject to change without notice and does not represent a commitment on the part of the manufacturer. The software described in this document is provided under license and may only be used or copied in accordance with the terms of the agreement. It is illegal to copy the software onto any medium, except as specifically allowed in the license or nondisclosure agreement. No part of this manual may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or information storage and retrieval systems, for any purpose other than the purchasers personal use, without prior written permission. Every effort has been made to ensure the accuracy of this manual and to give appropriate credit to persons, companies and trademarks referenced herein. This manual exists both in paper and electronic form (pdf). Please check the printed version against the .pdf installed on the computer in the Ride installation directory, for the most up-to-date version. The examples of code used in this document are for illustration purposes only and accuracy is not guaranteed. Please check the code before use. Copyright Raisonance 1987-2009 All rights reserved.
- 25 -