AN3311 STMICROELECTRONICS | Alldatasheet
Document overview
- Manufacturer or author: Provided By ALLDATASHEET.COM(FREE DATASHEET DOWNLOAD SITE)
- PDF pages: 58
Technical content
Datasheet sections
- 1 Document and library rules
- 1.1 Acronyms
- 2 ZigBee smartplug
- 2.1 Smartplug description
- 2.2 ZigBee module
- 3 Multi-input embedded GUI library
- 3.1 Description
- 4 STM3210C-EVAL demonstration board
- 4.1 Features
- 4.2 STM32 peripherals mapping
- 4.3 Power supply
- 4.4 Boot option
- 4.5 Clock source
- 4.6 Reset source
- 4.7 Joystick
- 4.8 Pushbuttons
- 4.9 Storage memory
- 4.10 Development and debug support
- 4.11 Display and input devices
- 4.12 JTAG debugging connector CN13
- 4.13 Daughterboard extension connector CN8 and CN9
- 4.14 TFT LCD connector CN14
- 4.15 Power connector CN18
- 5 Demonstration firmware system setup
- 5.1 Hardware requirements
- 5.2 STM3210C-EVAL demonstration board setup
- 5.3 STM3210C-EVAL and ZigBee adapter with M24LR62-r memory
- 5.4 How to navigate the demo menu
December 2010 Doc ID 18209 Rev 1 1/58 AN3311 Application note In-home display for ZigBee® smartplug Introduction This application note describes the demonstration firmware running on the STM3210C- EVAL for the STM32F107VC to manage a smartplug network system. An embedded graphical user interface (GUI) based on the “multi-input embedded GUI library 2.0 for STM32F10xxx” described in the AN3128 application note, and working on an LCD TFT 320 x 240 display and 5-position joystick, allows the user to interact with the smartplug system made up of one coordinator and two smartplugs connected. Section 1 describes the document and library rules. Section 2 highlights the features of the ZigBee smartplug and explains its hardware interface with a device microcontroller (STM32). Section 3 describes briefly the “multi-input embedded GUI library”. Section 4 describes the relevant blocks of the STM3210C-EVAL demonstration board. Section 5 shows the demonstration firmware/board system setup. Section 6 describes, in detail, how the “in-home display” firmware is structured, its architecture and its exported APIs. Section 7 explains how to get started with the system, how to configure and use the IAR workspace, and contains an example application source code. Section 8 illustrates how the “in-home display” GUI application works. Section 9 illustrates the hardware schematics.
7.1 Configure IAR tool for building, debugging, and programming the application
1 Document and library rules
This document uses the conventions described in the sections below.
1.1 Acronyms
Table 1 lists the acronyms used in this document. Table 1. List of acronyms
2 ZigBee smartplug
2.1 Smartplug description
Figure 1. STM3210C-EVAL block scheme
- Energy measurement
- Load differential current
- Load driving by relay or TRIAC (dimming)
- ZigBee communication capability.
Figure 2. Block diagram SPZB260 ZigBee module, and an STPM01 energy metering IC. an electrical wall socket and supplies a home appliance or other generic electrical load. data concentrator through the home/building ZigBee network.
2.2 ZigBee module
- 0dBm nominal TX output power
- -92dBm RX sensitivity
- +2dBm TX output power in boost mode
- RX filtering for co-existence with IEEE 802.11g and Bluetooth® devices. For further details please refer to the SPZB260 module and the SN260 network processor datasheet. Note: For more information, see the UM0608 user manual, STEVAL-IHP001V3 schematics diagram, and AN2993 application note.
AN3311 Multi-input embedded GUI library Doc ID 18209 Rev 1 9/58
3 Multi-input embedded GUI library
3.1 Description
This solution enables users, comfortable with the use of standard microcontrollers, to create higher-end “look and feel” human interfaces by replacing conventional electromechanical switches with touch-sensing controls. Users can combine touch-sensing functions using multiple configurations (touchscreen, joystick, and keys) with traditional MCU features (communication, beeper, LCD control, etc.). The E-multi-input graphic library is part of the application firmware. The graphic objects are a set of controls that can be printed on the screen and associated to an action when pressed. The library has been developed and tested on an LCD panel of QWGA resolution (320x240) which is the default, but the library is independent of the LCD resolution, although it has not been tested with others. The library supports touchscreen features and includes a low level driver which handles the analog input (for 12-bit ADC), and a function for the touchscreen calibration based on an algorithm that uses 5 points. The multi-input embedded GUI firmware library is fully developed in 'ANSI-C' following an OOP approach. This means that the final application uses instances of page and graphic objects according to their public methods and properties. In the end, the PageObj is a structure containing public properties (data fields) and methods (functions pointers). The OOP encapsulation feature is assured. The library has been developed and tested on the “STM3210C” STMicroelectronics demonstration board. The library can be included in the final application as a library file (multi-input embedded GUI library.a) and used as a black box through its exported public API, or can be included in the final application as source files (.c and .h), if the user wants to debug the library itself, or to change the HAL functions in order to port the library on a different LCD (in model and resolution) from the one attached to STM3210C-EVAL. For more information on the graphic library see the AN3128, rev. 2, application note. The calibration process is part of the post-processing layer. The touchscreen must be calibrated at first power-on and/or upon user request. Once the calibration is done, final adjustments on future power-on of the board are not necessary because the calibration parameters are saved on the Flash memory. The touchscreen and the joystick are controlled by the STMPE811 devices. The STMPE811 has a simple 2-wire I 2C digital serial interface which allows the user to access the data in the touchscreen controller register at any time. It communicates via the serial interface with a master controller. Figure 3 shows how the STM32F10xxx microcontroller (master device) must be connected to the STMPE811 device. Refer to the STMPE811 datasheet for more information on the register concerning the data of the touched points on the touchscreen.
Figure 3. I/O expander hardware configuration on the STM3210C-EVAL
4 STM3210C-EVAL demonstration board
Figure 4. STM3210C-EVAL demonstration board
STM3210C-EVAL demonstration board AN3311 12/58 Doc ID 18209 Rev 1
4.1 Features
- Three 5 V power supply options: power jack, USB connector, or daughterboard
- Boot from user Flash, system memory or SRAM
- I2S audio DAC, stereo audio jack
- 512 MByte (or bigger) micro-SD cardTM
- Both type A and B smartcard support
- I2C compatible serial interface 64-Kbit EEPROM, MEMS and I/O expander
- RS-232 communication
- IrDA transceiver
- USB-OTG full speed, USB mini-AB connector
- IEEE-802.3-2002 compliant Ethernet connector
- Two channels of CAN2.0A/B compliant connection
- Inductor motor control connector
- JTAG and trace debug support
- 3.2" 240x320 TFT color LCD with touchscreen
- Joystick with 4-direction control and selector
- Reset, wake-up, tamper, and user button
- 4 color LEDs
- RTC with backup battery
- MCU consumption measurement circuit
- Extension connector for daughterboard or wrapping board.
4.2 STM32 peripherals mapping
The STM3210C-EVAL demonstration board is designed around the STM32F107VC in a 100-pin TQFP package. The hardware block diagram, Figure 5, illustrates the connection between the STM32F107VC and peripherals (LCD, EEPROM, MEMS, USART, IrDA, USB- OTG, Ethernet, audio, CAN bus, smartcard, micro-SD card, and motor control) and these features can be located on the actual demonstration board in Figure 6.
Figure 5. Hardware block diagram - STM32 peripherals mapping For more details of calibration parameters, refer to the STPM01 datasheet on www.st.com.
Figure 6. STM3210C-EVAL demonstration board layout
4.3 Power supply
- 5 V DC power adapter connected to CN18, the power jack on the board (PSU on silk screen for power supply unit)
- 5 V DC power with 500 mA limitation from CN2, the USB mini-AB connector (USB on silkscreen)
- 5 V DC power from both CN8 and CN9, the extension connector for the daughterboard (DTB for daughterboard on silkscreen). !-V &10RWRUFRQWURO 86%0LFUR$% &1&1 ([WHQVLRQKHDGHU &$1 &$1 670)9&7 &1&1%1& 7UDFH -7$* 9SRZHU $XGLRMDFN 0LFUR6'FDUG 5HVHW %:DNHXS %7DPSHU 8-R\\VWLFN 3RWHQWLRPHWHU ,U'$ &RORU/&' FRQQHFWRU 6PDUWFDUG 8VHUNH\\ FRQQHFWRU
4.4 Boot option
- Embedded user Flash
- System memory with boot loader for ISP
- Embedded SRAM for debugging. The boot option is configured by setting switches SW1 (BOOT1) and SW2 (BOOT0). The BOOT0 can be configured also via the RS-232 connector CN6.
Table 2. Power related jumpers JP25 selects one of the three possible power supply resources.
4.5 Clock source
STM32F107VC, and RTC is embedded.
- X2, 32 kHz crystal for embedded RTC
- X3, 25 MHz crystal with socket for an STM32F107VC microcontroller, it can be removed from the socket when an internal RC clock is used.
4.6 Reset source
- Reset button, B1
- Debugging tools from JTAG connector CN13 and trace connector CN12
- Daughterboard from CN9
- RS-232 connector CN6 for ISP .
Table 3. Boot related switches Table 4. Reset related jumper connection with the system reset signal RESET#. Default setting: not fitted.
4.7 Joystick
The joystick is four-directional and includes a selection key.
4.8 Pushbuttons
- Key: user pushbutton
- Tamper: user pushbutton
- Wake-up: pushbutton used to wake up the processor from low-power mode.
4.9 Storage memory
and it is connected to the I2C1 peripheral of the MCU.
4.10 Development and debug support
- CN13, standard 20-pin JTAG interface connector which is compliant with the debug
- CN12, SAMTEC 20-pin connector FTSH-110-01-L-DV for both SWD and trace which is
4.11 Display and input devices
4) are available as display devices. Table 5. LCD module
1 CS PB2
3 WR/SCL PC10
4.12 JTAG debugging connector CN13
Figure 7. JTAG debugging connector CN13 viewed from above the PCB
5 RESET RESET#
22 BL_GND GND
23 BL_Control +5 V
26 GND GND
27 GND GND
28 BL_VDD +5 V
29 SDO PC11
30 SDI PC12
31 XL I/O Expander
32 XR I/O Expander
33 YD I/O Expander
34 YU I/O Expander
Table 5. LCD module (continued) Table 6. JTAG debugging connector CN13
3 PB4 4 GND
4.13 Daughterboard extension connector CN8 and CN9
mills (68.58mm). This standard was implemented on the majority of demonstration boards. corresponding function block on the STM3210C-EVAL demonstration board.
11 RTCK 12 GND
13 PB3 14 GND
15 RESET# 16 GND
17 DBGRQ 18 GND
19 DBGACK 20 GND
Table 6. JTAG debugging connector CN13 (continued) Table 7. Daughterboard extension connector CN8
5 PC9 USB power switch On Remove R36
7 PA9 USB VBUS Remove R78
11 PC14 via SB1 32 kHz oscillator Remove R161, close SB1
13 PA12 USB_DP Remove R43 or disconnect USB cable
15 PC15 via SB2 32 kHz oscillator Remove R59, close SB2
17 PC10 SPI1_CLK
19 GND -
21 PC12 SPI1_MOSI
23 PD1 CAN1_TX
25 PD3 LD3 Remove R96
27 PD5 USART2_TX
29 PD7 LD1 Remove R94
33 PB3 TDO/SWO
35 PB5 CAN2_RX Remove R45
37 PB7 I2C1_SDA Remove R132
39 GND -
41 PE2 Trace_CK
43 PE4 Trace_D1
45 PB8 MC Disconnect STM3210C-EVAL board from motor power drive
47 PE6 Trace_D3
49 D5V
2 PC6 I2S_MCK/MC JP10 open
6 PA8 MCO JP4 open
8 PA10 USB_ID Remove R38 or disconnect USB cable
10 GND
12 PA11 USB_DM Remove R42 or disconnect USB cable
14 PA13 TMS/SWDIO
16 PA14 TCK/SWCLK
18 PC11 SPI1_MISO Remove R135 and LCD
20 PA15 TDI
22 PD0 CAN1_RX Remove R44
24 PD2 MC Disconnect STM3210C-EVAL board from motor power drive
26 PD4 LD4 Remove R97
28 PD6 USART2_RX Keep JP16 open
30 GND
34 PB4 TRST Keep JP20 open
36 PB6 CAN2_TX/
38 PE0 MC/Micro-SD card
from motor power drive board.
40 PE1 USB_Overcurrent Remove R35
42 PE3 Trace_D0
44 PE5 Trace_D2
Table 7. Daughterboard extension connector CN8 (continued)
46 PB9 User button Remove R104
50 GND
Table 8. Daughterboard extension connector CN9
5 PD12 Ethernet Remove RS2
7 PD10 Ethernet/smartcard Keep JP11 open
9 PC13 button
11 RESET# -
13 PB15 I2S_DIN
15 PB13 I2S_CK/Ethernet Remove RS3
17 PB11 Ethernet Remove RS3
19 D5V -
21 PE14 Smartcard_CMDVCC Remove R166
25 PE12 MC Disconnect STM3210C-EVAL board from motor power drive
27 PE10 MC
29 PE8 MC
31 PE7 Smartcard_OFF Remove R69
33 PB1 MC Remove R168
35 PC5 VBAT_voltage Remove R154
37 PA7 MC Remove R169
39 GND
41 PA4 Micro-SD card/
43 PA2 Ethernet Remove R162
45 PC3 Ethernet Remove RS1
47 PC1 Ethernet
49 PC13
4 PD13 LD2 Remove R95
6 PD11 Ethernet Remove RS1
8 PD9 Ethernet/smartcard Keep JP12 open
12 PD8 Ethernet/smartcard Keep JP13 open
14 PB14 IO_Expander_INT Remove R159
16 PB12 Ethernet/audio Remove RS3
18 PB10 Ethernet Remove RS2
20 PE15 MC Remove R139
22 PE13 MC Disconnect STM3210C-EVAL board from motor power drive
26 PE11 MC Disconnect STM3210C-EVAL board from motor power drive
28 PE9 MC
32 PB2 MC Remove R168
34 PB0 MC Remove R167
36 PC4 Potentiometer Remove R103
38 PA6 IDD_Measurement Remove R79
40 PA5 MC Remove R84
42 PA3 MC/Ethernet Keep JP10 open
44 PA1 Ethernet Keep JP3 open
46 PC2 Ethernet Remove RS1
48 PC0 MC/smartcard Remove R165
Table 8. Daughterboard extension connector CN9 (continued)
4.14 TFT LCD connector CN14
4.15 Power connector CN18
Figure 8. Power supply connector CN18 viewed from the front For more information on STM3210C-EVAL, please refer to the UM0600 user manual.
5 Demonstration firmware system setup
5.1 Hardware requirements
5.2 STM3210C-EVAL demo nstration board setup
- Close jumper JP19
- Keep JP15 open
- Remove R79, R84, and R169.
5.3 STM3210C-EVAL and ZigBee adapter with M24LR62-r
Table 9. ZigBee adapter pin description
29 PA4 SPI1_NSS CN9 - Pin 41 ZIG_SS
30 PA5 SPI1_CLK CN9 - Pin 40 ZIG_SCLK
31 PA6 SPI1_MISO CN9 - Pin 38 ZIG_MISO
32 PA7 SPI1_MOSI CN9 - Pin 37 ZIG_MOSI
92 PB6 CAN2_TX/I2C1_SCK CN8 - Pin 36 I2C1_SCK
93 PB7 I2C1_SDA CN8 - Pin 37 I2C1_SDA
2 PE3 Trace_D0 CN8 - Pin 42 ZIG_HOST_INT
3 PE4 Trace_D1 CN8 - Pin 43 VCC-GPIO (for M24LR64-
4 PE5 Trace_D2 CN8 - Pin 44 ZIG_WAKE
5 PE6 Trace_D3 CN8 - Pin 47 ZIG_RSTB
AN3311 Demonstration firmware system setup Doc ID 18209 Rev 1 25/58
5.4 How to navigate the demo menu
Four basic elements constitute the hardware of the system user interface: a 320 x 240 TFT LCD display, a resistive touchscreen, a 5-way (left, right, up, down, selection) micro-joystick and a pushbutton “Key”. The joystick is primarily used for navigating between the various menu screens, within a screen and between screen items. In addition, the joystick allows the selection and editing of item values.
6 In-home display firmware
6.1 Firmware architecture
Figure 9. In-home display firmware architecture Table 10. Function description format
Table 11. vSmartPlugSamplingTask task
GraphCharts and the histograms show a maximum value set to zero. and calls the graphic library relative function according to the object pressed. Table 12. vGraphicLibraryTask task
This function starts the smartplug coordinator application routine. Table 13. prvApplicationTask task Table 14. prvSetupHardware function
ZigBee hardware configuration. and the graphic library hardware parameters. Table 14. prvSetupHardware function (continued) Table 15. vBoardInit function
7 Getting started with the system
7.1 Configure IAR tool for building, debugging, and
provide the final user with a real example of “In-home display” application usage. the header files, both for the project files and the library files, as shown in Figure 10. Figure 10. Application project files select, in \\project folder\\EWARM, the file “Project.eww”.
AN3311 Getting started with the system Doc ID 18209 Rev 1 33/58 In order to use the In-home display application project, it is necessary to:
- Include all the firmware delivered in the In-home display package containing the FreeRTOS core files. See Figure 10
- Create the desired menu application functions in the file menu.c
- Put inside “picture.c” the HEX dump of the pictures to be used with the application GUI
- Implement a main function as described in the following section. 7.2 Example application - main.c An example of a main application is given below. The main function contains an example of the In-home display application initialization/configuration and implements the classic operations: /* Standard includes. */ #include <stdio.h> /* Scheduler includes. */ #include "FreeRTOS.h" #include "task.h" #include "queue.h" #include "semphr.h" /* Library includes. */ #include "stm32f10x.h" #include "stm32f10x_it.h" #include "STM3210c_eval_lcd.h" #include "LcdHal.h" //SB /* Demo app includes. */ #include "flash.h" #include "partest.h" #include "common.h" #include "micro_clocks_irqs.h" #include "micro.h" #include "menu.h" #include "graphicObject.h" #include "cursor.h" #include "stm32d-eval_io_expander.h" #include "LcdHal.h" #include "TscHal.h" #include "pictures.h" #include "stm32f10x.h" #include "stm32f10x_rcc.h" #include "misc.h" #include "SmartPlugObj.h" #include "CoordinatorObj.h" #include "COORDINATOR_Layer.h" #include "ZSP_Layer.h" #ifdef USE_STM3210E_EVAL #include "stm3210e_eval_lcd.h" #elif USE_STM3210C_EVAL #include "stm3210c_eval_lcd.h" #include "touchscreen.h" #endif
Getting started with the system AN3311 34/58 Doc ID 18209 Rev 1 /* Touchscreen Controller and Joystick DEFINES */ #define TSC_GPIO_PORT_SOURCE GPIO_PortSourceGPIOB #define TSC_GPIO_PIN_SOURCE GPIO_PinSource14 #define JOY_GPIO_PORT_SOURCE GPIO_PortSourceGPIOB #define JOY_GPIO_PIN_SOURCE GPIO_PinSource14 #define JOY_GPIO_SELECT_PORT GPIOG #define JOY_GPIO_SELECT_PIN GPIO_Pin_7 #define JOY_GPIO_RIGHT_PORT GPIOG #define JOY_GPIO_RIGHT_PIN GPIO_Pin_13 #define JOY_GPIO_LEFT_PORT GPIOG #define JOY_GPIO_LEFT_PIN GPIO_Pin_14 #define JOY_GPIO_UP_PORT GPIOG #define JOY_GPIO_UP_PIN GPIO_Pin_15 #define JOY_GPIO_DOWN_PORT GPIOD #define JOY_GPIO_DOWN_PIN GPIO_Pin_3 #define JOY_GPIO_RCC_APB_PERIPH1 RCC_APB2Periph_GPIOG #define JOY_GPIO_RCC_APB_PERIPH2 RCC_APB2Periph_GPIOG #define JOY_GPIO_RCC_APB_PERIPH3 RCC_APB2Periph_GPIOG #define JOY_GPIO_RCC_APB_PERIPH4 RCC_APB2Periph_GPIOG #define JOY_GPIO_RCC_APB_PERIPH5 RCC_APB2Periph_GPIOD #define TSC_EXTI_IRQ_CHANNEL EXTI15_10_IRQn #define JOY_EXTI_IRQ_CHANNEL EXTI15_10_IRQn #define TSC_EXTI_LINE EXTI_Line14 #define JOY_EXTI_LINE EXTI_Line14 #define TSC_GPIO_PORT GPIOA #define TSC_GPIO_PIN GPIO_Pin_14 #define TSC_I2C_DEVICE_REGISTER 0x82 #define JOY_I2C_DEVICE_REGISTER 0x88 #define M24LR64_I2C_DEVICE_REGISTER 0x24 #define TSC_I2C_PORT I2C1 /* User Button GPIO Port and Pin*/ #ifdef USE_STM3210C_EVAL #define USER_BUTTON_PORT GPIOB #define USER_BUTTON_PIN GPIO_Pin_9 #elif USE_STM3210E_EVAL #define USER_BUTTON_PORT GPIOG #define USER_BUTTON_PIN GPIO_Pin_8 #endif /* LCD Controller DEFINES */ #define LCD_CTRL_PORT_NCS GPIOB #define LCD_GPIO_DATA_PORT GPIOC #define LCD_CTRL_PIN_NCS GPIO_Pin_2 #define LCD_CTRL_PIN_NWR GPIO_Pin_15 #define LCD_CTRL_PIN_RS GPIO_Pin_7 #define LCD_GPIO_PIN_SCK GPIO_Pin_10 #define LCD_GPIO_PIN_MISO GPIO_Pin_11 #define LCD_GPIO_PIN_MOSI GPIO_Pin_12 #define LCD_GPIO_RCC_APB_PERIPH RCC_APB2Periph_GPIOC #define LCD_GPIO_RCC_APB_PERIPH_NCS RCC_APB2Periph_GPIOB #define LCD_GPIO_REMAP_PORT GPIO_Remap_SPI3 #define LCD_RCC_APB_PERIPH RCC_APB1Periph_SPI3 #define LCD_RCC_AHB_PERIPH RCC_AHBPeriph_FSMC #define LCD_SPI_PORT SPI3 #ifdef USE_STM3210C_EVAL #define LCD_CONNECTION_MODE GL_SPI #elif USE_STM3210E_EVAL #define LCD_CONNECTION_MODE GL_FSMC #endif #define RCC_AHBPeriph_FSMC ((uint32_t)0x00000100)
AN3311 Getting started with the system Doc ID 18209 Rev 1 35/58 LCD_HW_Parameters_TypeDef* pLcdParam; TSC_HW_Parameters_TypeDef* pTscParam; JOY_HW_Parameters_TypeDef* pJoyParam; BTN_HW_Parameters_TypeDef* pBtnParam; extern volatile GL_u8 touch_done; GL_s16 smart_points1[N_SAMPLES]; GL_s16 smart_points1B[N_SAMPLES]; GL_s16 smart_points2[N_SAMPLES]; GL_s16 smart_points2B[N_SAMPLES]; SmartPlugType** ppSmartPlugList; SmartPlugType* pCurrentSmartPlug; extern GL_Page_TypeDef pageS2B; extern GL_Page_TypeDef pageS2C; static volatile ErrorStatus HSEStartUpStatus /*= SUCCESS*/; volatile GL_u8 restart_calibration = 0; GPIO_InitTypeDef GPIO_InitStructure; static u32 TimingDelay; static xTaskHandle xEmberTaskHandle, xApplTaskHandle, xSmartSamplingTaskHandle, xGraphLibTaskHandle; /* The time between cycles of the 'check' functionality (defined within the tick hook. */ #define mainCHECK_DELAY ( ( portTickType ) 5000 / portTICK_RATE_MS ) /* Task priorities. */ #define EMBER_Task ( tskIDLE_PRIORITY + 3 ) #define APPLICATION_Tick_Task ( tskIDLE_PRIORITY + 2 ) #define mainINIT_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 ) /* The period of the system clock in nano seconds. This is used to calculate the jitter time in nano seconds. */ #define mainNS_PER_CLOCK ((unsigned portLONG)((1.0 / (double)configCPU_CLOCK_HZ)*1000000000.0)) /* Configure the hardware for the demo. */ static void prvSetupHardware( void ); static void vEmberTickTask( void *pvParameters ); extern void EZSPInit(void); static void prvApplicationTask( void * pvParameters ); void vApplication_EXIT2_ISRFunc( void ); void vApplication_USART0_ISRFunc( void ); /* Configure the hardware for the demo. */ static void prvSetupHardware( void ); /* Configure the board, LCD, Joystick, Button, GPIO and other peripherals as required by the demo. */ static void vBoardInit( void ); /* Check Touchscreen, Joystick, Button in polling mode as required by the demo. */ static void vGraphicLibraryTask(void *pvParameters); /* Check the SmartPlug Energy data as required by the demo. */ static void vSmartPlugSamplingTask( void *pvParameters);
Getting started with the system AN3311 36/58 Doc ID 18209 Rev 1 * Configures the high frequency timers - those used to measure the timing * jitter while the real time kernel is executing. extern void vSetupHighFrequencyTimer( void ); u16 ticksSinceLastHeard[APPLICATION_ADDRESS_TABLE_SIZE]; EmberNetworkStatus networkState = EMBER_NO_NETWORK; /* insert Start */ xSemaphoreHandle xSemaphore_Ember = NULL; xSemaphoreHandle xSemaphore_Serial = NULL; extern void EZSP_Init(void); extern void emberTick(void); extern void processSerialInput(void); extern void applicationTick(void); /* insert End */ int main( void ) #ifdef DEBUG debug(); #endif pLcdParam = NewLcdHwParamObj (); pTscParam = NewTscHwParamObj (); pJoyParam = NewJoyHwParamObj (); pBtnParam = NewBtnHwParamObj (); prvSetupHardware(); /* Start the tasks. FreeRTOS API. */ xTaskCreate( vEmberTickTask, "EMBER", configMINIMAL_STACK_SIZE, NULL, EMBER_Task, xEmberTaskHandle ); xTaskCreate( vSmartPlugSamplingTask, ( signed portCHAR * ) "SmartPlugSampling", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, xSmartSamplingTaskHandle ); xTaskCreate( vGraphicLibraryTask, ( signed portCHAR * ) "GraphicLibrary", configMINIMAL_STACK_SIZE*2, NULL, tskIDLE_PRIORITY+1, xGraphLibTaskHandle ); /* Start the scheduler. */ vTaskStartScheduler(); // emberLeaveNetwork(); /* Will only get here if there was insufficient memory to create the idle task. The idle task is created within vTaskStartScheduler(). */ for( ;; ); The initialization process is charged with preparing the basic mechanism of the system:
- Hardware peripheral configuration and initialization
- ZigBee stack initialization
- FreeRTOS task creation
- Starting system.
AN3311 Getting started with the system Doc ID 18209 Rev 1 37/58 The clock distribution and the interrupt settings are two components that are strongly dependent on the target project. An example of clock rate may be 72 MHz as the maximum speed of the current STM32 microcontroller. It can be decreased to reduce the power consumption. The clock rate assumptions are:
- System HCLK - 72 MHz
- Low speed peripheral PCLK1 - 72 MHz
- High speed peripheral PCLK2 - 36 MHz
- Analog to digital converter ADCCLK - 36 MHz The interrupt setting situation is very similar to clock distribution. The library functions involved with interrupt managing do not take the priorities into account; they only perform very necessary and absolutely common settings to make them serviceable.
8 In-home display GUI application
Figure 13. ZigBee dongle connection problem power is correctly supplied, the main screen is displayed as shown in Figure 14. Figure 14. Main menu
Figure 15. Searching plugs
9 Schematics
9.1 Smartplug board schematics and layout
Figure 26. ZigBee and dual interface EEPROM adapter schematic for STM3210C-EVAL
9.2 ZigBee/RF adapter for smartp lug and dual interface memory
Figure 27. ZigBee and dual interface EEPROM adapter layout for STM3210C-EVAL
9.3 STM3210C
Figure 28. STM3210C main schematic
9.4 MCU
Figure 29. MCU schematic
1 SW1
9.5 LCD
Figure 30. LCD schematic
9.6 I/O expander
Figure 31. I/O expander schematic
9.7 I/O peripherals
Figure 32. I/O peripherals
100 COMMON5
2 RV1
9.8 Extension connector
Figure 33. Extension connector
9.9 JTAG and trace
Figure 34. JTAG and trace
9.10 Power
Figure 35. Power
3 JP23
1 U21
Figure 36. LCD 3.2" module with SPI and 16-bit interface 1
10 References
- AN3128 application note 2. RM0008 reference manual 3. STM32F10xFWLib 3.2.1 help file 4. STM811 datasheet 5. TN0074 technical note 6. UM0608 user manual 7. STEVAL-IHP001V3 schematics diagram 8. AN2993 application note 9. M24LR64-r datasheet 10. AN2972 application note.
Table 16. Document revision history 14-Dec-2010 1 Initial release.