File name: main.c
** Last modified Date: 2004-09-16 ** Last Version: 1.0
** Descriptions: The main() function example template **
**------------------------------------------------------------------------------------------------------
** Created by: lls
** Created date: 2006-09-16 ** Version: 1.0
** Descriptions: The original version **
**------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date: 2006-09-21 ** Version:
** Descriptions: **
******************************************************************************************************* ** 功能 :
** 上位机使用EasyARM软件全仿真的DOS窗口观察。 ** 说明 :
** 通讯波特率115200,8位数据位,1位停止位,无奇偶校验。 *******************************************************************************************************
#include \#include \#include %uint32 DA_OUT,DCT;
uint32 value[6][7];
/*数组:六个参数的标准值(比较错误时用)*/
uint32 biaozhunzhi[6]={0.8*413, //VIL 2.0*413, //VIH 2.7*413, //VOH 0.5*413, //VOL 4*1024/2480, //IIL 8*1024/2480}; //IOL /*数组:继电器使用情况*/
uint32 a[6][3]={(1<<8) |(1<<17),(1<<8),(1<<17), //J1 J7 (1<<9) |(1<<18),(1<<9),(1<<18), //J2 J8 (1<<10)|(1<<19),(1<<10),(1<<19), //J3 J9 (1<<12)|(1<<20),(1<<12),(1<<20), //J4 J10 (1<<13)|(1<<23),(1<<13),(1<<23), //J5 J11 (1<<16)|(1<<27),(1<<16),(1<<27)}; //J6 J12
uint8 ay[7]={1,2,3,4,5,6,7}; //数组:六个参数的名称
uint8 fm1,fm2,fm3,fm4,fm5,fm6; //非门编号 uint8 zj_flag; //三角波过顶标志 uint8 rcv_buf[18];
uint8 rcv_dat0;
/*实际电路中各参数要修正的偏差系数*/
const float ad01x = 1.905; //AD0.1测VOH const float ad03x = 1.905; //AD0.3测VIH const float ad05x = 0.500; //AD0.5const float ad15x = 0.500; //AD1.5const float ad16x = 0.500; //AD1.6const float ad17x = 1.900; //AD1.7 /*模拟开关CD4051 GPIO口*/
#define A0 1<<16 //P1.16 IO1DIR
#define A1 1<<17 //P1.17 IO1DIR #define A2 1<<24 //P1.24 IO1DIR /*继电器 GPIO口*/ #define J1 1<<8 //P0.8 IO0DIR (左)
#define J2 1<<9 //P0.9 IO0DIR #define J3 1<<10 //P0.10 IO0DIR #define J4 1<<12 //P0.12 IO0DIR #define J5 1<<13 //P0.13 IO0DIR #define J6 1<<16 //P0.16 IO0DIR 测IIL 测VIL 测VOL
测IOL(看为高电平) 非门1 非门2 非门3 非门4 非门5 非门6
#define J7 1<<17 //P0.17 IO0DIR 非门1 (右)
#define J8 1<<18 //P0.18 IO0DIR 非门2 #define J9 1<<19 //P0.19 IO0DIR 非门3 #define J10 1<<20 //P0.20 IO0DIR 非门4 #define J11 1<<23 //P0.23 IO0DIR 5
#define J12 1<<27 //P0.27 IO0DIR
非门非门6
/*LED灯 GPIO口*/
const uint32 LED1 = (1 << 18); //P1.18 IO1DIR 控制LED1低电平点亮
const uint32 LED2 = (1 << 19); //P1.19 IO1DIR 控制LED2低电平点亮
const uint32 LED3 = (1 << 20); //P1.20 IO1DIR 低电平点亮
const uint32 LED4 = (1 << 21); //P1.21 IO1DIR 低电平点亮
const uint32 LED5 = (1 << 22); //P1.22 IO1DIR 低电平点亮
const uint32 LED6 = (1 << 23); //P1.23 IO1DIR 低电平点亮
/*key1 UART0 SPI BEEP DAC GPIO口*/
#define UART0 0x05 //P0.0 P0.1发送到PC机显示
#define SPI 0x00005500 //P0.4 P0.5 P0.6 P0.7接SPI,数码管显示用
#define DAC 2<<18 //P0.25#define key1 1<<25 //P1.25
控制LED3控制LED4控制LED5控制LED6控制UART0,连连接到DAC 连接到按键key1