📄 sim.ini
字号:
/******************************************************************************/
/* SIM.INI: Simulator Initialization File */
/******************************************************************************/
/* This file is part of the uVision/ARM development tools. */
/* Copyright (c) 2005-2007 Keil Software. All rights reserved. */
/* This software may only be used under the terms of a valid, current, */
/* end user licence from KEIL for a compatible version of KEIL software */
/* development tools. Nothing else gives you the right to use this software. */
/******************************************************************************/
/*-------------------------------------------------------------------*/
/* Analog0() simulates analog input values given to channel-0 (AD00) */
/*-------------------------------------------------------------------*/
Signal void analog0 (float limit) {
float volts;
printf ("Analog0 (%f) entered.\n", limit);
while (1) { /* forever */
volts = 0;
while (volts <= limit) {
ad00 = volts; /* analog input-0 */
twatch (500000); /* 500000 Cycles Time-Break */
volts += 0.1; /* increase voltage */
}
volts = limit;
while (volts >= 0.0) {
ad00 = volts;
twatch (500000); /* 500000 Cycles Time-Break */
volts -= 0.1; /* decrease voltage */
}
}
}
/*
* Simulate LCD Display (2 line 40 character Text LCD with 4-bit Interface)
* Pins:
* - DB4..DB7 = P1.24..P1.27
* - RS = P1.28
* - RW = P1.29
* - E = P1.31
*/
define unsigned long oldPORT1;
define unsigned char Cursor;
define unsigned char bitpos;
define unsigned char Cmd;
define unsigned long _E;
define unsigned long _RW;
define unsigned long _RS;
define unsigned long _CTRL;
define unsigned long _DATA;
MAP 0x10000000, 0x1000004F READ WRITE // LCD Memory
oldPORT1 = PORT1;
Cursor = 0;
bitpos = 0;
_E = 0x80000000;
_RW = 0x20000000;
_RS = 0x10000000;
_CTRL = 0xB0000000;
_DATA = 0x0F000000;
// Clear Display Function
Func void LCD_Clear (void) {
unsigned char i;
for (i = 0; i < 80; i++) {
_WBYTE(0x10000000 + i, 0x20);
}
Cursor = 0;
}
// LCD Display Signal Function
Signal void LCD_Display (void) {
unsigned char val;
while (1) {
wwatch(PORT1); // Wait for write to PORT1
if ((PORT1 & _RW) == 0) {
// Write to Display
if (((oldPORT1 & _E) != 0) && ((PORT1 & _E) == 0)) {
// E: 1->0
if ((PORT1 & _RS) == 0) {
// Write Command
val = ((PORT1 & _DATA) >> 24);
if (val == 3) {
bitpos = 4;
}
Cmd &= 0xF0 >> bitpos;
Cmd |= val << bitpos;
if (bitpos == 0) {
if (Cmd == 0x01) {
// Clear Display
LCD_Clear();
} else if (Cmd & 0x80) {
// Set Cursor Position
Cursor = Cmd & 0x7F;
}
}
} else {
// Write Data
val = _RBYTE(0x10000000 + Cursor);
val &= 0xF0 >> bitpos;
val |= ((PORT1 & _DATA) >> 24) << bitpos;
_WBYTE(0x10000000 + Cursor, val);
if (bitpos == 0) Cursor++;
}
bitpos ^= 4;
}
} else {
// Read from Display
if (((oldPORT1 & _E) == 0) && ((PORT1 & _E) != 0)) {
// E: 0->1
if ((PORT1 & _RS) == 0) {
// Read Status
val = (0x7F >> bitpos) & 0x0F;
} else {
// Read Pointer
val = ((Cursor & 0x7F) >> bitpos) & 0x0F;
}
PORT1 &= ~_DATA;
PORT1 |= val << 24;
bitpos ^= 4;
}
}
oldPORT1 = PORT1;
}
}
LCD_Display()
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -