Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multiple definition of `SERCOM4_Handler' #8

Open
2788west opened this issue Jul 8, 2021 · 6 comments
Open

multiple definition of `SERCOM4_Handler' #8

2788west opened this issue Jul 8, 2021 · 6 comments

Comments

@2788west
Copy link

2788west commented Jul 8, 2021

I just installed this library and tried to get one of the examples to work. Unfortunately I get this error when trying to compile for the MKR WiFi 1010. Is there any way to resolve this?

core\variant.cpp.o: In function `SERCOM4_Handler':
C:\Users\johan\Documents\ArduinoData\packages\arduino\hardware\samd\1.8.11\variants\mkrwifi1010/variant.cpp:256: multiple definition of `SERCOM4_Handler'
libraries\LXSAMD21DMX-master\LXSAMD21DMX.cpp.o:C:\Users\johan\Documents\Arduino\libraries\LXSAMD21DMX-master\src/LXSAMD21DMX.cpp:38: first defined here
collect2.exe: error: ld returned 1 exit status
exit status 1
Error compiling for board Arduino MKR WiFi 1010.
@claudeheintz
Copy link
Owner

It looks like MKR WiFi 1010 uses sercom4 and sercom5. The sercom to use is selected by macros in LXSAMD21DMX.h. There are a number of pre-defined options. I just added an option for MKR 1010 that selects sercom2, pins 3 & 4. You can select other of the pre-defined options by uncommenting line 500 and changing the value of use_optional_sercom_macros. The variations are defined in lines 504-631. There are comments explaining the various options including what sercom/pins combination they use.

@2788west
Copy link
Author

2788west commented Jul 8, 2021

Thanks for the quick response, this is really helpful!

@bigdingoTECH
Copy link

bigdingoTECH commented Apr 21, 2023

I am also having this issue,

Have followed your instructions however I am using a MKR 1500 NB.

I chose macro 4

I am unsure of what to uncomment at line 500. This is what is at line 500 for me...

* This library uses a macro, use_optional_sercom_macros, to make the changes necessary

I commented out these

// Serial1
//Uart Serial1(&sercom5, PIN_SERIAL1_RX, PIN_SERIAL1_TX, PAD_SERIAL1_RX, PAD_SERIAL1_TX);
//void SERCOM5_Handler()
//{
//  Serial1.IrqHandler();
//}

However this is not working.

@berchca
Copy link

berchca commented Jun 29, 2023

I am unsure of what to uncomment at line 500. This is what is at line 500 for me...

In the current version, the line to uncomment is 532. It looks like this:
// #define use_optional_sercom_macros 3

You change the '3' to the macro you wish to use.

I, too, am having this problem using a XIAO (which should allow me to access SERCOM4 on pins 6&7. I can't figure out what the conflict is, but if anyone has any good ideas, they'd be much appreciated.

@berchca
Copy link

berchca commented Jul 7, 2023

Just to follow up, I did figure out how to use SERCOM4 (pins 6 & 7) on the XIAO. There were two steps. First was to create a new optional macro, as such:

#elif (use_optional_sercom_macros == 6)
//********************** optional sercom macros 6 **********************
// BtJ - SEEED XIAO M0 on pins 6 and 7 (SERCOM4)

#define PIN_DMX_RX (7ul)
#define PIN_DMX_TX (6ul)
#define PAD_DMX_RX SERCOM_RX_PAD_1
#define PAD_DMX_TX UART_TX_PAD_0

// Set to PIO_SERCOM or PIO_SERCOM_ALT
#define MUX_DMX_RX PIO_SERCOM_ALT
#define MUX_DMX_TX PIO_SERCOM_ALT

// SERCOM is pointer to memory address where SERCOM registers are located.
#define DMX_SERCOM SERCOM4

// sercom is C++ wrapper for SERCOMn (passed to UART constructor)
#define DMX_sercom sercom4

// sercom handler function
#define DMX_SERCOM_HANDLER_FUNC SERCOM4_Handler

#warning Using use_optional_sercom_macros = 6

And then I had to comment out (or delete) the following lines in the XIAO's variant.cpp:

void SERCOM4_Handler()
{
  Serial1.IrqHandler();
}

@claudeheintz
Copy link
Owner

claudeheintz commented Jul 12, 2023

This is exaxtly what is required when a board definition has a sercom handler for Serial1 that is defined, for example:
void SERCOM4_Handler()
{
Serial1.IrqHandler();
}
and you need to define and use

void SERCOM4_Handler()

for the library to work.

Which might not be quickly obvious because of the library's use of macros which let you target different sercoms. See the header file LXSAMD21DMX.h for different sercom configurations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants