0
\$\begingroup\$

I'm building a bootloader firmware, and now I want a simple app (LED blinks) to test calling bootloader from application itself.

I'm currently doing:

    #include <stdio.h>
#include <stdlib.h>
#include <p18f25k50.h>


#pragma config FOSC = INTOSCIO
#pragma config FCMEN = OFF                         
#pragma config BORV = 3
#pragma config CPB = OFF
#pragma config CPD = OFF
/*
 *
 */

int main(int argc, char** argv) {

    int i, j;

    TRISC = 0xF0;

    LATCbits.LATC2 = 0;

    while(1) {

        if(!PORTBbits.RB3)
         _asm goto 0x1C _endasm


        LATCbits.LATC2=!LATCbits.LATC2;

        for(i=0;i<1000; i++) {
            for(j=0; j<10; j++) {

            }

        }

    }
    return (EXIT_SUCCESS);
}

And, I get

newmain.c:33: error: (195) expression syntax
(908) exit status = 1

The error is showing me the one assembly line I have in my code, which is supposed to send MC's instructions to absolute bootloader entry point.

After trying to build. I'm using MPlab X, with XC8 PRO compiler.

Does anyone have any idea what in here is wrong?

Thanks in advance.

\$\endgroup\$
3
  • 1
    \$\begingroup\$ Try using: asm("goto 0x1c"); \$\endgroup\$
    – Majenko
    Commented Mar 23, 2015 at 17:05
  • \$\begingroup\$ Are you sure it is the asm problem? It says line 33, which is after that line. Will it compile if you remove it? Will it compile if you take the asm thing into {} ? \$\endgroup\$
    – Eugene Sh.
    Commented Mar 23, 2015 at 17:06
  • \$\begingroup\$ @Majenko Thanks for the tip! It compiled, easy! I am new to PIC programming, and asm language, so I just followed Microchip's tutorial that proved to be wrong. Again, thanks! \$\endgroup\$
    – Rorschach
    Commented Mar 23, 2015 at 17:12

1 Answer 1

2
\$\begingroup\$

XC8 doesn't use that syntax for inline assembler.
What you should have is:

asm("GOTO 0x1C");

instead.

\$\endgroup\$
1
  • \$\begingroup\$ Yup, it works this way. I am new to PIC programming, and asm language, so I just followed Microchip's tutorial that proved to be wrong. Thank you! \$\endgroup\$
    – Rorschach
    Commented Mar 23, 2015 at 17:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.