通信设计应用
Jumper | Installed | Description |
JU1 | Installed | Board's DVDD connected to DS8007's digital VDD |
JU2 | Installed | DS8007's VCCA connected to smart card socket 1, pin C1 |
JU3 | Installed | Board's AVDD connected to DS8007's analog supply, VDDA |
JU4 | Installed: Connect pins 1 and 2 | Board's AVDD connected to smart card socket 1, pin S2 |
JU5 | Installed: Connect pins 2 and 3 | Board's AVDD connected to smart card socket 1 pin, S1 through 10K |
JU6 | Not Installed | |
JU7 | Not Installed | |
JU8 | Installed | DS8007's VCCB connected to SAM socket, pin C1 |
JU9 | Installed: Connect pins 2 and 3 | DS8007's PRESB connected to GND (through 10K) |
JU10 | Installed: Connect pins 2 and 3 | DS5002FP's nPROG connected to RS-232 DTR0/DSR0 |
JU11 | Installed | Board's 5V supply connected to board's AVDD |
JU12 | Installed | Board's 5V supply connected to board's DVDD |
JU13 | Installed: Connect pins 2 and 3 | DS8007's INTAUX pin connected to GND (through 10K) |
// File DS8007-1.C #include// special function register declarations // // for the DS5000/5002 #include // prototype declarations for I/O functions // Main C function. Program execution starts here. void main (void) { // Set up the serial port for 38400 baud at 14.7MHz. TMOD=0x21; // Timer 1: 8-bit auto-reload from TH1, Timer 0: 16-bit TH1 = 0xFE; // Set timer reload value for 38,400 baud PCON|=0x80; // Turn on baud rate doubler SMOD_0 TCON=0x50; // Enable timers 0 and 1 SCON=0x50; // 10-bit async, enabled TI=1; // Set TI to send first character TR1 = 1; // Start timer 1 // Start main program printf ("\nHello DS8007 World!\n\n"); // Output message while (1) ; // End program by looping here. }
> W MCON 0A > W RPCTL 01 > R MCON:0A RPCTL:81 MSL:01 Microcontroller's response to read register command如果在输入启动加载程序命令时,您收到"E: LOCKED"错误消息,说明该部分有自己的安全锁定设置。要对该部分进行解锁,在加载程序提示符 >下输入解锁命令(U)即可。这样做会破坏存储在处理器存储器中的信息,但是该部分解锁后,可以输入上面的寄存器命令。发出读寄存器命令(> R)后,DS5002FP报告寄存器MCON (0A)和RPCTL (81)的状态。DS5002FP还显示MSL位的状态(参见安全微控制器用户指南(English only),了解详细信息),该例中为01。
> Loading File ...\DS8007-1.hex通过显示一连串的圆点表示正在装载。
// file DS8007-2.c // #include// special function register declarations // // for the DS5000/5002 #include #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); // Position 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); // Position 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 module void 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 module void 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 module void 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 position to a specific location int 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++); } }
全部0条评论
快来发表一下你的评论吧 !