《计算机接口技术》大作业 下载本文

内容发布更新时间 : 2024/5/10 11:07:29星期一 下面是文章的全部内容请认真阅读。

{ switch (status)

{ case OK : calc_display(calc_decascii(lvalue)); break; case SLEEP : break; case ERROR : calc_display(\ break; default : calc_display(\ break; } }

LONG calc_asciidec (CHAR *buffer)

// Convert the ASCII string into the floating point number. { LONG value; LONG digit; value = 0;

while (*buffer != ' ') { digit = *buffer - 48; value = value*10 + digit; buffer++; }

return value; }

CHAR *calc_decascii (LONG num)

// A rather messy function to convert a floating // point number into an ASCII string. { LONG temp = num;

CHAR *arrayptr = &outputbuffer[MAX_DISPLAY_CHAR]; LONG divisor = 10; LONG result;

CHAR remainder,asciival; INT i;

// If the result of the calculation is zero // insert a zero in the buffer and finish. if (!temp)

{ *arrayptr = 48; goto done; }

// Handle Negative Numbers. if (temp < 0)

{ outputbuffer[0] = '-'; temp -= 2*temp; }

for (i=0 ; i < sizeof(outputbuffer) ; i++) { remainder = temp % divisor; result = temp / divisor;

// If we run off the end of the number insert a space into // the buffer.

if ((!remainder) && (!result)) { *arrayptr = ' ';}

// We're in business - store the digit offsetting // by 48 decimal to account for the ascii value. else

{ asciival = remainder + 48;

第15页

*arrayptr = asciival; }

temp /= 10;

// Save a place for a negative sign.

if (arrayptr != &outputbuffer[1]) arrayptr--; }

done: return outputbuffer; }

CHAR calc_testkey (CHAR key)

// Test whether the key is a digit or an operator. Return 1 for digit, 0 for op. { if ((key >= 0x30) && (key <= 0x39)) { return 1;} else

{ return 0;} }

/************************************************************************ ***** I/O Routines ***** ***********************/

CHAR calc_getkey (VOID)

// Use the input routine from the *Keypad_Read* assembly file to // Scan for a key and return ASCII value of the Key pressed. { CHAR mykey;

do mykey = input(); while (mykey == 0); return mykey; }

VOID calc_display (CHAR buf[MAX_DISPLAY_CHAR])

// Use the Output and Clearscreen routines from the

// *LCD_Write* assembly file to output ASCII values to the LCD. { INT i = 0; clearscreen();

for (i = 0 ; i <= MAX_DISPLAY_CHAR ; i++) { if (buf[i] != ' ') { output(buf[i]); } } }

第16页

5. 调试运行 proteus仿真结果

第17页

6. 设计心得体会

微型计算机接口技术是一门很有趣的课程,任何一个计算机系统都是一个复杂的整体,学习计算机原理是要涉及到整体的每一部分。讨论某一部分原理时又要涉及到其它部分的工作原理。这样一来,不仅不能在短时间内较深入理解计算机的工作原理,而且也很难孤立地理解某一部分的工作原理。所以,在循序渐进的课堂教学过程中,我总是处于“学会了一些新知识,弄清了一些原来保留的问题,又出现了一些新问题”的循环中,直到课程结束时,才把保留的问题基本搞清楚。

学习该门课程知识时,其思维方法也和其它课程不同,该课程偏重于工程思维,具体地说,在了解了微处理器各种芯片的功能和外部特性以后,剩下额是如何将它们用于实际系统中,其创造性劳动在于如何用计算机的有关技术和厂家提供的各种芯片,设计实用的电路和系统,再配上相应的应用程序,完成各种实际应用项目。

这次实验并不是很难,主要的困难来自对程序的理解。功夫不负有心人,经过多个人的合作和努力,我们最后对实验的原理有了清晰的认识。虽然很多模块单元没有用到,但是就系统功能来说,我觉得我们做的还是不错的。

这次课设却让我们对实验芯片有了足够的了解,让我们知道了实验芯片的用法;而且它还让我们对自己动手写程序来控制芯片的运作有了一定的基础。虽然只是一个小型的课程设计,但是通过学习和操作,我们对有关接口的知识将会有一个更广泛的认识,而且它对我们以后的学习也会有帮助的。

实验中个人的力量是不及群体的力量的,我们几个人分工合作,做事的效率高了很多。虽然有时候会为了一些细节争论不休,但最后得出的总是最好的结论。而且实验也教会我们在团队中要善于与人相处,与人共事,不要一个人解决所有问题。

参考书目:

[1] 刘乐善. 微型计算机接口技术及应用.武汉:华中科技大学出版社,2011.2 [2] 刘红玲 赵梅.微机原理与接口技术.北京:电子工业出版社,2008.1

第18页