📄 util.lst
字号:
C51 COMPILER V7.08 UTIL 12/11/2005 15:43:15 PAGE 1
C51 COMPILER V7.08, COMPILATION OF MODULE UTIL
OBJECT MODULE PLACED IN util.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE util.c BROWSE DEBUG OBJECTEXTEND
line level source
1 /*= util.c =========================================================================================
2 *
3 * Copyright (C) 2004 Nordic Semiconductor
4 *
5 * This file is distributed in the hope that it will be useful, but WITHOUT WARRANTY OF ANY KIND.
6 *
7 * Author(s):
8 *
9 * COMPILER:
10 *
11 * This program has been tested with Keil C51 V7.08 and 7.09
12 *
13 * $Revision: 2 $
14 * www.rfmcu.com
15 *==================================================================================================
16 */
17 #include "reg9e5.h"
18 #include "uart.h"
19 #include "util.h"
20 sbit PWM =P0^7;
21 const char hex_tab[] = "0123456789ABCDEF"; // ASCII-hex table used by hex-output routines
22
23 static volatile unsigned int idata timer[2]; // Two utility timers used in radio.c
24 static volatile unsigned char t0lrel, t0hrel;
25 unsigned int tt;
26 void Delay100us(unsigned char n)
27 {
28 1 unsigned char i;
29 1 while(n--)
30 1 for(i=0;i<35;i++)
31 1 ;
32 1 }
33
34 unsigned char SpiReadWrite(unsigned char b)
35 {
36 1 EXIF &= ~0x20; // Clear SPI interrupt
37 1 SPI_DATA = b; // Move byte to send to SPI data register
38 1 while((EXIF & 0x20) == 0x00) // Wait until SPI hs finished transmitting
39 1 ;
40 1 return SPI_DATA;
41 1 }
42
43
44
45 void InitTimer(void)
46 {
47 1 timer[0] = timer[1] = 0;
48 1
49 1 TR0 = 0;
50 1 TMOD &= ~0x03;
51 1 TMOD |= 0x01; // mode 1
52 1 CKCON |= 0x00; // T0M = 1 (/4 timer clock)
53 1 //t0lrel = 0x60; // 1KHz tick...
54 1 //t0hrel = 0xF0; // ... = 65536-16e6/(4*1e3) = F060h
55 1
C51 COMPILER V7.08 UTIL 12/11/2005 15:43:15 PAGE 2
56 1 t0lrel = 0xf0;
57 1 t0hrel = 0xF0;
58 1 TF0 = 0; // Clear any pending Timer0 interrupts
59 1 TR0 = 1; // Start Timer0
60 1 ET0 = 1; // Enable Timer0 interrupt
61 1 }
62
63 void Timer0ISR (void) interrupt 1
64 {
65 1 TF0 = 0; // Clear Timer0 interrupt
66 1 TH0 = t0hrel; // Reload Timer0 high byte
67 1 TL0 = t0lrel; // Reload Timer0 low byte
68 1 timer[0]++; // Increment timer[0]
69 1 timer[1]++;
70 1 tt++;
71 1 if(tt==1) // Increment timer[1
72 1 PWM=1;
73 1 // ;
74 1 if(tt==2)
75 1 PWM=0;
76 1 if(tt>2)
77 1 tt=0;
78 1 }
79
80 void ResetTimer(unsigned char n)
81 {
82 1 ET0 = 0; // Disable Timer0 interrupt
83 1 timer[n & 0x01] = 0; // Clear timer[n]
84 1 ET0 = 1; // Enable Timer0 interrupt
85 1 }
86
87 unsigned GetTimer(unsigned char n)
88 {
89 1 unsigned tmp;
90 1 ET0 = 0; // Disable Timer0 interrupt
91 1 tmp = timer[n]; // Clear timer[n]
92 1 ET0 = 1; // Enable Timer0 interrupt
93 1 return tmp;
94 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 179 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 21 ----
IDATA SIZE = 4 ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -