View previous topic :: View next topic |
Author |
Message |
ctmseattle
Joined: 26 May 2010 Posts: 3
|
Start-Up Code Help Needed |
Posted: Wed May 26, 2010 1:01 pm |
|
|
Hello,
I am using the PCH Compiler with MPLAB IDE and I cannot figure out how to correctly include startup code for the MCU (PIC18F6527). Given that I am not using CCS’s IDE there does not appear to be a seamless way to do this.
I have a compiling (multi-C file) project in MPLAB that does not load yet due to the absence of the start-up code. If I try to follow Microchip’s instructions for the Project Wizard to add the start-up code file (either Object or Code Template, e.g. C:\Program Files\Microchip\MPASM Suite\Template\Code\18F6527TEMP.ASM) to my project it sticks the ASM file in the “Other Files” folder instead of the “Source Files” folder in the project. I presume this is because I’ve specified CCS as the Toolsuite, which is a C complier and doesn’t expect ASM source code.
I've searched this forum and was unable to find anything. I would think that the process for integrating start-up code would be one of the most common questions (and problems) people have. This is especially true for those of us who have not purchased the hi-end version of the compiler. Perhaps I've just missed a sticky post somewhere in this forum. If so then I'd appreciate a pointer to it! :O)
Can you please specify the steps I need to take to integrate Microchip’s ASM start-up code into a CCS Toolsuite enabled project? Of course, if CCS has an example of other working start-up code I can use that as well.
Best Regards,
ctmseattle |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19369
|
|
Posted: Wed May 26, 2010 2:27 pm |
|
|
Most PICs don't need any startup code at all. What is needed, is automatically inserted by the compiler. The only stuff you need to add, is to initialise the particular peripherals, and for this, the examples are a reasonable source...
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
ctmseattle
Joined: 26 May 2010 Posts: 3
|
|
Posted: Wed May 26, 2010 3:44 pm |
|
|
Well, I have code that compiles but there's nothing in program memory if I open the simulator trace window. Don't I need to specify a far jump to main somwhere to enter C context? I don't think that happens automatically. |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed May 26, 2010 3:50 pm |
|
|
Start with a simple program that blinks an LED on Pin B0.
Code: |
#include <18F6527.h>
#fuses INTRC_IO,NOWDT,PUT,BROWNOUT,NOLVP
#use delay(clock=4000000)
//======================================
void main(void)
{
while(1)
{
output_high(PIN_B0);
delay_ms(500);
output_low(PIN_B0);
delay_ms(500);
}
} |
|
|
![](templates/subSilver/images/spacer.gif) |
ctmseattle
Joined: 26 May 2010 Posts: 3
|
|
Posted: Wed May 26, 2010 9:34 pm |
|
|
Ok... I tried this sample project and it worked. I then went and re-created my project from scratch including only the main C file at first and that worked too. Added everything else and it's still working. My original project still doesn't work (no source changes) and I don't know why. Perhaps an order of operations glitch somewhere along the line.
Anyway, thank you for your help!
Best Regards,
ctmseattle |
|
![](templates/subSilver/images/spacer.gif) |
|