📄 setusart.txt
字号:
; generated by ARM/Thumb C/C++ Compiler with , RVCT3.1 [Build 934] for uVision
; commandline ArmCC [--split_sections --debug -c --asm --interleave -o.\Obj\setusart.o --depend=.\Obj\setusart.d --device=DARMSTM --apcs=interwork -O3 -I..\..\include -I..\..\..\FWLib\library\inc -I..\..\..\USBLib\library\inc -I..\..\SRAM -I"D:\Program Files\MDK KEIL\ARM\INC\ST\STM32F10x" -D__MICROLIB --omf_browse=.\Obj\setusart.crf ..\..\source\SetUsart.c]
THUMB
AREA ||i.SetupUSART||, CODE, READONLY, ALIGN=2
SetupUSART PROC
;;;15
;;;16 void SetupUSART (void) {
000000 b510 PUSH {r4,lr}
000002 b086 SUB sp,sp,#0x18
;;;17
;;;18 USART_InitTypeDef USART_InitStructure;
;;;19
;;;20 GPIO_InitTypeDef GPIO_InitStructure;
;;;21
;;;22 /* Enable USART1 and GPIOA clock */
;;;23 RCC_APB2PeriphClockCmd (RCC_APB2Periph_USART1 | RCC_APB2Periph_GPIOA, ENABLE);
000004 2101 MOVS r1,#1
000006 f244f244 MOV r0,#0x4004
00000a f7fff7ff BL RCC_APB2PeriphClockCmd
;;;24
;;;25
;;;26 /* Configure USART1 Rx (PA10) as input floating */
;;;27 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
00000e f44ff44f MOV r0,#0x400
000012 f8adf8ad STRH r0,[sp,#4]
;;;28 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
000016 2004 MOVS r0,#4
;;;29 GPIO_Init(GPIOA, &GPIO_InitStructure);
000018 4c18 LDR r4,|L1.124|
00001a f88df88d STRB r0,[sp,#7] ;28
00001e a901 ADD r1,sp,#4
000020 4620 MOV r0,r4
000022 f7fff7ff BL GPIO_Init
;;;30
;;;31 /* Configure USART1 Tx (PA9) as alternate function push-pull */
;;;32 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
000026 1560 ASRS r0,r4,#21
000028 f8adf8ad STRH r0,[sp,#4]
;;;33 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
00002c 2003 MOVS r0,#3
00002e f88df88d STRB r0,[sp,#6]
;;;34 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
000032 2018 MOVS r0,#0x18
000034 f88df88d STRB r0,[sp,#7]
;;;35 GPIO_Init(GPIOA, &GPIO_InitStructure);
000038 a901 ADD r1,sp,#4
00003a 4620 MOV r0,r4
00003c f7fff7ff BL GPIO_Init
;;;36
;;;37
;;;38 /* USART1 configuration ------------------------------------------------------*/
;;;39 /* USART1 configured as follow:
;;;40 - BaudRate = 115200 baud
;;;41 - Word Length = 8 Bits
;;;42 - One Stop Bit
;;;43 - No parity
;;;44 - Hardware flow control disabled (RTS and CTS signals)
;;;45 - Receive and transmit enabled
;;;46 - USART Clock disabled
;;;47 - USART CPOL: Clock is active low
;;;48 - USART CPHA: Data is captured on the middle
;;;49 - USART LastBit: The clock pulse of the last data bit is not output to
;;;50 the SCLK pin
;;;51 */
;;;52 /* USART_InitStructure.USART_BaudRate = 9600;
;;;53 USART_InitStructure.USART_WordLength = USART_WordLength_8b;
;;;54 USART_InitStructure.USART_StopBits = USART_StopBits_1;
;;;55 USART_InitStructure.USART_Parity = USART_Parity_No;
;;;56 USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
;;;57 USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
;;;58 USART_InitStructure.USART_Clock = USART_Clock_Disable;
;;;59 USART_InitStructure.USART_CPOL = USART_CPOL_Low;
;;;60 USART_InitStructure.USART_CPHA = USART_CPHA_2Edge;
;;;61 USART_InitStructure.USART_LastBit = USART_LastBit_Disable;
;;;62
;;;63 USART_Init(USART1, &USART_InitStructure);
;;;64
;;;65
;;;66 USART_Cmd(USART1, ENABLE); */
;;;67
;;;68 /* USART1 configuration ------------------------------------------------------*/
;;;69 /* USART1 configured as follow:
;;;70 - BaudRate = 9600 baud
;;;71 - Word Length = 8 Bits
;;;72 - Two Stop Bit
;;;73 - Odd parity
;;;74 - Hardware flow control disabled (RTS and CTS signals)
;;;75 - Receive and transmit enabled
;;;76 - USART Clock disabled
;;;77 - USART CPOL: Clock is active low
;;;78 - USART CPHA: Data is captured on the second edge
;;;79 - USART LastBit: The clock pulse of the last data bit is not output to
;;;80 the SCLK pin
;;;81 */
;;;82 USART_InitStructure.USART_BaudRate = 19200;
000040 f44ff44f MOV r0,#0x4b00
;;;83 USART_InitStructure.USART_WordLength = USART_WordLength_8b;
000044 9002 STR r0,[sp,#8]
000046 2000 MOVS r0,#0
000048 f8adf8ad STRH r0,[sp,#0xc]
;;;84 USART_InitStructure.USART_StopBits = USART_StopBits_1;
00004c f8adf8ad STRH r0,[sp,#0xe]
;;;85 USART_InitStructure.USART_Parity = USART_Parity_No ;//USART_Parity_Odd
000050 f8adf8ad STRH r0,[sp,#0x10]
;;;86 USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
000054 f8adf8ad STRH r0,[sp,#0x14]
;;;87 USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
000058 200c MOVS r0,#0xc
;;;88
;;;89
;;;90
;;;91 USART_Init(USART1, &USART_InitStructure);
00005a 4c09 LDR r4,|L1.128|
00005c f8adf8ad STRH r0,[sp,#0x12] ;87
000060 a902 ADD r1,sp,#8
000062 4620 MOV r0,r4
000064 f7fff7ff BL USART_Init
;;;92 // if you want to set the parity bit ,you must select 9bit data
;;;93
;;;94 /* Configure the USART1 */
;;;95 USART_Init(USART1, &USART_InitStructure);
000068 a902 ADD r1,sp,#8
00006a 4620 MOV r0,r4
00006c f7fff7ff BL USART_Init
;;;96
;;;97 /* Enable the USART Transmoit interrupt: this interrupt is generated when the
;;;98 USART1 transmit data register is empty */
;;;99 //USART_ITConfig(USART1, USART_IT_TXE, ENABLE);
;;;100
;;;101 /* Enable the USART Receive interrupt: this interrupt is generated when the
;;;102 USART1 receive data register is not empty */
;;;103 // USART_ITConfig(USART1, USART_IT_RXNE, ENABLE);
;;;104
;;;105 /* Enable USART1 */
;;;106 USART_Cmd(USART1, ENABLE);
000070 2101 MOVS r1,#1
000072 4620 MOV r0,r4
000074 f7fff7ff BL USART_Cmd
;;;107
;;;108 }
000078 b006 ADD sp,sp,#0x18
00007a bd10 POP {r4,pc}
;;;109
ENDP
|L1.124|
00007c 40010800 DCD 0x40010800
|L1.128|
000080 40013800 DCD 0x40013800
AREA ||i.SendChar||, CODE, READONLY, ALIGN=2
SendChar PROC
;;;113 /* Implementation of putchar (also used by printf function to output data) */
;;;114 int SendChar (int ch) { /* Write character to Serial Port */
000000 b510 PUSH {r4,lr}
000002 4604 MOV r4,r0
;;;115
;;;116 USART_SendData(USART1, (unsigned char) ch);
000004 b2c1 UXTB r1,r0
000006 4805 LDR r0,|L2.28|
000008 f7fff7ff BL USART_SendData
00000c 4804 LDR r0,|L2.32|
;;;117 while (!(USART1->SR & USART_FLAG_TXE));
00000e bf00 NOP
|L2.16|
000010 f8b0f8b0 LDRH r1,[r0,#0x800]
000014 0609 LSLS r1,r1,#24
000016 d5fb BPL |L2.16|
;;;118 return (ch);
000018 4620 MOV r0,r4
;;;119 }
00001a bd10 POP {r4,pc}
;;;120
ENDP
|L2.28|
00001c 40013800 DCD 0x40013800
|L2.32|
000020 40013000 DCD 0x40013000
AREA ||i.GetKey||, CODE, READONLY, ALIGN=2
GetKey PROC
;;;121
;;;122 int GetKey (void) { /* Read character from Serial Port */
000000 4804 LDR r0,|L3.20|
;;;123
;;;124 while (!(USART1->SR & USART_FLAG_RXNE));
000002 bf00 NOP
|L3.4|
000004 f8b0f8b0 LDRH r1,[r0,#0x800]
000008 0689 LSLS r1,r1,#26
00000a d5fb BPL |L3.4|
;;;125 return (USART_ReceiveData(USART1));
00000c 4802 LDR r0,|L3.24|
00000e f7fff7ff B.W USART_ReceiveData
;;;126 }
;;;127
ENDP
000012 0000 DCW 0x0000
|L3.20|
000014 40013000 DCD 0x40013000
|L3.24|
000018 40013800 DCD 0x40013800
AREA ||i.fputc||, CODE, READONLY, ALIGN=2
fputc PROC
;;;137 int fputc(int ch, FILE *f)
;;;138 {
000000 b570 PUSH {r4-r6,lr}
;;;139 /* Place your implementation of fputc here */
;;;140 /* e.g. write a character to the USART */
;;;141 USART_SendData(USART1, (u8) ch);
000002 4d07 LDR r5,|L4.32|
000004 4604 MOV r4,r0 ;138
000006 b2c1 UXTB r1,r0
000008 4628 MOV r0,r5
00000a f7fff7ff BL USART_SendData
|L4.14|
;;;142
;;;143 /* Loop until the end of transmission */
;;;144 while(USART_GetFlagStatus(USART1, USART_FLAG_TC) == RESET)
00000e 2140 MOVS r1,#0x40
000010 4628 MOV r0,r5
000012 f7fff7ff BL USART_GetFlagStatus
000016 2800 CMP r0,#0
000018 d0f9 BEQ |L4.14|
;;;145 {
;;;146 }
;;;147
;;;148 return ch;
00001a 4620 MOV r0,r4
;;;149 }
00001c bd70 POP {r4-r6,pc}
;;;150
ENDP
00001e 0000 DCW 0x0000
|L4.32|
000020 40013800 DCD 0x40013800
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -