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.
1 Answer 1
XC8 doesn't use that syntax for inline assembler.
What you should have is:
asm("GOTO 0x1C");
instead.
-
\$\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– Rorschach2015年03月23日 17:13:54 +00:00Commented Mar 23, 2015 at 17:13
asm("goto 0x1c");
\$\endgroup\$asm
problem? It says line 33, which is after that line. Will it compile if you remove it? Will it compile if you take theasm
thing into{}
? \$\endgroup\$