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

📄 timer_a.lst

📁 瑞萨单片机LCD控制
💻 LST
📖 第 1 页 / 共 5 页
字号:
    565          /**************************************************************************/
    566          /*                                                                        */
    567          /*       Timer A1 - Initialization for pwm mode                           */
    568          /*       The timer outputs pulses of a given width                        */
    569          /*       routine may be customized to the user's needs                    */
    570          /*                                                                        */
    571          /*       Name         :      timer_a1_init_pwm_mode                       */
    572          /*       Date/Author  :      08.04.1997/ST                                */
    573          /*       Parameter    :                                                   */
    574          /*       Return       :                                                   */
    575          /*                                                                        */
    576          /**************************************************************************/
    577          void near timer_a1_init_pwm_mode (void)
    578          {       
   \   0000E9   EC80                 PUSHM   R0
    579              TA1MR    = 0x07;        // XXXX X111 
   \   0000EB   C7079703             MOV.B   #7,919
    580                                      // |||| |||+- must always be 1 in pwm mode
    581                                      // |||| ||+-- must always be 1 in pwm mode
    582                                      // |||| |+--- must always be 1 in pwm mode
    583                                      // |||| +---- 0: ext. trigger falling edge of
    584                                      // ||||          TA1in input signal
    585                                      // ||||       1: ext. trigger rising edge of
    586                                      // ||||          TA1in input signal
    587                                      // ||||       TA1in must be configured as input
    588                                      // ||||       TA1in must be selected by 
    589                                      // ||||       event/trigger select bits
    590                                      // |||+------ 0: trigger is count start flag (TABSR)
    591                                      // |||        1: trigger is selected by event/trigger
    592                                      // |||           select bits
    593                                      // ||+------- 0: 16-bit pwm
    594                                      // ||         1:  8-bit pwm
    595                                      // |+-------- count source select bits
    596                                      // +--------- count source select bits
    597                                      //            00:  f1
    598                                      //            01:  f8
    599                                      //            10:  f32
    600                                      //            11:  fc32
    601          
    602          
    603              TRGSR   &= ~(0x03);     // ---- --XX
   \   0000EF   97FC8303             AND.B   #252,899
    604                                      //        |+- timer A1 event/trigger select bits
    605                                      //        +-- timer A1 event/trigger select bits
    606                                      //            00: input on TA1in (TA1in must be input)
    607                                      //            01: overflow of timer B2
    608                                      //            10: overflow of timer A0
    609                                      //            11: overflow of timer A2
    610          
    611              // Clock prescaler reset flag
    612              // This function is only effective if fc32 is selected
    613              if ((TA1MR & 0xC0)==0xC0)
   \   0000F3   74C0C0               MOV.B   #192,R0L
   \   0000F6   139703               AND.B   919,R0L
   \   0000F9   7680C0               CMP.B   #192,R0L
   \   0000FC   6E06                 JNE     ?0011
   \                     ?0010:
    614              {
    615                  CPSRF = 0x80;       // 1--- ----                                   
   \   0000FE   74CF8103             MOV.B   #128,897
   \            80      
   \                     ?0011:
    616                                      // +---------- 1: clock prescaler is reset 
    617              }
    618          }
   \   000103   ED01                 POPM    R0
   \   000105   F3                   RTS     
   \                     timer_a1_start:
    619          
    620          /**************************************************************************/
    621          /*                                                                        */
    622          /*       Timer A1 - start                                                 */
    623          /*       In following cases this routine takes no effect:                 */
    624          /*       - in one-shot timer mode if ext. trigger or timer overflow is    */
    625          /*         selected as start condition                                    */
    626          /*       - in pwm mode if external trigger or timer overflow is selected  */
    627          /*         as start condition                                             */
    628          /*                                                                        */
    629          /*       Name         :      timer_a1_start                               */
    630          /*       Date/Author  :      08.04.1997/ST                                */
    631          /*       Parameter    :                                                   */
    632          /*       Return       :                                                   */
    633          /*                                                                        */
    634          /**************************************************************************/
    635          void near timer_a1_start (void)
    636          {
    637                  TABSR |= 0x02;          // ---- --1-
   \   000106   9F028003             OR.B    #2,896
    638                                          //        +-- 1: start timer A1 (count flag)
    639          
    640                  ONSF  |= 0x02;          // ---- --1-
   \   00010A   9F028203             OR.B    #2,898
    641                                          //        +-- 1: start timer A1 (one-shot flag)
    642          }
   \   00010E   F3                   RTS     
   \                     timer_a1_stop:
    643          
    644          /**************************************************************************/
    645          /*                                                                        */
    646          /*       Timer A1 - stop                                                  */
    647          /*       In following cases this routine takes no effect:                 */
    648          /*       - in one-shot timer mode if ext. trigger or timer overflow is    */
    649          /*         selected as start condition                                    */
    650          /*       - in pwm mode if external trigger or timer overflow is selected  */
    651          /*         as start condition                                             */
    652          /*                                                                        */
    653          /*       Name         :      timer_a1_stop                                */
    654          /*       Date/Author  :      08.04.1997/ST                                */
    655          /*       Parameter    :                                                   */
    656          /*       Return       :                                                   */
    657          /*                                                                        */
    658          /**************************************************************************/
    659          void near timer_a1_stop (void)
    660          {
    661              TABSR &= ~(0x02);           // ---- --0-
   \   00010F   97FD8003             AND.B   #253,896
    662                                          //        +-- 0: stop  timer A1 (count flag)
    663          
    664              ONSF  &= ~(0x02);           // ---- --0-
   \   000113   97FD8203             AND.B   #253,898
    665                                          //        +-- 0: stop  timer A1 (one-shot flag)
    666          }
   \   000117   F3                   RTS     
   \                     timer_a1_get:
    667          
    668          /**************************************************************************/
    669          /*                                                                        */
    670          /*       Timer A1 - get current value                                     */
    671          /*                                                                        */
    672          /*       Name         :      timer_a1 get                                 */
    673          /*       Date/Author  :      08.04.1997/ST                                */
    674          /*       Parameter    :                                                   */
    675          /*       Return       :      - current count value in timer mode or event */
    676          /*                             counter mode                               */
    677          /*                           - indeterminate in one-shot mode or pwm mode */
    678          /*                                                                        */
    679          /**************************************************************************/
    680          unsigned int near timer_a1_get (void)
    681          {
    682              return(TA1);
   \   000118   73F08803             MOV.W   904,R0
    683          }
   \   00011C   F3                   RTS     
   \                     timer_a1_set:
    684          
    685          /**************************************************************************/
    686          /*                                                                        */
    687          /*       Timer A1 - set current value                                     */
    688          /*       when counting stopped    : write value to reload register and    */
    689          /*                                  counter                               */
    690          /*       when counting in progress: write value only to reload register   */
    691          /*                                  transferred to counter at next reload */
    692          /*                                  time                                  */
    693          /*       In 8-bit pwm mode highbyte gives time of high level and          */
    694          /*                         lowbyte gives time of low level                */
    695          /*                                                                        */
    696          /*       Name         :      timer_a1_set                                 */
    697          /*       Date/Author  :      08.04.1997/ST                                */
    698          /*       Parameter    :      load value                                   */
    699          /*       Return       :                                                   */
    700          /*                                                                        */
    701          /**************************************************************************/
    702          void near timer_a1_set (unsigned int value)
    703          {
   \   00011D   EC02                 PUSHM   SB
   \   00011F   7540                 PUSH.W  R0
   \   000121   EB52                 PUSHC   SP
   \   000123   EB63                 POPC    SB
    704              TA1 = value;
   \   000125   73AF0088             MOV.W   0[SB],904
   \            03      
    705          }
   \   00012A   7DB2                 ADD.B   #2,SP
   \   00012C   ED40                 POPM    SB
   \   00012E   F3                   RTS     
   \                     timer_a1_interrupt_set:
    706          
    707          /**************************************************************************/
    708          /*                                                                        */
    709          /*       Timer A1 - set interrupt                                         */

⌨️ 快捷键说明

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