1#include <NXP/iolpc2148.h>
2#include <stdio.h>
3#include "uart.h"
//系统时钟
4#define Fosc 12000000UL //晶振时钟 【Hz】
5#define Fcclk (Fosc * 5) //系统频率,必须为Fosc的整数倍(1~32),且<=60MHZ
6#define Fcco (Fcclk * 4) //CCO频率,必须为Fcclk的2、4、8、16倍,范围为156MHz~320MHz
7#define Fpclk (Fcclk / 4) * 4 // VPB时钟频率,只能为(Fcclk / 4)的1 ~ 4倍
//接口声明
8#define DS_OUT() IO0DIR_bit.P0_19 = 1 //设置为输出
9#define DS_IN() IO0DIR_bit.P0_19 = 0 //设置为输入
10#define DS_L() IO0CLR_bit.P0_19 = 1 //端口底电平
11#define DS_H() IO0SET_bit.P0_19 = 1 //端口高电平
12#define DS_R() IO0PIN_bit.P0_19 //读入端口数据
//函数声明
13void PLL_Init(void);
14void Tmp_Change(void);
15void Delayn(unsigned long n);
16void DelaynUs(unsigned int n);
17float tmp(void);
18void DS_Reset(void);
//主函数
19void main(void)
20{
21 char buf[100];
22 float a;
23 PLL_Init(); //初始化系统时钟
24 InitUart0(); //初始化串口
25 PINSEL1_bit.P0_19 = 0; //初始化端口
26 DS_IN();
//定时器1初始化,产生定时基准
27 T1IR = 0xFF; // reset match and capture event interrupts
28 T1TC = 0; // Clear timer counter
29 T1PR = 0;
2#include <stdio.h>
3#include "uart.h"
//系统时钟
4#define Fosc 12000000UL //晶振时钟 【Hz】
5#define Fcclk (Fosc * 5) //系统频率,必须为Fosc的整数倍(1~32),且<=60MHZ
6#define Fcco (Fcclk * 4) //CCO频率,必须为Fcclk的2、4、8、16倍,范围为156MHz~320MHz
7#define Fpclk (Fcclk / 4) * 4 // VPB时钟频率,只能为(Fcclk / 4)的1 ~ 4倍
//接口声明
8#define DS_OUT() IO0DIR_bit.P0_19 = 1 //设置为输出
9#define DS_IN() IO0DIR_bit.P0_19 = 0 //设置为输入
10#define DS_L() IO0CLR_bit.P0_19 = 1 //端口底电平
11#define DS_H() IO0SET_bit.P0_19 = 1 //端口高电平
12#define DS_R() IO0PIN_bit.P0_19 //读入端口数据
//函数声明
13void PLL_Init(void);
14void Tmp_Change(void);
15void Delayn(unsigned long n);
16void DelaynUs(unsigned int n);
17float tmp(void);
18void DS_Reset(void);
//主函数
19void main(void)
20{
21 char buf[100];
22 float a;
23 PLL_Init(); //初始化系统时钟
24 InitUart0(); //初始化串口
25 PINSEL1_bit.P0_19 = 0; //初始化端口
26 DS_IN();
//定时器1初始化,产生定时基准
27 T1IR = 0xFF; // reset match and capture event interrupts
28 T1TC = 0; // Clear timer counter
29 T1PR = 0;