0

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.

Rorschach
  • 113
  • 1
  • 5
  • 1
    Try using: asm("goto 0x1c"); – Majenko Mar 23 '15 at 17:05
  • 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 {} ? – Eugene Sh. Mar 23 '15 at 17:06
  • @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! – Rorschach Mar 23 '15 at 17:12

1 Answers1

2

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

asm("GOTO 0x1C");

instead.

brhans
  • 14,723
  • 3
  • 35
  • 51
  • 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!

    – Rorschach Mar 23 '15 at 17:13