0
votes

Hi there stackoverflow.

I'm working with pic 18f4550 with bootloader.

Because of the bootloader i need to start de code in a specifed address in the memory.

In this case 0x1000 because i dont have any interruptions.

This is my code so far (simple):

#include <p18f4550.h>
#include <delays.h>

#pragma config FOSC = INTOSCIO_EC //Internal oscillator, port function on RA6, EC used by USB 
#pragma config WDT = OFF //Disable watchdog timer

#define LEDPin PORTAbits.RA0 //Define LEDPin as PORT D Pin 1
#define LEDTris TRISDbits.TRISD1 //Define LEDTris as TRISD Pin 1
void main()
{   
    _asm org 1000h
    LEDTris = 0;//Set LED Pin data direction to OUTPUT
    LEDPin = 1;//Set LED Pin

    while(1)
    {
        LEDPin = ~LEDPin;//Toggle LED Pin
        Delay10KTCYx(25);//Delay 250K cycles (1 second at 1MHz since each instruction takes 4 cycles)
    }

}

But!...

C:\Users\User\Documents\ProjectosPIC\testeled\main.c:13:Error: syntax error

I do you know how to fix it? Is this a problem with the compiler??

I'm using mplab IDE with microchip C18 toolsuite with mpasm and other languages.

Why is sintaxe error?

ty

2

2 Answers

1
votes

If you have a C compiler you need not worry about the org address. The compiler and/or linker startup code takes care of that and then calls main. If this is not true, you have a non-standard compiler.

0
votes

It is unlikely for inline assembly to support org.

Further, main() is not the very first piece of code that will execute in your program. There will be a relatively short piece of code to initialize hardware, global variables and possibly the C(++) standard library before main().

So, this error should not come as a surprise at all.

You need to study your compiler and linker options to see how you can specify the load and start addresses. Often times setting such addresses is done via a special linker script which you pass to the compiler or linker as a parameter.

Look up the documentation for your compiler/linker and its files.