stm8l-discovery 原理图

合集下载

stm8l-discovery

stm8l-discovery

UM0970User ManualSTM8L-DISCOVERYIntroductionThe STM8L-DISCOVERY helps you to discover the STM8L ultralow power features and todevelop and share your applications. It is based on an STM8L152C6T6 and includes an ST-Link embedded debug tool interface, LCD (24 segments, 4 commons), LEDs and pushbuttons.Figure 1.STM8L-DISCOVERY boardSeptember 2010Doc ID 17693 Rev 11/29Contents UM0970Contents1Quick start . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.1Getting started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.2System requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.3Development toolchain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41.4Demonstration software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41.5Order code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 2Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53Hardware and layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63.1STM8L152C6T6 microcontroller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93.2Embedded ST-Link . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113.2.1Using the ST-Link to program/debug the STM8L on board . . . . . . . . . . 123.2.2Using the ST-Link to program/debug an external STM8L application . . 123.3Power supply and power selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133.4LEDs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133.5Push buttons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133.6Built-in IDD measurement circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143.6.1Run mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143.6.2Low power mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143.6.3Low power mode I DD measurement principle . . . . . . . . . . . . . . . . . . . . 153.6.4Ibias current measurement procedure . . . . . . . . . . . . . . . . . . . . . . . . . . 163.7Solder bridges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163.8LCD (24 segments, 4 commons) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 4Extension connection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 5Electrical schematics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 6Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282/29Doc ID 17693 Rev 1UM0970Quick startDoc ID 17693 Rev 13/291 Quick startThe STM8L-DISCOVERY is a low-cost and easy-to-use development kit to quickly evaluateand start a development with an STM8L ultralow power microcontroller.Before installing and using the product, please accept the Evaluation Product License Agreement from /stm8l-discovery.For more information on the STM8L-DISCOVERY and for demonstration software visit /stm8l-discovery.1.1 Getting started1.Check jumper positions on the board, JP1 and CN3 ON (Discovery selected).2. Connect the STM8L-DISCOVERY board to a PC with a USB cable to power the board.Red LED LD2 (PWR) then lights up.3.Function 1 is executed and each click on user button B2 changes the executed function as described in Table 1.To study or modify the DISCOVER project related to this demo, visit /stm8l-discovery and follow the tutorial. Discover the STM8L features, download and execute programs proposed in the list of projects. This site also contains examples from which you can develop your own applications.1.2 System requirements●Windows PC (2000, XP , Vista)●A/Mini-B USB cableTable 1.FunctionsFunction LED LD3/4BarsValue displayed1BlinkSTM8L V DD voltage measured2Off STM8L consumption measured in Run mode3Off STM8L consumption measured in Low power mode, LCD on4Off STM8L consumption measured in Low power mode, LCD off5Off STM8L consumption measured in Halt mode, LCD offQuick start UM09704/29Doc ID 17693 Rev 11.3 Development toolchain●IAR, Embedded Workbench® for STM8●STMicroelectronics, ST Visual Develop (STVD)1.4 Demonstration softwareDemonstration software is preloaded in the board's Flash memory. This demonstration usesthe built-in IDD measurement feature of the STM8L-DISCOVERY to automatically measure and display on the LCD the consumption of the MCU in run and low power modes. The latest versions of this demonstration source code and associated documentation can be downloaded from /stm8l-discovery.1.5 Order codeTo order the STM8L ultralow power Discovery, use the order code STM8L-DISCOVERY.UM0970FeaturesDoc ID 17693 Rev 15/292 FeaturesThe STM8L-DISCOVERY offers the following features:●STM8L152C6T6 microcontroller, 32 KB Flash, 2 KB RAM, 1KB EEPROM in 48-pin LQFP●On-board ST -Link with selection mode switch to use the kit as a stand-alone ST -Link (with SWIM connector for programming and debugging)●Two red LEDs; LD1 for USB communication, LD2 for 3.3 V power on ●Designed to be powered by USB or an external supply of 5 V or 3.3 V ●Can supply target application with 5 volts and 3 volts ●Two user LEDs, LD3 and LD4 (green and blue)●Two push buttons (User and Reset)●I DD current measurement●LCD 28-pin DIP (24 segments, 4 commons)●Extension header for all QFP48 I/Os for quick connection to prototyping board for easy probingHardware and layout UM0970 3 Hardware and layoutThe STM8L-DISCOVERY is designed around the STM8L152C6T6 microcontroller in a 48-pin LQFP package.Figure2 illustrates the connections between the STM8L152C6T6 and its peripherals (ST-Link, push button, LED, LCD and connectors).Figure3 and Figure4 help you to locate these features on the STM8L-DISCOVERY.6/29Doc ID 17693 Rev 1UM0970Hardware and layoutDoc ID 17693 Rev 17/29Figure 3.Top layoutST -LinkLCD 24 segmentsI DD measurement STM8L152C6T6B2CN2JP1LD3LD4B1CN3IDD moduleLD1LD2User buttonLED blueReset buttonLED greenSWIM connectorCOMpowerSB1,2X2 crystalD2 diode D1 diodeST -Link/Discovery selector+3.3V power supply input+5Vpower supply inputHardware and layoutUM09708/29Doc ID 17693 Rev 1Figure 4.Bottom layoutP1P2SB4,6,8,10PRG-32SB3,5,7,9DEFAULTSB11,12,14SB13,15SB16SB17P3IDD_MeasurementB2-USER B1-RESETX3 crystal connectorconnectorconnectorJP1IDD(RESERVED)UM0970Hardware and layoutDoc ID 17693 Rev 19/293.1 STM8L 152C6T6 microcontrollerThis 8-bit ultralow power MCU has 32 KB Flash, 2 KB RAM, 1 KB data EEPROM, RTC,LCD, timers, USART, I2C, SPI, ADC, DAC and comparators.Figure 5.STM8L152C6T6 packageThis device provides the following benefits:●Ultralow power proprietary 130 nm technology:Speed and power consumption independent of MCU power supply, Ultralow leakage ●Ultralow power design (clock gating, low-power Flash with power-off capability): Reduced overall Run and Wait mode current consumption by turning off clocks of unused peripherals or Flash●Sub 1µA hardware RTC and AWU system unit:Ultralow power modes for applications requesting regular wake up●Range of Low power modes (up to 4):Suitable for many applications from complete switch off to continuous monitoring at ultralow frequency●Advanced and flexible clock system (multiple internal and external clock sources): Switch and adjust frequency and clock sources on the fly depending on application needs●Direct memory access on board (4-channel DMA):Autonomy for peripherals, independent from core; can switch off Flash memory and CPU (large current consumption contributors) while keeping peripherals active ●Ultralow power and ultrasafe reset system POR/PDR; additional optional activationBOR:Integrated safety and security for application●Ultrafast wakeup from lowest Low power mode (4µs): Fast switching from Static and Dynamic power modes●Analog functional down to 1.8 V, programming down to 1.65 V: Full functionality over the complete V DD rangeFor more information see the STM8L152C6T6 datasheet (Doc ID 15962) on the ST website.The STM8L152C6T6 8-bit microcontroller offers: 2Kbytes RAM32Kbytes of Flash memory LQFP48 7 x 7 mm1Kbytes EEPROMHardware and layout UM0970 Figure 6.STM8L152C6T6 block diagram10/29Doc ID 17693 Rev 1UM0970Hardware and layoutDoc ID 17693 Rev 111/293.2 Embedded ST-LinkThe ST -Link programming and debugging tool is integrated on the STM8L-DISCOVERY.The embedded ST -Link can be used in 2 different ways according to the jumper states (see Table 2):●to program/debug the MCU on board,●to program/debug an MCU in an external application board using a cable connected to SWIM connector CN2.For information about debugging and programming features refer to ST -Link UM0627.Note:UM0627 contains information about all the ST -Link features. Usage in this situation is restricted to STM8 devices and SWIM support.Figure 7.Typical configurationTable 2.Jumper statesJumper stateDescriptionBoth CN3 jumpers ON ST -Link functions enabled for on board programming (default)Both CN3 jumpers OFFST -Link functions enabled for external application through CN2 connector (SWIM supported).Hardware requirements:- USB cable type A to mini-B- Computer with Windows 2000, XP or Vista OSDevelopment toolchain:- IAR, Embedded Workbench® for STM8L- STMicroelectronics, ST Visual Develop (STVD)Hardware and layout UM09703.2.1 Using the ST-Link to program/debug the STM8L on boardTo program the STM8L on board, simply plug in the two jumpers on CN3, as shown inFigure8 in red, but do not use the CN2 connector as that could disturb communication withthe STM8L152C6T6 of the STM8L-DISCOVERY.Figure 8.STM8L-DISCOVERY connections imageJumpers on CN33.2.2 Using the ST-Link to program/debug an external STM8L applicationIt is very easy to use the ST-Link to program the STM8L on an external application. Simplyremove the 2 jumpers from CN3 as shown in Figure9, and connect your application to theCN2 debug connector according to Table3.Table 3.Debug connector CN2 (SWIM)Pin CN2Designation1VDD_TARGET VDD from application2SWIM SWIM data input/output3GND Ground4SWIM_RST SWIM reset12/29Doc ID 17693 Rev 1UM0970Hardware and layoutDoc ID 17693 Rev 113/29Figure 9.ST-Link connections image3.3 Power supply and power selectionThe power supply is provided either by the host PC through the USB cable, or by external power supply (5V or 3.3V). The D1 and D2 protection diodes allow the 5V and 3V3 pins to be used independently as input or output power supplies (see Figure 3). The 5V and 3V3 pins can be used as an output power supply for use by an application board connected on pin headers (P1 to P3). In such a case, the 3V3 pin provides only a 3V power supply and the power consumption must be lower than 100mA. The 5V and 3V3 pins can also be used as an input power supply for the board when the USB connector is not connected to the PC.3.4 LEDs●LD1 COM: Red LED indicates communication in progress between PC and ST -Link.●LD2 PWR: Red LED indicates that the board is powered.●LD3 PE7: Green LED is a user LED connected to the I/O PE7 of the STM8L152C6T6.●LD4 PC7: Blue LED is a user LED connected to the I/O PC7 of the STM8L152C6T6.3.5 Push buttons●B1 RST: Push button is used to RESET the STM8L152C6T6.●B2 USER: User push button connected to the I/O PC1 of the STM8L152C6T6.No jumpers on CN3Hardware and layout UM097014/29Doc ID 17693 Rev 13.6 Built-in IDD measurement circuitThe STM8L-DISCOVERY built-in I DD measurement circuit allows the consumption of the STM8L152C6T6 to be measured and displayed on the LCD Glass while the MCU is in Run or Low power saving modes.●JP1 in ON position: STM8L152C6T6 is powered through I DD measurement circuit (default).●JP1 in OFF position: STM8L152C6T6 is powered directly by +3V3, I DD measurement circuit is bypassed.Note:When jumper JP1 is removed the current consumption of the STM8L152C6T6 can be measured by connecting an ammeter between jumper JP1 pin 1 and pin 2.For Imeasurement by the MCU itself, the circuit below is implemented on the STM8L-measurement timing according to Figure 11.UM0970Hardware and layout 3.6.3 Low power mode I DD measurement principleThe principle used to measure a current when the STM8L152C6T6 is in Low power mode is:1.Configure ADC to measure voltage on the IDD_Measurement pin.2. Configure PE6 to serve as wakeup pin.3. Enter Low power mode after setting IDD_CNT_EN (PC4) signal low.4. IDD_WAKEUP rising edge wakes up the MCU after around 300ms.5. Start ADC conversion as soon as possible after wakeup in order to measure thevoltage corresponding to Low power mode on capacitor C11.6. Reset the counter by programming IDD_CNT_EN high (in less than 70ms after thewakeup) to avoid the R21 2KΩ resistor being connected later in Run mode.The measurement timing is given in Figure11. In Low power modes, the 2KΩ resistor isconnected when T1 goes off after entering Low power mode. Q13 output of the counterallows connection of the 2KΩ resistor when the current I DD becomes very low.Figure11 shows how the counter and T1 ensure that, 150ms after IDD_CNT_EN fallingedge, the shunt resistor R21 is connected between VDD_MCU and the power supply inorder to reduce the measurement range to 30uA full scale. Then after another 150ms forcurrent stabilization, R21 is shorted, the IDD measurement is stored in C11, and the MCU iswoken up. After wakeup the MCU can measure the IDD current corresponding to the Lowpower mode stored in C11.Figure 11.STM8L-DISCOVERY I DD Low power mode measurement timing diagramThe Low power mode measurement procedure can be used in Halt or Active halt mode if theI DD current does not exceed 30uA, otherwise the I DD measurement procedure in Run modeshould be used up to 30mA.Doc ID 17693 Rev 115/29Hardware and layout UM097016/29Doc ID 17693 Rev 13.6.4 Ibias current measurement procedureIn Low power mode the bias current of operational amplifier input (U4 pin 4) is not negligiblecompared to I DD current (typical Ibias is ~240 nA). T o obtain a reliable STM8L152 I DD measurement it is mandatory to subtract the bias current from the I DD low power measurement since this current is not sinked by the MCU. Ibias is measured duringproduction test and stored in the MCU EPROM. The demonstration software, Discover, uses this value to display the correct I DD . The Ibias measurement procedure is part of the demonstration software and can be launched if required.The procedure for Ibias measurement (implemented in the Demo) is:1.Power off the board (disconnect the USB cable).2. Set jumper JP1 to OFF position (pins 1 and 2).3. Push down B2 (USER button), power on the board from the USB.4. Wait at least 1 second before releasing B2, the LCD displays the Ibias measurement.5. Power off the board (disconnect the USB cable).6.Set jumper JP1 to ON position (pins 2 and 3). The Ibias value is now stored. The bias current is then subtracted from the I DD measurement performed in Low power mode.3.7 Solder bridgesTable 4.Solder bridgeBridgeState (1)1.Default state is in bold type.DescriptionSB1,2(X2 crystal)Off P A2, P A3 are disconnected from P1X2, C19, C20 and R24 provide a clock as shown in schematics On P A2, P A3 are connected to P1 (X2, C19, C20, R24 must not be fitted)SB3,5,7,9 (DEFAULT)On Reserved, do not modify SB4,6,8,10(PRG-32)Off Reserved, do not modifySB11,12,14(IDD_Measurement)Off PFO, PE6, PC4 are available and IDD module cannot be used JP1 must be set to OFFOn PFO, PE6, PC4 are used by IDD module JP1 must be set to ONSB13,15(X3 crystal)Off PC5, PC6 are only connected to P2 (but do not remove X3, C21, C23, R27)On PC5, PC6 are connected to P2. X3, C21, C23 and R27 provide 32KHz clock SB16(B1-RESET)Off P A1/RESET signal is only connected to P1On P A1/RESET signal is used by ST_LINK as SWIM_RST and also connected to P1SB17(B2-USER)Off PC1 is only connected to P2OnPC1 is connected to P2 and push button B2 for userUM0970Hardware and layout3.8 LCD (24 segments, 4 commons)This LCD allows the STM8L152C6T6 to display any information on six 14-segment digitsand 4 BARs, using all COMs. (See the LCD segment mapping in Figure12 and pinconnections in Table5.)Note:This LCD also supports six 8-segment digits by only using COM0 and COM1.This configuration allows COM2 and COM3 to be used as I/O ports. In this case the 2 LCDpins must not be plugged into the LCD socket. To proceed with this configuration, removethe LCD carefully, slightly open the COM2 and COM3 pins (pin 13 and pin 14) of the LCD,then replug it in the socket.Characteristics overview:●24 segments and 4 commons●Drive method: multiplexed 1/4 duty, 1/3 bias●Operating voltage: 3V●Operating temperature: 0 to 50°C●Connector: 28-pin DIL 2.54mm pitchNote:When the LCD is plugged, all I/O ports listed in Table5 are unavailable. To use one of these as I/O, you must remove the LCD.Figure 12.LCD segment mappingDoc ID 17693 Rev 117/29Hardware and layout UM0970Table 5.LCD connectionsSTM8L152C6T6 LCDPin name Pin COM3COM2COM1COM0 P A7_LCDSEG011N1P1D1EPE0_LCDSEG121DP1COLON1C1MPE1_LCDSEG232N2P2D2EPE2_LCDSEG342DP2COLON2C2MPE3_LCDSEG453N3P3D3EPE4_LCDSEG563DP3COLON3C3MPE5_LCDSEG674N4P4D4EPD0_LCDSEG784DP4COLON4C4MPD2_LCDSEG895N5P5D5EPD3_LCDSEG910BAR2BAR35C5MPB0_LCDSEG10116N6P6D6EPB1_LCDSEG1112BAR0BAR16C6MPD1_LCDCOM313COM3P A6_LCDCOM214COM2P A5_LCDCOM115COM1P A4_LCDCOM016COM0PB2_LCDSEG12176J6K6A6BPB3_LCDSEG13186H6Q6F6GPB4_LCDSEG14195J5K5A5BPB5_LCDSEG15205H5Q5F5GPB6_LCDSEG16214J4K4A4BPB7_LCDSEG17224H4Q4F4GPD4_LCDSEG18233J3K3A3BPD5_LCDSEG19243H3Q3F3GPD6_LCDSEG20252J2K2A2BPD7_LCDSEG21262H2Q2F2GPC2_LCDSEG22271J1K1A1BPC3_LCDSEG23281H1Q1F1G18/29Doc ID 17693 Rev 1Extension connection UM097019/29Doc ID 17693 Rev 14 Extension connectionMale headers P1, P2 and P3 can connect the STM8L-DISCOVERY to a standardprototyping/wrapping board. All GPI/Os of STM8L152C6T6 are available on it.P1, P2 and P3 can also be probed by an oscilloscope, logical analyzer or voltmeter.Table 6.P1 pinoutPin number (P1)Pin number(STM8L)Board pin nameT y p eMain functionAlternate function LCD (U5)1+3V33.3 V board power supplied or supplyexternal application when USB connected21P A0I/O Port A0 P A0/[USART1_CK](3)/SWIM/BEEP/IR_TIM (7)39/40GND Ground42P A1I/O ResetNRST/P A1(1)53P A2I/O Port A2 P A2/OSC_IN/[USART1_TX](3)/[SPI1_MISO] (3) 64P A3I/O Port A3 P A3/OSC_OUT/[USART1 _RX](3)/[SPI1_MOSI](3) 75P A4I/O Port A4P A4/TIM2_BKIN/ LCD_COM0(2)/ADC1_IN2/COMP1_INP LCD_COM086P A5I/O Port A5P A5/TIM3_BKIN/ LCD_COM1(2)/ADC1_IN1/COMP1_INP LCD_COM197P A6I/O Port A6P A6/[ADC1_TRIG](3)/LCD_COM2(2)/ADC1_IN0/ COMP1_INP LCD_COM2108P A7I/O Port A7 P A7/LCD_SEG0(2)(4) LCD_SEG01114PE0I/O Port E0 PE0(4)/LCD_SEG1(2) LCD_SEG11215PE1I/O Port E1 PE1/TIM1_CH2N / LCD_SEG2(2) LCD_SEG21316PE2I/O Port E2PE2/TIM1_CH3N / LCD_SEG3(2)LCD_SEG31417PE3I/O Port E3 PE3/LCD_SEG4(2) LCD_SEG41518PE4I/O Port E4 PE4/LCD_SEG5(2)LCD_SEG5UM0970Extension connectionDoc ID 17693 Rev 120/291619PE5I/O Port E5PE5/LCD_SEG6(2)/ADC1_IN23/COMP2_INP/ COMP1_INP LCD_SEG61720PD0I/O Port D0PD0/TIM3_CH2/ [ADC1_TRIG](3)/ LCD_SEG7(2)/ADC1_IN2 2/COMP2_INP/ COMP1_INP LCD_SEG71821PD1I/O Port D1 PD1/TIM3_TRIG/ LCD_COM3(2)/ADC1_IN21/COMP2_INP/ COMP1_INPLCD_COM3199/40GNDGroundTable 7.P2 pinoutPin number (P2)Pin number(STM8L)Pin nameT y p eMain functionAlternate function LCD (U5)1+5V5 Volts board power supplied or supplyexternal application when USB connected2NC 39/40GND Ground448PE7I/O Port E7 PE7/LCD_SEG27(2)547PE6 I/O Port E6PE6/LCD_SEG26(2)/PVD_IN646PC7I/O Port C7PC7/LCD_SEG25(2)/ ADC1_IN3/COMP2_INM/ COMP1_INP 745PC6I/O Port C6PC6/OSC32_OUT/ [SPI1_SCK](3)/ [USART1_RX](3)844PC5I/O Port C5 PC5/OSC32_IN /[SPI1_NSS](3)/[USART1_TX](3) 943PC4I/O Port C4 PC4/[USART1_CK](3)/ I2C1_SMB/CCO/LCD_SEG24(2)/ADC1_IN4/COMP2_INM/ COMP1_INPTable 6.P1 pinout (continued)Pin number (P1)Pin number(STM8L)Board pin nameT y p eMain functionAlternate function LCD (U5)UM0970Extension connectionDoc ID 17693 Rev 121/291042PC3I/O Port C3 PC3/[USART1_TX](3)/LCD_SEG23(2)/ADC1_IN5/COMP1_INP/ COMP2_INM LCD_SEG231141PC2I/O Port C2 PC2/[USART1_RX](3)/ LCD_SEG22/ADC1_IN6/COMP1_INP/VREF_OUT LCD_SEG221238PC1I/O Port C1 PC1(4)/I2C1_SCL 1337PC0I/O Port C0 PC0(4)/I2C1_SDA1436PD7I/O Port D7 PD7/TIM1_CH1N /LCD_SEG21(2)/ ADC1_IN7/RTC_ALARM/ VREF_OUT/ COMP1_INPLCD_SEG211535PD6I/O Port D6PD6/TIM1_BKIN /LCD_SEG20(2)/ ADC1_IN8/RTC_CALIB/ VREF_OUT/ COMP1_INP LCD_SEG201634PD5I/O Port D5PD5/TIM1_CH3 /LCD_SEG19(2)/ADC1_IN9/COMP1_INP LCD_SEG191733PD4I/O Port D4PD4/TIM1_CH2 /LCD_SEG18(2)/ADC1_IN10/COMP1_INP LCD_SEG181832PF0I/O Port F0PF0/ADC1_IN24/DAC_OUT 199/40GNDGroundTable 7.P2 pinout (continued)Pin number (P2)Pin number(STM8L)Pin nameT y p eMain functionAlternate function LCD (U5)Extension connectionUM097022/29Doc ID 17693 Rev 1Table 8.P3 pinoutPin number (P3)Pin number(STM8L)Pin nameT y p eMain functionAlternate function LCD (U5)122PD2I/O Port D2 PD2/TIM1_CH1 /LCD_SEG8(2)/ ADC1_IN20/COMP1_INP LCD_SEG8223PD3I/O Port D3 PD3/ TIM1_TRIG/ LCD_SEG9(2)/ADC1_IN1 9/COMP1_INP LCD_SEG9324PB0I/O Port B0 PB0/TIM2_CH1/ LCD_SEG10(2)/ ADC1_IN18/COMP1_INP LCD_SEG10425PB1I/O Port B1 PB1/TIM3_CH1/ LCD_SEG11(2)/ ADC1_IN17/COMP1_INP LCD_SEG11526PB2I/O Port B2 PB2/ TIM2_CH2/ LCD_SEG12(2)/ ADC1_IN16/COMP1_INP LCD_SEG12627PB3I/O Port B3 PB3/TIM2_TRIG/ LCD_SEG13(2)/ ADC1_IN15/COMP1_INP LCD_SEG13728PB4I/O Port B4 PB4/[SPI1_NSS](3)/ LCD_SEG14(2)/ ADC1_IN14/COMP1_INP LCD_SEG14829PB5I/O Port B5 PB5/[SPI1_SCK](3)/ LCD_SEG15(2)/ ADC1_IN13/COMP1_INP LCD_SEG15930PB6I/O Port B6 PB6/[SPI1_MOSI](3)/ LCD_SEG16(2)/ ADC1_IN12/COMP1_INP LCD_SEG161031PB7I/O Port B7 PB7/[SPI1_MISO](3)/ LCD_SEG17(2)/ ADC1_IN11/COMP1_INPLCD_SEG17Revision history UM097028/29Doc ID 17693 Rev 16 Revision historyTable 9.Document revision historyDateRevisionChanges24-Sep-20101Initial release.UM0970Please 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.UNL ESS OTHERWISE SET FORTH IN ST’S TERMS AND CONDITIONS OF SAL E ST DISCL AIMS ANY EXPRESS OR IMPL IED WARRANTY WITH RESPECT TO THE USE AND/OR SAL E OF ST PRODUCTS INCL UDING WITHOUT L IMITATION IMPL IED 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. UNL ESS EXPRESSL Y APPROVED IN WRITING BY AN AUTHORIZED ST REPRESENTATIVE, ST PRODUCTS ARE NOT RECOMMENDED, 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. ST PRODUCTS WHICH ARE NOT SPECIFIED AS "AUTOMOTIVE GRADE" MAY ONLY BE USED IN AUTOMOTIVE APPLICATIONS AT USER’S OWN RISK.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.© 2010 STMicroelectronics - All rights reservedSTMicroelectronics group of companiesAustralia - Belgium - Brazil - Canada - China - Czech Republic - Finland - France - Germany - Hong Kong - India - Israel - Italy - Japan - Malaysia - Malta - Morocco - Philippines - Singapore - Spain - Sweden - Switzerland - United Kingdom - United States of AmericaDoc ID 17693 Rev 129/29。

