LXESP8266DMX
LXESP8266DMX copied to clipboard
Can't receive DMX on the UART0 swap pin.
Hi,
First of all thank you for your library ! It works great when i use an ESP on the default RX pin (3).
Somehow i tried before to receive on the UART0 swap pin (13), by simply making a small modification calling instead of
pinMode(3, SPECIAL);
inside of void uart_init_rx()
pinMode(13, FUNCTION_4);
That didn't work as expected somehow.
I managed to write my own DMX receive code, which did work on the swap pin, but then i was creating something that uses the primary RX pin again and that code somehow failed to work properly and your library did work, so i thought i'd try and see if i could get it to work again on the swap pin, but somehow still no luck. Any idea how to get it working ?
I went as far as to modify the startInput(); function to
void LX8266DMX::startInput ( bool swap ) {
if ( _direction_pin != DIRECTION_PIN_NOT_USED ) {
digitalWrite(_direction_pin, LOW);
}
if ( _interrupt_status != ISR_INPUT_ENABLED ) {
stop();
}
if ( _interrupt_status == ISR_DISABLED ) { //prevent messing up sequence if already started...
_dmx_read_state = DMX_STATE_IDLE;
uart_init_rx(DMX_DATA_BAUD, FORMAT_8N2, this, swap);
_interrupt_status = ISR_INPUT_ENABLED;
}
}
and uart_init_rx(); to
void uart_init_rx(int baudrate, byte config, LX8266DMX* dmxi, bool swap) {
uint32_t conf1 = 0x00000000;
if (swap) {
pinMode(13, FUNCTION_4);
}
else {
pinMode(3, SPECIAL);
}
uart_set_baudrate(UART0, baudrate);
USC0(UART0) = config;
conf1 |= (0x01 << UCFFT);
USC1(UART0) = conf1;
uart_rx_flush();
uart_enable_rx_interrupt(dmxi);
}
to not break the existing library using sketch, and in my mind, this should do the trick. I know for sure the hardware works.