Now I wish someone can make ICD2 work under Linux (even only as a programmer). Xiaofan -----Original Message----- From: forums@microchip.com [mailto:forums@microchip.com] Sent: Tuesday, May 17, 2005 5:26 AM Subject: This is an email notification from forum.microchip.com. A new post has been made on May 16, 2005 2:26:09 PM . Category: 16 bit Digital Signal controllers Forum: dsPIC30F Topics http://forum.microchip.com/fb.asp?m=94243 Details of this message include: hanzl Success report: C, bare dsPIC and Linux free tools Using C, bare dsPIC in breadboard, ad-hoc made programmer and just opensource free tools, I have my LED blinking This game is for bigger nasty children so think twice before following me. But if you think that at least trying what is it worth to do something zero-up, here we go: 1) C30 is ported gcc, you can compile your mostly complete free toolchain or use these .deb or .rpm files: http://noel.feld.cvut.cz/dspic/ 2) Minimalistic C file working around missing libraries looks like this: #define ASM(X) __asm__ volatile( X ) #define STRING(X) #X /* X macro-expanded before being quoted */ #define BCLR(adr,bit) ASM( "bclr " STRING(adr) ", #" STRING(bit) ) #define BSET(adr,bit) ASM( "bset " STRING(adr) ", #" STRING(bit) ) #define TRISD 0x2D2 #define PORTD 0x2D4 #define LATD 0x2D6 __attribute__((section("__FOSC.sec,x"))) int _FOSC = (0x810B); _reset(){ main(); } delay(){ volatile int x = 0; for( x=30002; x>0; x-- ){ } } main(){ BCLR( TRISD, 1 ); /* RD1 is output */ while( 1 ){ BSET( LATD, 1 ); /* RD1 high */ delay(); BCLR( LATD, 1 ); /* RD1 low */ delay(); } }; 3) Compile like this: pic30-elf-gcc -nostdlib dspic.c -o dspic pic30-elf-bin2hex dspic 4) Download and compile Homer Reid's programming software: http://homerreid.ath.cx/misc/dspicprg/ 5) Build JDM-style programmer. You should ensure 5V for dsPIC and proper level shifting for these signals: TD --> MCLR (RS232 to 0V/9V, should rise quickly to at least 9V ) RTS --> PGC (RS232 to logical levels) DTR --> PGD (RS232 to logical levels) CTS <-- PGD (logical levels to RS232, working at least when DTR is high) All this signal conditioning keeps polarity, no inversion. 6) Take special care to filter PGC and PGD as dsPIC is really really picky regarding these signals. For me, it seemed to work with just 82pF between PGC and GND, but might better follow the original advice: ...put 22..47 pF on the PGD and PGC lines to ground near the target chip. In addition, put a 100 ohm resistor in series with the PGD line between target chip and the cap 7) Try to guess whether things work buy observing the hex file produced by something like: dspicdmp -p 760 where "760" is the base port IN DECIMAL (look at /proc/ioports for ideas) and when confident enough, flash your program with something like dspicprg -p 760 -c pic30f4012 -f dspic.hex 8) Connect MCLR to +5V and enjoy blinking LED. So far the C code cannot use global variables, look here to know more: http://forum.microchip.com/tm.asp?m=85994 And please consider pushing the status of free tools a little bit forward. Well, I am happy to have my blinking LED, but I might have one without going through 1000+ pages of manuals If you want any further progress on the Linux front, it might very well be up to you now Many thanks to Microchip, John, Homer and Olin. Regards Vaclav Hanzl http://forum.microchip.com/ -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist