收藏 分享(赏)

STM32F10xxx Cortex-M3编程手册-英文版.pdf

上传人:a****2 文档编号:3048829 上传时间:2024-01-18 格式:PDF 页数:154 大小:1.34MB
下载 相关 举报
STM32F10xxx Cortex-M3编程手册-英文版.pdf_第1页
第1页 / 共154页
STM32F10xxx Cortex-M3编程手册-英文版.pdf_第2页
第2页 / 共154页
STM32F10xxx Cortex-M3编程手册-英文版.pdf_第3页
第3页 / 共154页
STM32F10xxx Cortex-M3编程手册-英文版.pdf_第4页
第4页 / 共154页
STM32F10xxx Cortex-M3编程手册-英文版.pdf_第5页
第5页 / 共154页
STM32F10xxx Cortex-M3编程手册-英文版.pdf_第6页
第6页 / 共154页
亲,该文档总共154页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述

1、 April 2010Doc ID 15491 Rev 31/154PM0056Programming manualSTM32F10 xxx Cortex-M3 programming manualThis programming manual provides information for application and system-level software developers.It gives a full description of the STM32F10 xxx Cortex-M3 processor programming model,instruction set a

2、nd core peripherals.The STM32F10 xxx Cortex-M3 processor is a high performance 32-bit processor designed for the microcontroller market.It offers significant benefits to developers,including:Outstanding processing performance combined with fast interrupt handlingEnhanced system debug with extensive

3、breakpoint and trace capabilitiesEfficient processor core,system and memoriesUltra-low power consumption with integrated sleep modesPlatform ContentsPM00562/154 Doc ID 15491 Rev 3Contents1About this document .101.1Typographical conventions.101.2List of abbreviations for registers .101.3About the STM

4、32 Cortex-M3 processor and core peripherals.101.3.1System level interface .111.3.2Integrated configurable debug.111.3.3Cortex-M3 processor features and benefits summary.121.3.4Cortex-M3 core peripherals.132The Cortex-M3 processor.142.1Programmers model.142.1.1Processor mode and privilege levels for

5、software execution.142.1.2Stacks .142.1.3Core registers .152.1.4Exceptions and interrupts .232.1.5Data types .232.1.6The Cortex microcontroller software interface standard(CMSIS).242.2Memory model.252.2.1Memory regions,types and attributes .262.2.2Memory system ordering of memory accesses.272.2.3Beh

6、avior of memory accesses.272.2.4Software ordering of memory accesses .282.2.5Bit-banding.292.2.6Memory endianness .312.2.7Synchronization primitives.322.2.8Programming hints for the synchronization primitives.332.3Exception model.342.3.1Exception states .342.3.2Exception types.342.3.3Exception handl

7、ers .362.3.4Vector table .372.3.5Exception priorities .372.3.6Interrupt priority grouping.382.3.7Exception entry and return .38PM0056ContentsDoc ID 15491 Rev 33/154 2.4Fault handling.412.4.1Fault types.412.4.2Fault escalation and hard faults.422.4.3Fault status registers and fault address registers

8、.432.4.4Lockup.432.5Power management.432.5.1Entering sleep mode .442.5.2Wakeup from sleep mode .442.5.3The external event input .452.5.4Power management programming hints .453The Cortex-M3 instruction set .463.1Instruction set summary.463.2Intrinsic functions.513.3About the instruction descriptions

9、.523.3.1Operands.523.3.2Restrictions when using PC or SP.533.3.3Flexible second operand .533.3.4Shift operations .543.3.5Address alignment.573.3.6PC-relative expressions.573.3.7Conditional execution.583.3.8Instruction width selection .603.4Memory access instructions.613.4.1ADR.613.4.2LDR and STR,imm

10、ediate offset .623.4.3LDR and STR,register offset.643.4.4LDR and STR,unprivileged.653.4.5LDR,PC-relative .663.4.6LDM and STM .683.4.7PUSH and POP.693.4.8LDREX and STREX.713.4.9CLREX.723.5General data processing instructions.733.5.1ADD,ADC,SUB,SBC,and RSB.743.5.2AND,ORR,EOR,BIC,and ORN.76 ContentsPM0

11、0564/154 Doc ID 15491 Rev 33.5.3ASR,LSL,LSR,ROR,and RRX .773.5.4CLZ .783.5.5CMP and CMN.793.5.6MOV and MVN.803.5.7MOVT.813.5.8REV,REV16,REVSH,and RBIT.823.5.9TST and TEQ.833.6Multiply and divide instructions .843.6.1MUL,MLA,and MLS.843.6.2UMULL,UMLAL,SMULL,and SMLAL .863.6.3SDIV and UDIV .873.7Satur

12、ating instructions .883.7.1SSAT and USAT.883.8Bitfield instructions.893.8.1BFC and BFI .903.8.2SBFX and UBFX .903.8.3SXT and UXT.913.8.4Branch and control instructions.923.8.5B,BL,BX,and BLX.933.8.6CBZ and CBNZ .943.8.7IT .953.8.8TBB and TBH.973.9Miscellaneous instructions.983.9.1BKPT.993.9.2CPS.993

13、.9.3DMB.1003.9.4DSB.1003.9.5ISB.1013.9.6MRS.1013.9.7MSR.1023.9.8NOP.1033.9.9SEV .1033.9.10SVC.1043.9.11WFE.1043.9.12WFI .1054Core peripherals .106PM0056ContentsDoc ID 15491 Rev 35/154 4.1About the STM32 core peripherals .1064.2Memory protection unit(MPU).1064.2.1MPU access permission attributes .107

14、4.2.2MPU mismatch .1094.2.3Updating an MPU region.1094.2.4MPU design hints and tips.1114.2.5MPU type register(MPU_TYPER).1124.2.6MPU control register(MPU_CR).1134.2.7MPU region number register(MPU_RNR).1144.2.8MPU region base address register(MPU_RBAR).1154.2.9MPU region attribute and size register(

15、MPU_RASR).1174.3Nested vectored interrupt controller(NVIC).1194.3.1The CMSIS mapping of the Cortex-M3 NVIC registers.1204.3.2Interrupt set-enable registers(NVIC_ISERx).1214.3.3Interrupt clear-enable registers(NVIC_ICERx).1224.3.4Interrupt set-pending registers(NVIC_ISPRx).1234.3.5Interrupt clear-pen

16、ding registers(NVIC_ICPRx).1244.3.6Interrupt active bit registers(NVIC_IABRx).1254.3.7Interrupt priority registers(NVIC_IPRx).1264.3.8Software trigger interrupt register(NVIC_STIR).1274.3.9Level-sensitive and pulse interrupts.1274.3.10NVIC design hints and tips .1284.3.11NVIC register map.1294.4Syst

17、em control block(SCB).1304.4.1CPUID base register(SCB_CPUID).1304.4.2Interrupt control and state register(SCB_ICSR).1314.4.3Vector table offset register(SCB_VTOR).1334.4.4Application interrupt and reset control register(SCB_AIRCR).1344.4.5System control register(SCB_SCR).1354.4.6Configuration and co

18、ntrol register(SCB_CCR).1364.4.7System handler priority registers(SHPRx).1374.4.8System handler control and state register(SCB_SHCSR).1394.4.9Configurable fault status register(SCB_CFSR).1414.4.10Hard fault status register(SCB_HFSR).1444.4.11Memory management fault address register(SCB_MMFAR).1464.4

19、.12Bus fault address register(SCB_BFAR).1464.4.13System control block design hints and tips .147 ContentsPM00566/154 Doc ID 15491 Rev 34.4.14SCB register map .1474.5SysTick timer(STK).1484.5.1SysTick control and status register(STK_CTRL).1484.5.2SysTick reload value register(STK_LOAD).1494.5.3SysTic

20、k current value register(STK_VAL).1514.5.4SysTick calibration value register(STK_CALIB).1514.5.5SysTick design hints and tips.1524.5.6SysTick register map.1525Revision history .153PM0056List of tablesDoc ID 15491 Rev 37/154 List of tablesTable 1.Summary of processor mode,execution privilege level,an

21、d stack use options.15Table 2.Core register set summary.15Table 3.PSR register combinations.17Table 4.APSR bit definitions.18Table 5.IPSR bit definitions.19Table 6.EPSR bit definitions.20Table 7.PRIMASK register bit definitions.21Table 8.FAULTMASK register bit definitions.21Table 9.BASEPRI register

22、bit assignments.22Table 10.CONTROL register bit definitions.22Table 11.Ordering of memory accesses.27Table 12.Memory access behavior.27Table 13.SRAM memory bit-banding regions.29Table 14.Peripheral memory bit-banding regions.29Table 15.C compiler intrinsic functions for exclusive access instructions

23、.33Table 16.Properties of the different exception types.35Table 17.Exception return behavior.40Table 18.Faults.41Table 19.Fault status and fault address registers.43Table 20.Cortex-M3 instructions.46Table 21.CMSIS intrinsic functions to generate some Cortex-M3 instructions.51Table 22.CMSIS intrinsic

24、 functions to access the special registers.52Table 23.Condition code suffixes.59Table 24.Memory access instructions.61Table 25.Immediate,pre-indexed and post-indexed offset ranges.63Table 26.label-PC offset ranges .67Table 27.Data processing instructions.73Table 28.Multiply and divide instructions.8

25、4Table 29.Packing and unpacking instructions.89Table 30.Branch and control instructions .92Table 31.Branch ranges .93Table 32.Miscellaneous instructions.98Table 33.STM32 core peripheral register regions.106Table 34.Memory attributes summary.107Table 35.TEX,C,B,and S encoding.108Table 36.Cache policy

26、 for memory attribute encoding .108Table 37.AP encoding.108Table 38.Memory region attributes for STM32 .112Table 39.Example SIZE field values.118Table 40.MPU register map and reset values.118Table 41.Mapping of interrupts to the interrupt variables .120Table 42.IPR bit assignments.126Table 43.CMSIS

27、functions for NVIC control .128Table 44.NVIC register map and reset values.129Table 45.Priority grouping.135Table 46.System fault handler priority fields.137Table 47.SCB register map and reset values.147Table 48.SysTick register map and reset values.152 List of tablesPM00568/154 Doc ID 15491 Rev 3Ta

28、ble 49.Document revision history .153PM0056List of figuresDoc ID 15491 Rev 39/154 List of figuresFigure 1.STM32 Cortex-M3 implementation.11Figure 2.Processor core registers.15Figure 3.APSR,IPSR and EPSR bit assignments.17Figure 4.PSR bit assignments .17Figure 5.PRIMASK bit assignments.21Figure 6.FAU

29、LTMASK bit assignments .21Figure 7.BASEPRI bit assignments .22Figure 8.CONTROL bit assignments .22Figure 9.Memory map.25Figure 10.Bit-band mapping.30Figure 11.Little-endian example.31Figure 12.Vector table.37Figure 13.ASR#3 .55Figure 14.LSR#3.55Figure 15.LSL#3.56Figure 16.ROR#3.56Figure 17.RRX#3.56F

30、igure 18.Subregion example.111Figure 19.NVIC_IPRx register mapping.126Figure 20.CFSR subregisters.141 About this documentPM005610/154 Doc ID 15491 Rev 31 About this documentThis document provides the information required for application and system-level software development.It does not provide infor

31、mation on debug components,features,or operation.This material is for microcontroller software and hardware engineers,including those who have no experience of ARM products.1.1 Typographical conventionsThe typographical conventions used in this document are:1.2 List of abbreviations for registersThe

32、 following abbreviations are used in register descriptions:1.3 About the STM32 Cortex-M3 processor and core peripheralsThe Cortex-M3 processor is built on a high-performance processor core,with a 3-stage pipeline Harvard architecture,making it ideal for demanding embedded applications.The processor

33、delivers exceptional power efficiency through an efficient instruction set and extensively optimized design,providing high-end processing hardware including single-cycle 32x32 multiplication and dedicated hardware division.italic Highlights important notes,introduces special terminology,denotes inte

34、rnal cross-references,and citations.Enclose replaceable terms for assembler syntax where they appear in code or code fragments.For example:LDRSB,#read/write(rw)Software can read and write to these bits.read-only(r)Software can only read these bits.write-only(w)Software can only write to this bit.Rea

35、ding the bit returns the reset value.read/clear(rc_w1)Software can read as well as clear this bit by writing 1.Writing 0 has no effect on the bit value.read/clear(rc_w0)Software can read as well as clear this bit by writing 0.Writing 1 has no effect on the bit value.toggle(t)Software can only toggle

