⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 com_baud.s79

📁 ARM入门的好帮手.包含了从简单到相对较复杂的程序.
💻 S79
字号:
        NAME com_baud

        RTMODEL "__code_model", "small"
        RTMODEL "__cpu_mode", "arm"
        RTMODEL "__data_model", "absolute"
        RTMODEL "__endian", "little"
        RTMODEL "__rt_version", "2"
        RTMODEL "__thumb_aware", "enabled"

        RSEG CSTACK:DATA:NOROOT(2)

        EXTERN ??divu32_a

        PUBLIC at91_baud_com
        FUNCTION at91_baud_com,0203H
        LOCFRAME CSTACK, 8, STACK
        PUBLIC at91_error_baud_com
        FUNCTION at91_error_baud_com,0203H
        LOCFRAME CSTACK, 16, STACK
; C:\At91\software\projects\bench\Source\com_baud.c
;     1 //*----------------------------------------------------------------------------
;     2 //*      ATMEL Microcontroller Software Support  -  ROUSSET  -
;     3 //*----------------------------------------------------------------------------
;     4 //* The software is delivered "AS IS" without warranty or condition of any
;     5 //* kind, either express, implied or statutory. This includes without
;     6 //* limitation any warranty or condition with respect to merchantability or
;     7 //* fitness for any particular purpose, or against the infringements of
;     8 //* intellectual property rights of others.
;     9 //*----------------------------------------------------------------------------
;    10 //* File Name           : com_baud.c
;    11 //* Object              : Baud rate compute com port terminal
;    12 //*
;    13 //* 1.0 25/08/00 JPP    : Creation
;    14 //* 1.0 03/09/01 JPP    : Change com directory
;    15 //*----------------------------------------------------------------------------
;    16 
;    17 #include "com.h"
;    18 
;    19 //*----------------------------------------------------------------------------
;    20 //* Function Name       : at91_baud_com
;    21 //* Object              : Compute the baud rate
;    22 //* Input Parameters    : <mcki> external mcki if use in usart US_CLKS_MCK8 you
;    23 //*                              must be divided mcki by 8
;    24 //*                       <baud> use standart baud rate 4800,9600,19200,...
;    25 //* Output Parameters   : Usart CD baud value
;    26 //*----------------------------------------------------------------------------

        RSEG NEARFUNC_A:CODE:REORDER:NOROOT(2)
        
        CFI Names cfiNames0
        CFI StackFrame CFA SP HUGEDATA
        CFI Resource R0:32, R1:32, R2:32, R3:32, R4:32, R5:32, R6:32, R7:32
        CFI Resource R8:32, R9:32, R10:32, R11:32, R12:32, SP:32, LR:32
        CFI VirtualResource RET:32
        CFI EndNames cfiNames0
        
        CFI Common cfiCommon0 Using cfiNames0
        CFI CodeAlign 4
        CFI DataAlign 4
        CFI ReturnAddress RET CODE
        CFI CFA SP+0
        CFI R0 Undefined
        CFI R1 Undefined
        CFI R2 Undefined
        CFI R3 Undefined
        CFI R4 SameValue
        CFI R5 SameValue
        CFI R6 SameValue
        CFI R7 SameValue
        CFI R8 SameValue
        CFI R9 SameValue
        CFI R10 SameValue
        CFI R11 SameValue
        CFI R12 Undefined
        CFI LR Undefined
        CFI RET LR
        CFI EndCommon cfiCommon0
        
        CFI Block cfiBlock0 Using cfiCommon0
        CFI Function at91_baud_com
   CODE32   