STM8L数据手册

STM8L数据手册

STM32-PRIMER STM8L-PRIMER
STMPRIMER (accessories)
STM3240GPRIMER STM3210GPRIMER(1) STM3210CPRIMER STM32L15PRIMER STM8L1526PRIMER STM3240GPRIM-D STM3210GPRIM-D(1) STM3210CPRIM-D STM32L15PRIM-D STM8L1526PRIM-D STMPRIMER-PROTO STMPRIMER-BASE STMPRIMER-EXT
The EvoPrimer range is an enhancement of the original Primer1 and Primer2 devices. It offers even more flexibility to evaluate a range of STM32 microcontrollers and STM8L ultralow power line microcontrollers, using the same EvoPrimer base with interchangeable target boards (to test different microcontrollers) or extension boards.
■ STM32F connectivity line EvoPrimer features: – STM32F107VC MCU with 256 KB Flash – Mini-USB OTG connector
■ STM32F performance line EvoPrimer features: – STM32F103VG MCU with 1 MB Flash – Mini-USB connector

STM8L中文参考手册_2

STM8L中文参考手册_2

手动开关手动开关没有自动切换为直接的但它提供给用户的切换事件时间的精确控制。

参照图20中的流程图。

1。

写使用系统时钟开关选择目标时钟源的8位值寄存器(clk_swr)。

