I try to compile a simple function for XMEGA256A3BU:
uint8_t NVM_read_byte(uint8_t cmd, uint16_t address)
{
uint8_t result;
asm volatile(
"in r25, __SREG__" "\n\t"
"cli" "\n\t"
"lds __tmp_reg__, %A3" "\n\t"
"sts %A3, %[cmd]" "\n\t"
"lpm %[result], Z" "\n\t"
"sts %A3, __tmp_reg__" "\n\t"
"out __SREG__, r25" "\n\t"
: [result] "=r" (result)
: [cmd] "r" (cmd), "z" (address), [nvm_cmd] "m" (NVM_CMD)
: "r25"
);
return result;
}
When compiling using avr-gcc everything is ok, program compiles and executes fine. But the same code compiled by avr-g++ produces the following errors:
Error undefined reference to `X'
Errors are related to following instructions:
"lds __tmp_reg__, %A3" "\n\t"
"sts %A3, %[cmd]" "\n\t"
"sts %A3, __tmp_reg__" "\n\t"
It seems that the error is produced only during compiling with g++, extern “c” doesn’t change the situation. Can any body help? Thanks in advance.