00001
00002
00003
00004
00005
00006 #include "piccolo_all.h"
00007 #include "stdio.h"
00008
00019 unsigned char ch,ct,cd1,cd2,i;
00020
00025 void out2hex(unsigned char t) {
00026 unsigned char c;
00027 c=(char)((t>>4) & 0x0F);
00028 if (c>9) c+=7;
00029 _user_putc(c+'0');
00030 c=(char)(t & 0x0F);
00031 if (c>9) c+=7;
00032 _user_putc(c+'0');
00033 }
00034
00035 void main(void) {
00036 InitializeSystem();
00037
00038 while (!usb_cdc_kbhit()) {
00039 ProcessIO();
00040 }
00041 outString("read_id.c program on ");
00042 #if defined(__18F4550)
00043 outString("PICCOLO-4550\n");
00044 #elif defined(__18F14K50)
00045 outString("PICCOLO-14K50\n");
00046 #endif
00047 TBLPTR= (unsigned short long)0x3ffffe;
00048 _asm tblrdpostinc _endasm
00049 cd1=TABLAT;
00050 _asm tblrdpostinc _endasm
00051 cd2=TABLAT;
00052 outString("Device ID = ");
00053 out2hex(cd2);
00054 out2hex(cd1);
00055 outString(" User ID = ");
00056 TBLPTR= (unsigned short long)0x200000;
00057 for(i=0; i<8; i++) {
00058 _asm tblrdpostinc _endasm
00059 ct=TABLAT;
00060 out2hex(ct);
00061 }
00062 outString("\n");
00063 while (1) {
00064 ch=usb_cdc_getc();
00065 usb_cdc_putc(ch);
00066 }
00067 }
00068
00069