然后swbsy位是由硬件,和目标源振荡器开始。

古老的时钟源继续驱动CPU和外设。

2。

该软件具有等到目标时钟源准备(稳定的)。

这是在clk_swcr寄存器和快捷旗由中断如果swien位设置显示。

3。

最终软件的作用是设置,在所选择的时间,在clk_swcr的赛文点寄存器来执行开关。

在手动和自动切换模式,旧的系统时钟源不会自动关闭的情况下是由其他模块(LSI混凝土可用于例如独立的看门狗驱动)。

时钟源可以关机使用在内部时钟寄存器的位(clk_ickcr)和外部时钟寄存器(clk_eckcr)。

如果时钟开关不因任何原因的工作,软件可以通过清除swbsy标志复位电流开关操作。

这将恢复clk_swr注册到其以前的内容(旧的系统时钟)。

注意:在清理swbsy标志具有复位时钟主开关的程序,应用程序必须等到后产生新的主时钟切换请求之前有一段至少两个时钟周期。

9.7周门控时钟(PCG)外周时钟门控(PCG)模式选择性地启用或禁用系统时钟(SYSCLK)连接到外围设备在运行或慢速模式的任何时间来优化功耗。

设备复位后,所有的外设时钟被禁用。

唯一的一点是在复位状态是默认启用pcken27因为它用于启动。

