Hello Community,
I'm using Atmel Studio 6.2 and Visual Micro. I want to mix Assembler with C++ using a .S-file.
Unfortunately I have a linker problem, the output of the compiler run creates an
undefined reference to `foobar' error.
Following tips from the internet I created a .S file containing a function pulling some port pins:
#include <avr/io.h>
.section .text
.global foobar
foobar:
start:
cbi 0x05,4
sbi 0x05,4
sbi 0x05,5
sbi 0x05,3
nop
cbi 0x05,5
cbi 0x05,3
rjmp start
My .ino - file contains the declaration line
extern "C" {void foobar(void);}
and in the setup() function I call my function
foobar();
However, when I try to compile the outcome is
Compiling 'LCD7SEG' for 'Arduino Uno'
LCD7SEG.cpp.o:In function `setup'
LCD7SEG.ino:undefined reference to `foobar'
Error creating .elf
I tried to put the assembler source code in the sketchbook\libraries subfolder, in the folder where the ino file lives, I added it as a library or just as a source code to the solution explorer - it does not work.
To me it looks like the system just not assembles the source code - how can I make that happen (and tell the linker to use the .O file)?
Thank you very much