NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Microcontroller Programming » asm macro error

February 12, 2010
by lcruz007
lcruz007's Avatar

Hi,

I wrote a program that should create an square wave using an assembly macro (just to see how it worked), using the asm keyword in C. I am using 64 "NOPs" at 16MHz. It works just fine, but if I call several times the same macro I get the following error:

/tmp/ccQo9mux.o: In function main': /home/luis/project.c:103: relocation truncated to fit: R_AVR_7_PCREL againstno symbol' make: *** [project.hex] Error 1

What does this mean?

This is the code I am using:

           PORTB &= ~(1<<PB3);
           asm("Delay16");
           asm("Delay8");
           PORTB |= (1<<PB3);
           asm("Delay8");
           asm("Delay4");
           PORTB &= ~(1<<PB3);

//Delay macro definitions...

asm(".MACRO Delay4" ".rept 64" "NOP" ".endr" ".ENDM");

asm(".MACRO Delay8" ".rept 128" "NOP" ".endr" ".ENDM");

asm(".MACRO Delay16" ".rept 256" "NOP" ".endr" ".ENDM");

This code works just fine, but if I call the macro more times, I get that error. I am not using jmp or rjmp to go back to the macro, I just call it.

Thank you

March 05, 2010
by BobaMosfet
BobaMosfet's Avatar

You are getting this because you are using a macro, not a function.

BM

Post a Reply

Please log in to post a reply.

Did you know that you can connect a computer keyboard to your microcontroller? Learn more...