软件已被正确地写入关掉ROM Bootloader执行后的时钟。

您可以启用时钟的任何外围设置在clk_pckenrx周围门控时钟寄存器的相应pcken点。

●使周围,首先使在clk_pckenr相应的pcken点寄存器然后设置使点周围的外围控制寄存器。

●禁用适当的外围,先禁用在周边的适当位控制寄存器,然后停止相应的时钟。

注:蜂鸣器,RTC和液晶显示器是由不同的SYSCLK特定的时钟,使他们继续运行,即使时钟门控的外设寄存器是断言。

9.8时钟安全系统(CSS)9.8.1时钟安全系统对HSE时钟安全系统(CSS)监控HSE晶体时钟源故障时安全作为系统时钟。

基于 STM8L 的门锁控制和状态识别

基于 STM8L 的门锁控制和状态识别

基于STM8L 的门锁控制和状态识别җ*高小明(西南科技大学计算机科学与技术学院,绵阳621010)*基金项目:国家自然科学基金资助项目(项目编号:61202044)㊂摘要:门禁系统是一种管理人员进出的数字化智能系统,可以实时监控门的状态和合法用户的进出状况,防止非法用户强制闯入㊂门禁系统作为智能家居系统的一部分,在现代安防领域发挥了巨大作用,也给用户的使用和管理带来了极大的便利性㊁高效性和安全性㊂本文介绍了利用具有超低功耗的STM8L 微控制器为控制核心,设计了基于125KHz 的射频读卡模块,采用EM4100系列ID 卡作为用户身份识别卡,实现了对门锁的控制和状态的识别,并通过总线方式与服务器进行通信㊂实践表明,该系统整体功耗低㊁性能稳定㊁使用安全㊁管理方便㊂关键词:门禁控制系统;射频识别;STM8L ;总线通信;安防中图分类号:TP273.5 文献标识码:ALock Control and State Reco g nition Based on STM8L җGao Xiaomin g(School of Com p uter Science and Technolo gy ,Southwest Universit y of Science and Technolo gy ,Mian y an g 621010,China )Abstract :Gate -g uardin g s y stem is a smart di g ital s y stem which is used to control the access of p eo p le.It can monitor the state of the doors and the le g al users in real time ,and then p revents the ille g al users breakin g in the door.As p art of the smart home furnishin g s y s -tem ,the g ate -g uardin g s y stem p la y s an im p ortant role in modern securit y field ,and it also brin g s convenience ,effectiveness and safet yto the usin g and administration of the users.This p a p er introduces a desi g n usin g the ultra -low p ower STM8L microcontroller as the controllin g center ,and a 125kHz radio fre q uenc y card reader module is im p lemented usin g EM4100series ID card as user s identit y to control the lock and reco g nize the states ,and the communication with the server is carried on throu g h bus.The ex p eriment results show that the s y stem is low p ower consum p tion ,stable in functionin g ,safe to use and eas y to administrate.Ke y words :g ate -g uardin g s y stem ;RFID ;STM8L ;bus communication ;securit y 引 言在现代安防领域,门禁系统是安防自动化系统的一个重要环节,它对房间的出入口进行有效控制,通过身份认证的方式,允许合法人员的进出㊂门禁控制器主要实现用户身份信息的读取㊁合法身份比对㊁门锁的控制㊁与服务器进行数据通信等功能㊂本系统利用ST 公司的基于STM8L 的超低功耗微控制器为主控芯片,采用125kHz 的具有唯一标识的ID 识别卡作为用户身份卡,并自行设计了ID 卡读卡器及卡号解码程序,结合门锁控制模块㊁数据通信模块实现门禁系统的管理与控制㊂1 系统方案设计门禁控制器主要通过读取用户ID 身份信息,通过与本机合法ID 数据列表进行比对,并根据比对结果进行门锁的控制,并将操作数据传输给门禁服务器㊂本方案采用本地控制器存储合法用户的模式,一方面可以保证用户使用的实时性,另一方面可以保证即使在通信系统或服务器出现故障的情况下,依然能够进行门禁的正常操作㊂服务器系统仅用于ID 卡号的添加㊁删除㊁权限管理㊁事件查询等功能㊂微控制器(MCU )采用ST 公司的具有超低功耗的STM8L 系列微控制器STM8L052C6,该MCU 采用了全新的超低漏电工艺和优化的体系结构,集高性能与低功耗于一体,具备4种超低功耗工作模式,可以满足6μA 以内需要连续使用的要求,以及对低功耗有特殊要求的多种应用㊂读卡器采用自行设计的低功耗125kHz 射频卡读卡器,读写距离在5~10cm ,能够满足日常用户使用的需要㊂系统整机结构如图1所示㊂2 电路系统设计2.1 ID 卡读卡器电路ID 卡采用一种非接触㊁无源的射频识别技术,利用射图1 系统结构框图频信号及空间信号耦合传输特性,实现ID 卡与读卡器之间的数据交互㊂ID 卡作为应答器,内部本身不需要电池,内部所需要的电量全部来源于应答器与读卡器通过线圈耦合获取能量㊂因此,读卡器的天线直接影响到应答器的通信质量,其实现原理如图2所示㊂图2 无线识别系统框图为保证达到最佳通信效果,读卡器的天线回路与应答器的天线回路工作处于谐振状态,这样耦合功率最高,否则,将大大降低系统的性能㊂读卡器与应答器的两个天线回路L1㊁L2之间的互感系数定义如下:M 12=ψA2(I 1)I 1,M 12=M 21(1) 天线回路的耦合系数定义为:K =M L 1㊃L 2=ψA2(I 1)L 1L 2I 1(2)互感系数描述了两个回路通过磁场产生的耦合情况㊂耦合系数在0ɤKɤ1的极限范围内变化㊂K 随距离的变化而变化,当K=0时由于距离太远或磁屏蔽导致完全去耦;K=1处于全耦合状态㊂为保证可靠的通信,在5~10cm 范围内,应保证K 尽可能大㊂ID 卡读卡器主要包括发射电路和接收电路两个部分,发射部分用于驱动产生标准125kHz 载波信号,接收部分用于从载波信号中提取用户ID 卡唯一编号㊂载波发射驱动电路如图3所示㊂应答器在接收到读卡器的载波信号后,耦合产生电能,并将ID 卡号通过天线传输出去,接收电路将收到带有数据信息的载波信号,通过对信号滤波㊁检波㊁整流㊁比图3 载波发射驱动电路较放大等处理,提取数据信息,射频识别接收电路如图4所示㊂图4 射频识别接收电路为保证信号处于完全耦合状况,天线设计至关重要,本系统采用漆包线紧密绕制而成,回路处于谐振状态,则:f =12πLC(3)而天线的电感与线圈的直径㊁导体直径等相关,绕制线圈的电感值由以下公式确定:L =N 2㊃μ0R ㊃ln2R æèçöø÷d (4)其中:N 表示线圈绕制匝数;μ0表示磁场常数;R 表示线圈半径;d 表示导体直径㊂在f=125kHz 的情况下,根据式(3)㊁(4)确定谐振情况下的电感值L ,然后根据电感及实际应用环境绕制合适的天线㊂天线接收ID 卡信息后,通过一系列电路处理后,最终以数字信号的形式输出,该信号可直接连接到微控制器的端口,实现数据的采集㊂2.2 微控制器系统电路本系统采用ST 公司的具有超低功耗的STM8L 系列微控制器STM8L052C6,该芯片内部集成了1个8位定时器㊁3个16位定时器,并且所有GPIO 均可以配置成中断模式,方便实现数据的采集;内部集成的串口可用于门控制器与服务器的通信㊂本系统微控制器部分电路如图5所示㊂图5 微控制器系统电路实际应用中,系统采用了该微控制器芯片内部自带的一个16MHz 的RC 振荡器,进一步降低了系统的功耗,利用一个32.768kHz 的外部石英晶振,用于系统内部实时时钟㊂2.3 门锁控制电路门锁控制电路主要实现电机锁的开启㊁关闭状态的识别,本系统采用了浙江宏泰电子设备有限公司的灵性锁㊂图6 电机锁控制电路该锁采用12V 电源供电,利用两根数据线L +㊁L -控制开启,利用S +㊁S-反馈状态,微控制器通过相应的驱动隔离电路直接与这4根线进行通信㊂其电路如图6所示㊂2.4 通信电路通信电路主要实现门控制器与控制主机的通信,主机实现对整栋楼所有门控制器的管理㊂在实际应用中,采用RS485总线型通信方式,门控制器端采用串口转RS485的形式实现通信,其电路如图7所示㊂图7 RS485总线通信电路3 软件系统设计3.1 ID 卡数据解码125kHz 的典型ID 卡主要是瑞士的EM4100系列㊁台湾的4001系列,该类型ID 卡内部有64位激光可编程ROM ,采用曼切斯特码进行调制,单个数据位的宽度为512μs ,其数据结格式如图8所示㊂图8 ID 卡数据格式ID 卡ROM 中的数据以连续的9个 1作为头数据,用于读取数据时同步,D00~D90为ID 卡号数据,具有唯一编号,P0~P9为对应的行校验位,C0~C3为对应的列校验位,最后以0结束㊂根据曼彻斯特编码原则,上升沿对应的位表示数据0 ,下降沿对应的位表示数据 1,因此,利用微控制器端口边沿触发中断和定时器延迟计算相结合的方式实现对外部数据的采集,在利用曼彻斯特编码规则将采集的数据还原成用户ID 卡号,处理流程略编者注㊂3.2 门禁控制器处理软件处理软件主要实现用户权限的管理㊁门锁的控制㊁门锁状态的监控㊁网络通信等功能,在平时待机状态下则转入到低功耗模式,以节省电能㊂整机工作流程略 编者注㊂4方案测试结果4.1测试目标㊁方法与仪器根据上面叙述的方法设计并实现了该套系统,并部署在我院办公大楼,单门个数达99个,并经过了长期应用测试㊂针对单个门禁控制器性能做了如下测试,见表1㊂表1测试目标㊁方法与仪器测试目标测试仪器仪器型号测试方法读卡距离游标卡尺无刷卡测试误码测试无无统计测试功耗测试微安表GDM8261W=UI通信可靠性无无统计测试4.2测试结果在测试中,采用标准的ID卡测试卡面与读卡器天线之间能够正常通信的距离,在读卡正常的情况下统计ID 卡的误码率,并测试了服务器与门禁控制器的通信可靠性㊂测试结果如表2所列㊂表2测试结果样本编号识别距离/cm读卡误码率/%通信误码率/%平均电流/mA111.30.703211.70.303310.80.603411.20.7034.3测试结果分析上述测试中采用了4个不同的模块,对每个模块进行了测试,正常情况下ID卡的识别距离均能达到11cm,在距离较远的情况下,误码率比较高㊂同时在门状态发生改变的情况下,由于系统中断的原因,也会产生一定的误码率,在正常使用的情况下,刷卡出现误码的概率极低,完全能够满足正常使用的需要㊂对系统通信进行了长达数十小时的数据统计测试,未发现传输数据丢失和错误的情况,与数据传输波特率较低(1200 b p s)有一定关系㊂实验证明,该系统工作较为稳定㊂结语本文介绍了采用ST公司的具有超低功耗的STM8L 系列微控制器STM8L052C6设计门禁控制器的原理及方法,系统电路结构简单,体积小巧,安装方便,目前已投入正常使用㊂且在使用中也经历了雷雨天气的考验,经过实践证明,该系统完全能够满足办公楼群及智能小区门禁控制的需要,系统使用安全㊁管理方便,具有较大的市场应用空间㊂编者注:本文为期刊缩略版,全文见本刊网站www. ㊂参考文献[1]刘淑英,蔡胜乐,王文辉.电路与电子学[M].2版.北京:电子工业出版社,2002.[2]李卓徽.基于RFID的人员身份识别及定位系统研制[J].计算机测量与控制,2012,20(8):22812284.[3]邓强东,王立斌.一种高效可证明安全的RFID认证协议[J].小型微型计算机系统,2012,33(11):25082512. [4]周权,王奕,李仁发.RFID系统中低功耗J H算法的设计与实现[J].小型微型计算机系统,2013,34(8):19441948.[5]张挺,熊璋,王剑昆,等.一个面向低功耗设计的RFID系统研究与实现[J].小型微型计算机系统,2006,27(11):20902093.[6]周永彬,冯登国.RFID安全协议的设计与分析[J].计算机学报,2006,29(4):581589.[7]丁振华,李锦涛,冯波.基于Hash函数的RFID安全认证协议研究[J].计算机研究与发展,2009,46(4):583592.[8]马昌社.前向隐私的低成本RFID认证协议[J].计算机学报, 2011,34(8):13871397.[9]张博,李军怀,王志晓,等.RFID并行化定位方法研究与实现[J].计算机工程与应用,2012,12(20):687697. [10]谷峪,于戈,李传文.半限制空间内的RFID可能性k近邻查询技术[J].软件学报,2012,23(3):565581. [11]张忠,徐秋亮.物联网环境下UC安全的组证明RFID协议[J].计算机学报,2011,34(7):11881194. [12]吴爱华.多固定阅读器下基于路径约束的RFID数据清洗算法[J].计算机研究与发展,2011,48(1):282289. [13]金宏,王宏安,唐雪梅,等.计算机控制中的模糊调度设计[J].计算机学报,2006,29(3):414421.[14]鲍可进,姚成.基于双核数字信号处理器的人脸识别门禁系统[J].计算机应用,2010,30(9):25532555.高小明(硕士),主要研究方向为嵌入式系统技术㊁数字信号处理㊁嵌入式图像处理㊂(责任编辑:杨迪娜收稿日期:2013-12-24)。

