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

Fixed issue that shut down 2nd RMT channel after a few frames. #420

Merged
merged 2 commits into from
Nov 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 66 additions & 16 deletions ESPixelStick/src/output/OutputRmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,35 +134,68 @@ void c_OutputRmt::Begin (rmt_channel_t ChannelId,
//----------------------------------------------------------------------------
void IRAM_ATTR c_OutputRmt::ISR_Handler ()
{
if (RMT.int_st.val & RMT_INT_TX_END_BIT)
{
RMT.int_clr.val = RMT_INT_TX_END_BIT;
RMT.int_clr.val = RMT_INT_THR_EVNT_BIT;

RMT.int_ena.val &= ~RMT_INT_TX_END_BIT;
RMT.int_ena.val &= ~RMT_INT_THR_EVNT_BIT;
register uint32_t int_st = RMT.int_st.val;

// ISR_Handler_StartNewFrame ();
}
else if (RMT.int_st.val & RMT_INT_THR_EVNT_BIT)
do // once
{
// RMT.int_ena.val &= ~RMT_INT_THR_EVNT (RmtChannelId);
RMT.int_clr.val = RMT_INT_THR_EVNT_BIT;
if (!(int_st & (RMT_INT_TX_END_BIT | RMT_INT_RX_END | RMT_INT_ERROR | RMT_INT_THR_EVNT)))
{
IsrIsNotForUs++;
break;
}

if (OutputPixel->MoreDataToSend ())
if (RMT.int_st.val & RMT_INT_THR_EVNT_BIT)
{
ISR_Handler_SendIntensityData ();
DataISRcounter++;

// RMT.int_ena.val &= ~RMT_INT_THR_EVNT (RmtChannelId);
RMT.int_clr.val = RMT_INT_THR_EVNT_BIT;

if (OutputPixel->MoreDataToSend ())
{
ISR_Handler_SendIntensityData ();
}
else
{
RMT.int_ena.val &= ~RMT_INT_THR_EVNT_BIT;
}
break;
}
else

if (int_st & RMT_INT_TX_END_BIT)
{
FrameEndISRcounter++;

RMT.int_clr.val = RMT_INT_TX_END_BIT;
RMT.int_clr.val = RMT_INT_THR_EVNT_BIT;

RMT.int_ena.val &= ~RMT_INT_TX_END_BIT;
RMT.int_ena.val &= ~RMT_INT_THR_EVNT_BIT;

// ISR_Handler_StartNewFrame ();
break;
}
}

if (int_st & RMT_INT_ERROR_BIT)
{
ErrorIsr++;
}

if (int_st & RMT_INT_RX_END_BIT)
{
RxIsr++;
}

} while (false);


} // ISR_Handler

//----------------------------------------------------------------------------
void IRAM_ATTR c_OutputRmt::ISR_Handler_StartNewFrame ()
{
FrameStartCounter++;

RMT.conf_ch[RmtChannelId].conf1.mem_rd_rst = 1; // set the internal pointer to the start of the mem block
RMT.conf_ch[RmtChannelId].conf1.mem_rd_rst = 0;

Expand Down Expand Up @@ -249,4 +282,21 @@ bool c_OutputRmt::Render ()

} // render

//----------------------------------------------------------------------------
void c_OutputRmt::GetStatus (ArduinoJson::JsonObject& jsonStatus)
{
jsonStatus[" DataISRcounter: "] = DataISRcounter;
jsonStatus["FrameEndISRcounter: "] = FrameEndISRcounter;
jsonStatus[" FrameStartCounter: "] = FrameStartCounter;
jsonStatus[" ErrorIsr: "] = ErrorIsr;
jsonStatus[" RxIsr: "] = RxIsr;
jsonStatus[" IsrIsNotForUs: "] = IsrIsNotForUs;

jsonStatus[" Raw int_ena: 0x"] = String (RMT.int_ena.val, HEX);
jsonStatus[" int_ena: 0x"] = String (RMT.int_ena.val & (RMT_INT_TX_END_BIT | RMT_INT_THR_EVNT_BIT), HEX);
jsonStatus[" int_st: 0x"] = String (RMT.int_st.val & (RMT_INT_TX_END_BIT | RMT_INT_THR_EVNT_BIT), HEX);
jsonStatus[" Raw int_st: 0x"] = String (RMT.int_st.val, HEX);

} // GetStatus

#endif // def ARDUINO_ARCH_ESP32
10 changes: 7 additions & 3 deletions ESPixelStick/src/output/OutputRmt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,20 @@ class c_OutputRmt
uint8_t NumIntensityBitsPerInterrupt = 0;

// debug counters
// uint32_t DataISRcounter = 0;
// uint32_t FrameEndISRcounter = 0;
// uint32_t FrameStartCounter = 0;
uint32_t DataISRcounter = 0;
uint32_t FrameEndISRcounter = 0;
uint32_t FrameStartCounter = 0;
uint32_t RxIsr = 0;
uint32_t ErrorIsr = 0;
uint32_t IsrIsNotForUs = 0;

public:
c_OutputRmt ();
~c_OutputRmt ();

void Begin (rmt_channel_t ChannelId, gpio_num_t DataPin, c_OutputPixel * OutputPixel, rmt_idle_level_t idle_level);
bool Render ();
void GetStatus (ArduinoJson::JsonObject& jsonStatus);
void set_pin (gpio_num_t _DataPin) { DataPin = _DataPin; rmt_set_gpio (RmtChannelId, rmt_mode_t::RMT_MODE_TX, DataPin, false); }

void SetNumIdleBits (uint8_t Value) { NumIdleBits = Value; }
Expand Down
7 changes: 7 additions & 0 deletions ESPixelStick/src/output/OutputWS2811Rmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,13 @@ bool c_OutputWS2811Rmt::SetConfig (ArduinoJson::JsonObject& jsonConfig)

} // SetConfig

//----------------------------------------------------------------------------
void c_OutputWS2811Rmt::GetStatus (ArduinoJson::JsonObject& jsonStatus)
{
c_OutputWS2811::GetStatus (jsonStatus);
// Rmt.GetStatus (jsonStatus);
} // GetStatus

//----------------------------------------------------------------------------
void c_OutputWS2811Rmt::Render ()
{
Expand Down
1 change: 1 addition & 0 deletions ESPixelStick/src/output/OutputWS2811Rmt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class c_OutputWS2811Rmt : public c_OutputWS2811
void Begin (); ///< set up the operating environment based on the current config (or defaults)
bool SetConfig (ArduinoJson::JsonObject& jsonConfig); ///< Set a new config in the driver
void Render (); ///< Call from loop (), renders output data
void GetStatus (ArduinoJson::JsonObject& jsonStatus);

private:

Expand Down