36、 this bit by writing 1.Writing 0 has no effect.Reserved(Res.)Reserved bit,must be kept at reset value.PM0056About this documentDoc ID 15491 Rev 311/154 Figure 1.STM32 Cortex-M3 implementationTo facilitate the design of cost-sensitive devices,the Cortex-M3 processor implements tightly-coupled system

37、components that reduce processor area while significantly improving interrupt handling and system debug capabilities.The Cortex-M3 processor implements a version of the Thumb instruction set,ensuring high code density and reduced program memory requirements.The Cortex-M3 instruction set provides the

38、 exceptional performance expected of a modern 32-bit architecture,with the high code density of 8-bit and 16-bit microcontrollers.The Cortex-M3 processor closely integrates a configurable nested interrupt controller(NVIC),to deliver industry-leading interrupt performance.The NVIC includes a non-mask

39、able interrupt(NMI),and provides up to 256 interrupt priority levels.The tight integration of the processor core and NVIC provides fast execution of interrupt service routines(ISRs),dramatically reducing the interrupt latency.This is achieved through the hardware stacking of registers,and the abilit

40、y to suspend load-multiple and store-multiple operations.Interrupt handlers do not require any assembler stubs,removing any code overhead from the ISRs.Tail-chaining optimization also significantly reduces the overhead when switching from one ISR to another.To optimize low-power designs,the NVIC int

41、egrates with the sleep modes,that include a deep sleep function that enables the STM32 to enter STOP or STDBY mode.1.3.1 System level interfaceThe Cortex-M3 processor provides multiple interfaces using AMBA technology to provide high speed,low latency memory accesses.It supports unaligned data acces

42、ses and implements atomic bit manipulation that enables faster peripheral controls,system spinlocks and thread-safe Boolean data handling.1.3.2 Integrated configurable debugThe Cortex-M3 processor implements a complete hardware debug solution.This provides high system visibility of the processor and

43、 memory through either a traditional JTAG port or a 2-pin Serial Wire Debug(SWD)port that is ideal for small package devices.ProcessorcoreEmbedded Trace MacrocellNVICDebug access portSerial wire viewerBus matrixCode interfaceSRAM and peripheral interfaceData watchpointsFlashpatchSTM32 Cortex-M3proce

44、ssorai15994 About this documentPM005612/154 Doc ID 15491 Rev 3For system trace the processor integrates an Instrumentation Trace Macrocell(ITM)alongside data watchpoints and a profiling unit.To enable simple and cost-effective profiling of the system events these generate,a Serial Wire Viewer(SWV)ca

45、n export a stream of software-generated messages,data trace,and profiling information through a single pin.The optional Embedded Trace Macrocell(ETM)delivers unrivalled instruction trace capture in an area far smaller than traditional trace units,enabling many low cost MCUs to implement full instruc

46、tion trace for the first time.1.3.3 Cortex-M3 processor features and benefits summaryTight integration of system peripherals reduces area and development costsThumb instruction set combines high code density with 32-bit performanceCode-patch ability for ROM system updatesPower control optimization o

47、f system componentsIntegrated sleep modes for low power consumptionFast code execution permits slower processor clock or increases sleep mode timeHardware division and fast multiplierDeterministic,high-performance interrupt handling for time-critical applicationsExtensive debug and trace capabilitie

48、s:Serial Wire Debug and Serial Wire Trace reduce the number of pins required for debugging and tracing.PM0056About this documentDoc ID 15491 Rev 313/154 1.3.4 Cortex-M3 core peripheralsThese are:Nested vectored interrupt controller The nested vectored interrupt controller(NVIC)is an embedded interru

49、pt controller that supports low latency interrupt processing.System control block The system control block(SCB)is the programmers model interface to the processor.It provides system implementation information and system control,including configuration,control,and reporting of system exceptions.Syste

50、m timer The system timer,SysTick,is a 24-bit count-down timer.Use this as a Real Time Operating System(RTOS)tick timer or as a simple counter.The Cortex-M3 processorPM005614/154 Doc ID 15491 Rev 32 The Cortex-M3 processor2.1 Programmers modelThis section describes the Cortex-M3 programmers model.In

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 实用范文 > 工作总结

copyright@ 2008-2023 wnwk.com网站版权所有

经营许可证编号:浙ICP备2024059924号-2