STM8开发板原理图

STM8开发板原理图

D1 LED1
D2 LED2
按键3
C14 GND 104
第四版原理图
PC3 OSI J1 4 3 2 1 VDD SWIM GND RST C2 22 16M Y1 GND C3 22 OSO
PC4
PD2
B
仿真器接口
SWIM
HSE
LED
KEY
FLASH
B
J2 VDD R1 1032 NRST J4 C4 104 GND VDD S4 3 2 1 CON3 5VIN
PD7/TLI/T1_C4 PD6/UART1_RX PD5/UART1_TX PD4/BEEP/T2_C1 PD3/T2_C2/ADC_ETR PD2/T2_C3 PD1/SWIM PD0/_T1_BKIN PC7/SPI_MISO PC6/SPI_MOSI PC5/SPI_SCK PC4/T1_C4/CCO PC3/T1_C3 PC2/T1_C2 PC1/T1_C1/UART1_CK PE5/SPI_NSS
跳线
C10 104 GND
MINIUSB接口 XI Y2 XO
电源选择跳线
蜂鸣器
LS1
VDD
R3 103
多用途液晶接口
光敏电阻
Q1 PNP
OLED直接插/段码液晶电路板上靠右侧插
GND Title
D
双跳线
USB转TTL
1 2 3
蜂鸣器
4
ADC
5
B Date: File:
32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17
PD7 PD6 PD5 PD4 PD3 PD2 PD1 PD0 PC7 PC6 PC5 PC4 PC3 PC2 PC1 PE5

STM8L中文参考手册(4)-

STM8L中文参考手册(4)-

STM8L中文参考手册(4)-20 16位通用定时器(TIM2、TIM3、tim5)20.1简介本章介绍TIM2、TIM3和tim5是相同的定时器每个定时器包括一个由可编程分频器驱动的16位上下自动重载计数器它可以用于多种目的,包括:●定时产生●测量输入信号的脉冲长度(输入捕获)●产生输出波形(输出比较、脉宽调制和脉冲模式)●各种中断能力事件(捕获、比较、溢出)●与其他定时器或外部信号(外部时钟、复位、触发使能)同步定时器时钟可以来自内部时钟,也可以来自配置寄存器或外部源本章仅介绍通用定时器的主要特性。

它参考了与19:16高级控制定时器(TIM1)相对应的部分中的每个功能的更详细的信息页28320.2 TIMx 主要功能通用TIMx TIM2/TIM3功能包括:●16位向上、向下、向上/向下自动刷新计数器●3位可编程分频器允许将计数器的时钟频率分成1至128的任意2次方两个独立的低电平通道:输入捕获输出比较脉冲宽度调制产生(边沿对齐)-一个脉冲输出模式低电平中断输入,用于复位定时器输出信号,或处于已知状态●输入捕捉2可通过来自comp2比较器:更新的中断和DMA请求产生以下事件:当计数器溢出时,计数器初始化(软件)输入捕捉输出比较中断输入触发事件(开始、停止、内部/外部触发初始化或计数)20.3.1时间单元定时器时基单元包括:●16位可逆计数器时钟源是内部时钟(fsysclk)它由预分频器计数器的时钟ck_cnt驱动,预分频器计数器直接连接到ck_psc时钟馈送分频器分频器的实现如下:7位计数器(在timx_pscr寄存器中)由基于低预分频器的3位寄存器控制它可以控制飞行中寄存器缓冲区的变化。