;    27 u_short at91_baud_com( u_int mcki, u_int baud)
;    28 //* Begin
;    29 {
at91_baud_com:
   STMDB    SP!,{R4,LR}        ;; Push
        CFI RET Frame(CFA, -4)
        CFI R4 Frame(CFA, -8)
        CFI CFA SP+8
;    30     u_short cd;
;    31     u_int   user_baud;
;    32 
;    33     //* baud rate calculation
;    34     user_baud = ((mcki*10)/(baud*16));
   MOV      R3,#+0xA
   MUL      R2,R0,R3
   MOV      R0,R2
   MOV      R1,R1, LSL #+4
   BL       ??divu32_a
   MOV      R2,R1
;    35     //*
;    36     cd  = user_baud/10;
   MOV      R0,R2
   MOV      R1,R3
   BL       ??divu32_a
   MOV      R0,R1, LSL #+16
   MOV      R0,R0, LSR #+16
;    37     //* compute the error
;    38     user_baud = (user_baud - (cd *10));
;    39     //* aproximation
;    40     if (user_baud >= 5) cd++;
   MUL      R4,R0,R3
   SUB      R1,R2,R4
   CMP      R1,#+0x5
   ADDCS    R0,R0,#+0x1
;    41     // return the CD value for the Usart
;    42     return cd;
   MOV      R0,R0, LSL #+16
   MOV      R0,R0, LSR #+16
   LDMIA    SP!,{R4,PC}        ;; return
        CFI EndBlock cfiBlock0
;    43 }
;    44 //* End
;    45 //*----------------------------------------------------------------------------
;    46 //* Function Name       : at91_error_baud_com
;    47 //* Object              : Compute the baud rate
;    48 //* Input Parameters    : <mcki> external mcki if use in usart US_CLKS_MCK8 you
;    49 //*                              must be divided mcki by 8
;    50 //*                       <baud> use standart baud rate 4800,9600,19200,...
;    51 //* Output Parameters   : baud error rate in % (sup average)
;    52 //*----------------------------------------------------------------------------

        RSEG NEARFUNC_A:CODE:REORDER:NOROOT(2)
        CFI Block cfiBlock1 Using cfiCommon0
        CFI Function at91_error_baud_com
   CODE32   
;    53 u_short at91_error_baud_com( u_int mcki, u_int baud)
;    54 //* Begin
;    55 {
at91_error_baud_com:
   STMDB    SP!,{R4-R6,LR}     ;; Push
        CFI RET Frame(CFA, -4)
        CFI R6 Frame(CFA, -8)
        CFI R5 Frame(CFA, -12)
        CFI R4 Frame(CFA, -16)
        CFI CFA SP+16
   MOV      R3,R0
   MOV      R2,R1
;    56     u_short cd;
;    57     u_int usart_baud;
;    58     //* Calculate the User cd
;    59     cd = at91_baud_com(mcki, baud);
   MOV      R1,#+0xA
   MUL      R0,R1,R0
   MOV      R1,R2, LSL #+4
   BL       ??divu32_a
   MOV      R4,R1
   MOV      R0,R4
   MOV      R1,#+0xA
   BL       ??divu32_a
   MOV      R1,R1, LSL #+16
   MOV      R1,R1, LSR #+16
   MOV      R5,#+0xA
   MUL      R6,R1,R5
   SUB      R0,R4,R6
   CMP      R0,#+0x5
   ADDCS    R1,R1,#+0x1
;    60 
;    61     //* compute the real baud rate
;    62     usart_baud = (mcki/(cd*16));
   MOV      R0,R3
   MOV      R1,R1, LSL #+16
   MOV      R1,R1, LSR #+16
   MOV      R1,R1, LSL #+4
   BL       ??divu32_a
;    63 
;    64     //* compute error
;    65     if (usart_baud < (baud))
   CMP      R1,R2
   MOV      R3,#+0x64
;    66      cd =  100 - ((usart_baud*100)/baud);
   MULCC    R0,R1,R3
   MOVCC    R1,R2
;    67     else
;    68      cd =  100- ((baud*100)/usart_baud) ;
   MULCS    R0,R2,R3
   BL       ??divu32_a
   MOV      R1,R1, LSL #+16
   MOV      R1,R1, LSR #+16
   RSB      R0,R1,#+0x64
;    69 
;    70     // return the error value for the Usart
;    71     return  cd;
   MOV      R0,R0, LSL #+16
   MOV      R0,R0, LSR #+16
   LDMIA    SP!,{R4-R6,PC}     ;; return
        CFI EndBlock cfiBlock1
;    72 }

        END
;    73 //* End
; 
; 216 bytes in segment NEARFUNC_A
; 
; 216 bytes of CODE memory
;
;Errors: none
;Warnings: none

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -