TTom 0 Report post Posted February 26, 2015 I am new to "C" programming. I have previously done all my programming in Assembly code. I am using MPLAB IDE 8.70 and boostC. My Interface is ICD2. The chip I am programming is a PIC16F886 which I have almost completed in assembly. My computer crashed and I lost all my recent programs, but I would like to learn "C". The files I am trying to use were found on the Sourceboost web site for beginner, beginners which are excellent programs to learn from. The problem is if there is an error I do not know where to resolve the error. Please find attached the program and the output window. Any help would be appreciated. If the error is caused by the icd2 needing a linker file, I have no idea how to write a linker file. Please help me. Programming Problem.txt Quote Share this post Link to post Share on other sites
John P 0 Report post Posted February 27, 2015 It does say: @ 912: MESSAGE: "Warning: ICD2 Reserved ROM address range:0x1F00-0x1FFF (use linker -rt option)" I don't use ICD2, so I don't know how to interpret this. Is it a likely cause of the program not compiling? You could try removing the #include line temporarily, and see if it compiles OK then. Quote Share this post Link to post Share on other sites
TTom 0 Report post Posted February 27, 2015 I tried removing the include line with ICD2. I also tried programming in release mode. Gives same error. Quote Share this post Link to post Share on other sites
JorgeF 0 Report post Posted February 27, 2015 (edited) Hi It means you have to reserve some program memory for ICD2. The reservation is done by means of the "-rt" option of the linker. Given that you may or may not need this. The Microchip ICD tools (ICD2/3 and Pickit2/3) use some of the PIC resources when used as debuggers not as programmers. When you use "In Circuit Debugging" the ICD tools add some code to your program, this code is known as the "debug executive". The program address ranges and other resources vary from PIC to PIC, so you must check them out in the Microchip docs. When building for debugging with the Boost C toolchain you must include the "icd2.h" header and use the linker switches "-rt" and "-icd2". - The header file declares a number of dummy variables to reserve RAM for the debug executive variables. - The "-icd2" switch reserves program address "0x00" (the reset vector) for the debugging trap. - The "-rt 0x...." switch reserves some program memory at the top of it for the debug executive. If you use the ICD2 as a programmer only, none of this is necessary, but you must tell that to the IDE, by selecting a "release" build instead of a "debug" build. BTW: It is not an error, it is a simple warning. HIH Best regards Jorge Edited February 27, 2015 by JorgeF Quote Share this post Link to post Share on other sites
TTom 0 Report post Posted February 27, 2015 Does anyone out there know how to write a linker file for the Pic16F886 which will resolve this problem ? "Warning: ICD2 Reserved ROM address range:0x1F00-0x1FFF (use linker -rt option)" Quote Share this post Link to post Share on other sites
JorgeF 0 Report post Posted February 28, 2015 (edited) Hi As can be seen from this code snipset... #ifdef _PIC16F886 #define _VALID_ICD2_TARGET #pragma message "Warning: ICD2 Reserved ROM address range:0x1F00-0x1FFF (use linker -rt option)" char IcdReserved_0x070 @ 0x070; char IcdReserved_0x0F0 @ 0x0F0; char IcdReserved_0x170 @ 0x170; char IcdReserved_0x1E5_0x1F0[ 12 ] @ 0x1E5; #endif // _PIC16F886 ... the warning comes from the "icd2.h" file. It has nothing to do with the linker script. It as been put there so it will remember you the need to set the "-rt" (rom top) switch on your linker options. It won't go away unless you stop including the "icd2.h" header. Note that it is a simple message encoded in the "icd2.h" file, so it won't go away even after you adjusted the "-rt" switch. I enfasise once more, that it is only a warning, or better, its only a message, not an error, so it won't prevent a correct build opf the project. I have that same warning on all my debug builds. Best regards Jorge Edited February 28, 2015 by JorgeF Quote Share this post Link to post Share on other sites
JorgeF 0 Report post Posted February 28, 2015 (edited) Hi Just got back to your original post. A second review of the attached text showed me that the buil failed due to an error in line "4" of the "test2.c" file. Test2.c(4): error: failure The failure to build the project has nothing to do with the messages on the ICD2 subject. Best regards Jorge Edited March 1, 2015 by JorgeF Quote Share this post Link to post Share on other sites
TTom 0 Report post Posted March 2, 2015 JorgeF - Thank you sooo much for your response. Your information is what I have needed. So now how do I set the "-rt" (rom top) switch on my linker options. I don't know how to use the Linker YET. Quote Share this post Link to post Share on other sites
JorgeF 0 Report post Posted March 2, 2015 Hi At page 25 of the "BoostC manual" you can find the option switches for the linker. The "-rt" and other switches can be set in the options for building the project. If you are using the "Sourceboost IDE 7.xx". use the "settings->options" menu and fill in the "extra options" for the compiler and/or linker that you need. If you are using the "MPLAB V8.xx", use the "project->buil options -> project" menu to add the extra options for the compiler and/or linker. Here are a couple of linker options from projects of my own: For In Circuit Debugging with Pickit3 or ICD3: -icd2 -rt0x1eff For In Circuit Debugging with Pickit3 or ICD3 using a software call stack: -swcs 6 2 -rt 0x1efe -icd2 BTW: Did you already found the "bug" in your code. "C" variables must be declared at the begining of the code block, not intermixed with the statements. Best regards Jorge Quote Share this post Link to post Share on other sites
TTom 0 Report post Posted March 3, 2015 JorgeF - Thanks for your help. So let me make sure I am doing this correctly: In MPLAB, I go to "Project" then "Build Options" then "Project" then at the very bottom in the text box that is labeled "Additional Command Line Options" I enter the text -rt Is this correct ? Quote Share this post Link to post Share on other sites
JorgeF 0 Report post Posted March 3, 2015 (edited) Hi More or less. In MPLAB V8.xx its "Project -> Buid Options -> Project "choose the BoostLink Linker separator", at the bottom line write "-rt" followed by the appropriate adress for your PIC and debugging tool. I'm not sure where is it in MPLAB X. An example: To use the Pickit3 with a PIC16F886, we have the following reserved resources: - Program memory 0x000 and the range from 0x1f00 - 0x1fff - RAM addresses 0x0, 0x70, 0x80, 0xf0, 0x170, 0x180 and 0x1e5-0x1f0 So in the linker extra command line options we put: -icd2 -rt0x1eff "-icd2" takes care of reserving the program address 0x000 (reset vector). Its called "icd2", but is the same for ICD2, ICD3, Pickit2 and Pickit3. "-rt0x1eff" prevents the linker from using the reserved program address range for your code. The reservation of the RAM addresses is made by the include file "icd2.h" (or icd3.h) by declaring dummy variables at those addresses. You can find the tables with the reserved resources for each debugging tool and each PIC family in the MPLAB help menu. "help -> topics" and choose the topic for your debugging tool. Best regards Jorge Edited March 3, 2015 by JorgeF Quote Share this post Link to post Share on other sites
TTom 0 Report post Posted March 5, 2015 Jorge - I am using MPLAB 8.70 - So is this correct...... Well.... I'm trying to paste a Jpeg of the window that I have entered my script in, but I'm having no success. I have tried to paste using Ctrl+V from the Copy and Paste process. I have tried copying from Word and using that option. Is there a server that we can use to share Jpegs, so I can use the URL option. Quote Share this post Link to post Share on other sites
JorgeF 0 Report post Posted March 11, 2015 Hi Well. There are a number of free hosting sites for photo albuns, like "photobucket" for example.. Just pick your choice. Or you can attatch it here, but only very small images. Ether you cut it, like I did, reduce it to B&W or both. This is my setup to use an ICD3 to debug a BoostC project. PAy attention that the value for "-rt" id specific to the PIC16F886 I used in this project. As I said before you must check in the MPLAB docs for the ICD2 what are the reserved resources for your PIC. HIH Best regards Jorge Quote Share this post Link to post Share on other sites
TTom 0 Report post Posted March 12, 2015 Jorge - Thanks for helping me. Is there a way to close out this thread and give you credit ? Quote Share this post Link to post Share on other sites
JorgeF 0 Report post Posted March 12, 2015 Linker_Small.jpg Jorge - Thanks for helping me. Is there a way to close out this thread and give you credit ? Hi I haven't the slightest idea. If its possible it might be interesting to rename the thread with a "[sOLVED]" sufix. About giving me credit for anything, thank you but don't worry about it, Best regards Jorge Quote Share this post Link to post Share on other sites