它可以将计数器的时钟频率转换为1、2、4、8、16、32、64或128计数器的时钟频率计算如下:fCk _ CNT = fck _ PSC/2(PSCR[2:0)计数器操作请参考第19.3.4页:上部288,模式部分19.3.5:在第290页向下计数,模式19.3.6:中心对齐(向上/向下计数)29220.3.2时钟/触发控制器参见第296页第19.4节:TIM1时钟/触发控制器20.3.3采集/比较通道输入级参见第310页第19.5节:TIM1采集/比较通道有两个输入通道,如图122:输入级框图通道2内部连接到比较器输出级参见第19.5.4页:315,输出级19.5.5:强制输出模式在第316页,第19.5.7页:脉宽调制模式在第318页如图124所示。

STM8L数据手册

STM8L数据手册

UM0970用户手册STM8L-DISCOVERY 简介STM8L-DISCOVERY可以帮助用户探索发现STM8L的超低功耗特性,也可以开发相关的应用。

STM8L-DISCOVERY是基于STM8L152C6T6芯片做的开发板,包括一个嵌入的ST-LINK调试工具接口(ST-LINK调试器/编程器集成在同一块板子上,留有SWIM调试接口)、LCD(24段,4个COM 端)和按键。

图 1STM8L-DISCOVERY板本文仅供参考,请以ST官方文档为准/internet/com/TECHNICAL_RESOURCES/TECHNICAL_LITERATURE/USER_MANUAL/CD00278045.pdf目 录第1章 快速入门 (4)1.1 开始 (4)1.2 系统要求 (4)1.3 开发工具 (5)1.4 演示软件 (5)1.5 订单编码 (5)第2章 特点 (6)第3章 硬件和布局 (7)3.1 STM8L152C6T6微控制器 (11)3.2 嵌入的ST-LINK (13)3.2.1 使用ST-LINK编程/调试板上STM8L (14)3.2.2 使用ST-LINK编程/调试外部STM8L应用 (14)3.3 供电和电源选择 (15)3.4 LED灯 (15)3.5 按键 (16)3.6 内建的IDD测量电路 (16)3.6.1 运行模式 (17)3.6.2 低功耗模式 (17)3.6.3 低功耗模式IDD测量原理 (17)3.6.4 Ibias电流测量步骤 (18)3.7 锡桥 (18)3.8 LCD(24段,4个COM) (19)第4章 扩展连接 (22)第5章 机械制图 (26)第6章 电气原理图 (28)2 - 王志杰(QQ:411238869; MSN:iewangzhijie@)Design a Solution for Future第1章快速入门第1章 快速入门STM8L-DISCOVERY是一个低成本的、易于使用的开发工具,可快速评估和开始一个STM8L超低功耗微控制器的开发。

STM8L微控制器中文参考手册

STM8L微控制器中文参考手册

本参考手册的目标应用程序开发人员。

它提供了完整的信息如何使用stm8l05xx,stm8l15xx和stm8l16xx 微控制器的存储器和外围设备。

该stm8l05xx / stm8l15xx / stm8l16xx是一个家庭的不同存储密度的微控制器和外围设备。

这些产品是专为超低功耗应用。

可用的外设的完整列表,请参阅产品数据表。

订购信息,引脚说明,机械和电气设备的特点,请参阅产品数据表。

关于STM8 SWIM通信协议信息和调试模块,请参阅用户手册(um0470)。

在STM8的核心信息,请参阅STM8的CPU编程手册(pm0044)。

关于编程,擦除和保护的内部快闪记忆体,请参阅STM8L闪存编程手册(pm0054)。

1 中央处理单元(CPU)。

30。

1.1 引言301.2 CPU的寄存器。

30。

1.2.1 描述CPU寄存器。

..。

301.2.2 STM8 CPU寄存器图。

..。

341.3 全球配置寄存器(cfg_gcr)。

34。

1.3.1 激活水平。

..。

341.3.2 游泳禁用。

..。

351.3.3 描述全局配置寄存器(cfg_gcr)。

..。

35 1.3.4 全局配置寄存器图及复位值。

..。

352 启动ROM . . . 363程序存储器和数据存储器。

37。

3.1引言373.2术语。

37。

3.3个主要的快闪存储器的特点。

38。

3.4记忆的组织。

39。

3.4.1低密度设备的存储器组织。

393.4.2介质密度的装置记忆的组织。

..。

40 3.4.3介质+密度装置记忆的组织。

..。

41 3.4.4高密度存储器组织。

..。

423.4.5专有代码区(译)。

433.4.6用户区(UBC)。

433.4.7数据的EEPROM(数据)。

..。

463.4.8主程序区。

463.4.9选项字节。

..。

463.5内存保护。

47。

3.5.1读出保护。

473.5.2内存访问安全系统(质量)。

473.5.3使写访问选项字节。

单片机这么简单?一分钟看懂单片机最小系统电路原理图:STM8S

单片机这么简单?一分钟看懂单片机最小系统电路原理图:STM8S

单片机这么简单?一分钟看懂单片机最小系统电路原理图:STM8S本文以ST公司的STM8S003单片机为例,给大家讲解一个单片机最小系统的电路原理图:通过单片机采集一个按键信号,点亮一颗LED灯。

如果你看懂了这张原理图,单片机硬件就入门了——真的到进门了!一、系统框架电源从电源插座P1进入电路板,经过LM7805稳压成VCC(=5V)给单片机供电,单片机采集按键S1的信号,点亮LED灯D2,编译好的程序经过程序下载口JP1下载到单片机里。

二、电路细节电源插座P1可以采用12V电源,二极管D1的作用是为了防止电源不小心反接而损坏电路器件。

LM7805前面的两个电容C1和C2和后面的两个电容C3和C4是为电压滤波的,进一步稳定VCC的电压,让VCC的纹波不要太大,因为纹波大了会影响单片机的工作。

电容C5和C6是依据STM8S003的数据手册要求必须用的两颗电容,遵照执行即可,暂时不用深究,后续我的文章中会谈到。

电阻R1是为了限制发光二极管(LED)D2的电流。

LED一般需要5-10mA的电流才能点亮,LED本身的压降一般比较固定,其值是1V左右,当单片机控制PC6口输出低电平时,LED将被点亮,这时LED中的电流为:(5V-1V)/0.47KΩ=8.5mA。

按键S1一端接地,一端接单片机PD3口,在PD3口内部可以通过软件设置上拉电阻,当S1断开时,PD3口为高电平;当S1闭合时,PD3口为低电平。

单片机依据PD3口的电平状态即可获知按键是否闭合。

JP1是程序下载接口,所有STM8单片机的程序下载接口都是一样的。

其中NRST为单片机复位接口,SWIM为程序下载的数据通道,电脑里的程序代码就是通过SWIM传输到单片机中的。

疑问:为啥没有时钟(晶振)电路?因为现在的单片机一般内部集成有RC振荡电路,通过软件可以设置单片机选用内部的RC振荡脉冲作为单片机内部的时钟。

只是内部RC振荡电路的时钟不是太精准,对于一些时钟精度要求比较高的场合可以外接晶振电路。

STM8L中文参考手册-4

STM8L中文参考手册-4

STM8L中文参考手册-420个16位通用定时器(TIM2,TIM3,tim5)20.1引言本章介绍TIM2,TIM3和tim5是相同的定时器。

每个定时器包括一个16位的升降自动重载计数器由一个可编程分频器驱动。

它可用于多种用途,包括:●时基产生●测量输入信号的脉冲长度(输入捕捉)●生成输出波形(输出比较,脉宽调制和脉冲模式)●中断能力的各种事件(捕获,比较,溢出)●同步与其他计时器或外部信号(外部时钟,复位,触发使)定时器时钟可以来自内部时钟可以通过配置寄存器或从外部源。

只有通用定时器的主要特点是本章中提出的。

指的是部分19:16点先进控制定时器对应的段落(TIM1)对每个功能的更多详细信息页面283。

20.2 TIMx主要特点通用TIMx TIM2 / TIM3功能包括:●16位上,下,上/ downauto刷新计数器。

●3位可编程分频器使计数器的时钟频率可分‖ 飞‖的任何权力,2从1到128。

2个独立的通道●:输入捕捉输出比较PWM生成(边缘对齐方式)-一个脉冲输出的方式●中断输入将定时器的输出信号在复位状态,或在一个已知状态。

●输入捕捉2可以通过从comp2比较器●中断和DMA请求生成下列事件:更新:计数器溢出时,计数器初始化(软件)输入捕捉输出比较中断输入触发事件(计数器的启动,停止,内部/外部触发初始化或计数)20.3.1时间单位计时器时基单元包括:●16位可逆计数器●16位自动重载寄存器●3位可编程分频器没有重复计数器。

时钟源是内部时钟(fsysclk)。

它是直接连接到ck_psc 时钟饲料的预分频器计数器的时钟ck_cnt驱动。

分频器分频器实现如下:●预分频器的基础上通过一个3位寄存器控制的7位计数器(在 timx_pscr寄存器)。

它可以在飞这控制寄存器缓冲的改变。

它可以将计数器的时钟频率的1,2,4,8,16,32,64或128。

计数器的时钟频率计算如下:fck_cnt = fck_psc / 2(PSCR [2:0])计数器操作请参阅第19.3.4:上数288页,模式部分19.3.5:向下计数在290页和第19.3.6模式:中心对齐方式(向上/向下计数)292页。

STM8微控制器设计入门(四)-开发工具

STM8微控制器设计入门(四)-开发工具

STM8微控制器设计入门(四)开发工具V1.0王志杰2014/6/28版权所有,翻版必究目录1概述 (1)2STM8软件开发工具 (1)2.1IAR-EWSTM8 (1)2.2IDEA (2)2.3RIDE (3)2.4STM-STUDIO (3)2.5STVD (4)2.6STVP (5)2.6.1 编程步骤 (6)2.6.2 自动编程 (6)2.6.3 重新编程 (7)2.6.4 Bootloader (8)3开发工具和评估板 (9)3.1 ST-LINK调试/编程工具 (9)3.2 STM8S-DISCOVERY探索板 (10)3.3 STM8SVLDISCOVERY超值型探索板 (11)3.4 STM8/128-EVA评估板 (12)3.5 STM8L-DISCOVERY探索板 (13)3.6 STM8L1528-EVAL评估板 (14)3.7 STM8L101-EVAL评估板 (15)4固件 (16)4.1 固件库 (16)4.2 电机控制固件 (19)5 STM8电机控制套件 (20)1概述ST为STM8提供了不同的工具以及各种的固件和评估板,方便用户开发。

本文就简要地说明STM8开发工具的那点事儿。

2STM8软件开发工具目前,ST及第三方提供了如下表的软件方便用户开发。

上述STM8的软件开发工具较为主流的是:●STVD,ST公司的软件开发工具,仅提供汇编支持,不支持C语音●STVD+COSMIC ,STVD中外挂COSMIC C语音编译器●EWSTM8,IAR公司的C语音集成开发环境。

无需外挂。

2.1IAR-EWSTM8IAR-EWSTM8是一套软件开发工具,完全支持STM8AF、STM8AL、STM8L和STM8S 系列微控制器,以及STLUX™数字控制器。

特点:●重要组件:⏹具有项目管理工具和编辑的集成开发环境⏹为STM8高度优化的C和C++编译器⏹MISRA C规则的自动检测(MISRA-C:2004)⏹所有STM8微控制器的配置文件⏹实时运行库⏹重定向STM8汇编⏹连接器和库工具⏹C-SPY调试器,支持RTOS硬件调试⏹工程实例和代码模版⏹PDF格式的用户参考手册⏹线上帮助●调试系统支持⏹C-SPY调试仿真器⏹STice仿真系统⏹ST-LINK调试器⏹C-SY调试器,第三方调试SDK●RTOS支持⏹RTOS固件调试,内置的OSEK实时库接口ORTI⏹RTOS在C-SPY中安装了一定数量的新窗口,最重要的任务或线程列表窗口可指定特定的重点和任务的具体执行步骤。

stm8l中文参考手册(上)

stm8l中文参考手册(上)

本参考手册的目标应用程序开发人员。

它提供了完整的信息如何使用stm8l05xx,stm8l15xx 和stm8l16xx微控制器的存储器和外围设备。

该stm8l05xx / stm8l15xx / stm8l16xx是一个家庭的不同存储密度的微控制器和外围设备。

这些产品是专为超低功耗应用。

可用的外设的完整列表,请参阅产品数据表。

订购信息,引脚说明,机械和电气设备的特点,请参阅产品数据表。

关于STM8 SWIM通信协议信息和调试模块,请参阅用户手册(um0470)。

在STM8的核心信息,请参阅STM8的CPU编程手册(pm0044)。

关于编程,擦除和保护的内部快闪记忆体,请参阅STM8L闪存编程手册(pm0054)。

表一、类型零件号控制器价值线低密度stm8l05xx设备:stm8l051x3 8KB Flash微控制器价值线中密度stm8l05xx设备:stm8l052x6微控制器与32闪光价值线高密度stm8l05xx设备:stm8l052x8 64-KB闪存微控制器低密度stm8l15x设备:stm8l151c2 / K2 / G2/F2,stm8l151c3 / K3 / G3 / F3微控制器与4KB或8KB Flash中密度stm8l15xx设备:stm8l151c4 / K4 / G4,微控制器stm8l151c6 / K6 / G6,stm8l152c4 / K4和stm8l152c6 / K6微控制器与16-KB或32闪光培养基+密度stm8l15xx设备:stm8l151r6和stm8l152r6微控制器与闪存(32比中密度器件广泛的外设范围)高密度stm8l15xx设备:stm8l151x8和stm8l152x8随着64-KB闪存微控制器(相同的外周设置为中等+)高密度stm8l16xx设备:stm8l162x8微控制器与闪存(相同的外周设置为64-KB高密度stm8l152设备加AES硬件加速器1 中央处理单元(CPU)。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
相关文档
最新文档