您当前的位置:五五电子网电子知识电工技术电工文摘利用DS8007评估套件进行设计 正文
利用DS8007评估套件进行设计

利用DS8007评估套件进行设计

点击数:7146 次   录入时间:03-04 11:50:11   整理:http://www.55dianzi.com   电工文摘
DS8007电路板现在可以装入Keil开发工具建立的编程文件。
  1. 单击"File",然后选择"Load SRAM"。选择文件DS8007-1.HEX,然后单击"OPEN"。DS5002FP处理器的响应是: > Loading File ...\DS8007-1.hex

    > Loading File ...\DS8007-1.hex

    通过显示一连串的圆点表示正在装载。
  2. 完成后,处理器将报告"Load complete",单击"Target",然后单击"Disconnect from Loader",执行程序。
执行装载程序后立即断开,处理器将开始运行程序。MTK屏幕显示程序输出 "Hello DS8007 World!",成功!

图5. MTK器件选择
图5. MTK器件选择

图6. DS5002FP启动加载程序标志
图6. DS5002FP启动加载程序标志

评估LCD模块

为演示DS8007评估套件非常有用的一项功能,我们现在建立一个应用程序,在2行20字符的液晶显示屏(LCD)上显示一条消息。但是在开始前,必须设置LCD的对比度,使其在程序执行时能够正确地显示消息。首先,对电路板加电,LCD应不亮。找到电路板上的可变电阻R7 (参见上面的图2),使用小螺丝刀对电阻进行调整,直到一个5 x 7点阵出现在显示屏的字符位置。慢慢调整R7,直到点阵刚刚消失。这设置LCD的对比度,使我们能够看到字符,而看不到间隔。

按照上面的第1步到第10步(建立µVision工程),建立一个新工程和可执行文件。工程文件名为DS8007-2,C源代码文件名为DS8007-2.c。该程序的源代码在下面的附录A中给出。如果您不愿意输入这些信息,也可以从上面提到的FTP网站下载这些文件的.ZIP文件。

一旦建立了HEX文件,按照上面的步骤(装入可执行文件)将其装入到电路板的存储器中。和加载程序断开后,LCD将显示两行消息。

结论

DS8007评估套件为DS8007双路智能卡接口评估提供方便、成熟的平台。套件和Keil C语言开发工具简化了智能卡应用程序的开发过程。

附录A. LCD演示程序

// file DS8007-2.c//#include <REG5000.H> // special function register declarations// // for the DS5000/5002 #include <string.h>#include "LCD_Funct.h" int tmp = 0; uint8_t LCD_Str[42];void main(void){ // Initialize LCD Module, and display 2-line message. LCD_Init(); strcpy(LCD_Str, "DS8007 Dual"); // Create first line of LCD text tmp = LCD_Curpos(1,5); // POSTTTION cursor line 1 char 5 if (tmp == 0) LCD_WRStr(LCD_Str); // Write string to LCD strcpy(LCD_Str, "Smart Card Interface"); // Create 2nd line of LCD text tmp = LCD_Curpos(2,1); // POSTTTION cursor on line 2, char 1 if (tmp == 0) LCD_WRStr(LCD_Str); // Write string to LCD tmp = LCD_Curpos(1,20); // Return cursor to line 1 char 20 while (1); // Loop here to end program}void LCD_Init(){ LCD_Delay(); // Delay to ensure that LCD power-up is complete LCD_WRCmd(FnctSet); // Write FnctSet instruction LCD_WRCmd(DispCnt); // Write Display Control instruction LCD_WRCmd(DispClear); // Write Display Clear instruction LCD_WRCmd(EntryMode); // Write Entry Mode instruction}// Write a string to the 2 x 20 LCD modulevoid LCD_WRStr(uint8_t LCD_Str[]){ int i = 0; while ((LCD_Str[i] != '\0') && (i < 20)) { LCD_WRChr(LCD_Str[i]) ; // Write first 20 characters i++; } if (LCD_Str[i] != '\0') LCD_WRCmd(Line2Ad); // Set CGRAM address to first char 2nd line while ((LCD_Str[i] != '\0') && (i < 40)) { LCD_WRChr(LCD_Str[i]) ; i++; }}// Write a single character to the 2 x 20 LCD modulevoid LCD_WRChr(uint8_t LCD_Chr){ LCD_Busy(); // Wait until the LCD is not busy LCD_RS = 1; // Set RS high for character write LCD_Dat = LCD_Chr; // Output character LCD_EN = 1; // Set enable high LCD_EN = 0; // Clear enable LCD_RS = 0; LCD_Dat = 0xFF; // Re-establish Port Pins as inputs}// Write a command to the 2 x 20 LCD modulevoid LCD_WRCmd(uint8_t LCD_Cmd){ LCD_EN = 0; // Make sure that the LCD enable is low LCD_RS = 0; // Set LCD register select and R/W lines LCD_RW = 0; LCD_Busy(); // Make sure that the display is not busy LCD_Dat = LCD_Cmd; // Output instruction LCD_EN = 1; // Set enable high LCD_EN = 0; // Clear enable LCD_Dat = 0xFF; // Re-establish Port Pins as inputs}// Set the cursor POSTTTION to a specific LOCAIIONint LCD_Curpos(uint8_t VPos, uint8_t HPos){ int rtn; uint8_t Addr, Cmd; // Check input range 1..2 line, 1..20 characters per line if (((VPos == 0) || (VPos > 2)) || ((HPos == 0) || (HPos > 20))) rtn = -1; else { if(VPos == 2) Addr = (0x40 + (HPos - 1)); else Addr = HPos - 1; rtn = 0; Cmd = Addr | 0x80; LCD_WRCmd(Cmd); } return(rtn); }// Test the LCD Module to see if it is Busy (loop until// not busy) void LCD_Busy(){ uint8_t LCD_Stat = LCD_Dat; // Get byte containing status while (LCD_Stat & 0x80){ // Wait for busy flag to clear LCD_RW = 1; // LCD RW needs to be high LCD_EN = 1; // Strobe enable signal LCD_Stat = LCD_Dat; // Read staus LCD_EN = 0; LCD_RW = 0; }}// Time delay for 2 x 20 LCD module (approximately 50ms)void LCD_Delay(){ uint8_t i, j ; for (i=0;i!=100;i++) { for (j=0;j!=153;j++); }}

上一页  [1] [2] 


本文关键字:评估  电工文摘电工技术 - 电工文摘