DMX driver mapped to D21G SERCOM

Hi,

I found this library for DMX: https://github.com/claudeheintz/LXSAMD21DMX

I have tried to use it on the D21G board as a DMX receiver. It compiles OK but I do not receive any data. The library is designed to use SERCOM4. If I understand the board description the RS458 interface is connected to Serial (that should be replaced by the DMX driver) using SERCOM1, but I'm not sure I have undertood how to do the mapping correctly. There is an instruction at the end of the header file that I tried to follow. The changes I have done is:

// +++ Test for SERCOM1
#define PIN_DMX_RX (0ul)
#define PIN_DMX_TX (1ul)
#define PAD_DMX_RX SERCOM_RX_PAD_3
#define PAD_DMX_TX UART_TX_PAD_2

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

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

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

Is this the correct settings for the RS485 interface or have I missed something?

Gunnar Strömme
Gunnar Strömme
29
| 3 1 2
Asked on 6/21/18, 3:54 PM
0
vote
2261 Views

Thank you Tom, great help! I used your settings and also had to remove the SERCOM3 handler in variant.cpp to avoid multiple definitions, then it compiles with no errors.

Now it works like a charm and DMX settings are received as expected, at least on channel one as I have tested so far.

BR Gunnar

 

Gunnar Strömme
Gunnar Strömme
29
| 3 1 2
Answered on 6/22/18, 2:27 PM
0
vote

Hi, the only setting you need to be aware of regarding the INDIO's RS485 is that the TXenablePin is on D9 and the serial port is called 'Serial' (D0/D1), see https://github.com/Industruino/libraries#rs485

The INDIO uses the MAX485 IC, which is compatible with the example used in the library https://github.com/claudeheintz/LXSAMD21DMX/blob/master/src/LXSAMD21DMX.h

Library >> INDIO

RX (5) >> RX (0)

(3) >> (9)

TX (4) >> TX (1)

 

I'm not an expert in pin mappings but my suggestion, based on the Industruino D21G pin mapping https://github.com/Industruino/IndustruinoSAMD/blob/master/variants/industruino_d21g/variant.cpp is you try this:

#define PIN_DMX_RX (0ul)

#define PIN_DMX_TX (1ul)

#define PAD_DMX_RX SERCOM_RX_PAD_3

#define PAD_DMX_TX UART_TX_PAD_2

// Set to PIO_SERCOM or PIO_SERCOM_ALT

#define MUX_DMX_RX PIO_SERCOM_ALT

#define MUX_DMX_TX PIO_SERCOM_ALT

// SERCOMn is pointer to memory address where SERCOM registers are located.

#define DMX_SERCOM SERCOM3

// sercomN is C++ wrapper for SERCOMn (passed to UART constructor)

#define DMX_sercom sercom3

and in .cpp you'd have to change 

void SERCOM4_Handler() to void SERCOM3_Handler()

and in your sketch

SAMD21DMX.setDirectionPin(9); 

Tom
Tom
5675
| 1 1 3
Answered on 6/22/18, 1:23 AM
0
vote

Your answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

Ask a Question

Keep Informed

About This Forum

This community is for professionals and enthusiasts of our products and services.

Read Guidelines

Question tools

45 follower(s)

Stats

Asked: 6/21/18, 3:54 PM
Seen: 2261 times
Last updated: 6/22/18, 2:27 PM