diff --git a/DCCRMT.cpp b/DCCRMT.cpp index 21002cf..a0d8756 100644 --- a/DCCRMT.cpp +++ b/DCCRMT.cpp @@ -87,7 +87,7 @@ RMTPin::RMTPin(byte pin, byte ch, byte plen) { bzero(&config, sizeof(rmt_config_t)); config.rmt_mode = RMT_MODE_TX; config.channel = channel = (rmt_channel_t)ch; - config.clk_div = 1; // use 80Mhz clock directly + config.clk_div = RMT_CLOCK_DIVIDER; config.gpio_num = (gpio_num_t)pin; config.mem_block_num = 2; // With longest DCC packet 11 inc checksum (future expansion) // number of bits needed is 22preamble + start + diff --git a/DCCRMT.h b/DCCRMT.h index 2e119e6..bd235b7 100644 --- a/DCCRMT.h +++ b/DCCRMT.h @@ -23,8 +23,10 @@ #include "soc/rmt_reg.h" #include "soc/rmt_struct.h" -#define DCC_1_HALFPERIOD 4640 // 1 / 80000000 * 4640 = 58us -#define DCC_0_HALFPERIOD 8000 +// make calculations easy and set up for microseconds +#define RMT_CLOCK_DIVIDER 80 +#define DCC_1_HALFPERIOD 58 //4640 // 1 / 80000000 * 4640 = 58us +#define DCC_0_HALFPERIOD 100 //8000 class RMTPin { public: