IRMP-org / IRMP

Infrared Multi Protocol Decoder
GNU General Public License v3.0
267 stars 43 forks source link

IRTimer.hpp needs small corectoin for __AVR_ATmega4809__ #64

Closed mhrdl closed 2 years ago

mhrdl commented 2 years ago

Hi, __AVR_ATmega4809__ target has issue when sending data - timer's CCMP is incorrectly stored/restored. irsnd_send_data ends in an infinite loop.

Problem is in following part of code: https://github.com/ukw100/IRMP/blob/9de71e836921afec918f4cb38c231dba49b18bc8/src/IRTimer.hpp#L314-L318

TCB0.CCMP is 16-bit long, so sTimerOCR needs to be of uint16_t type. storeIRTimer / restoreIRTimer do not correctly store / restore timer state currently. (It might be better to create sTimerCCMP instead and use it in storeIRTimer / restoreIRTimer - so code is more readable ;) ).

Just note: I do not use it with __AVR_ATmega4809__, I work with AVR32DB28 and https://github.com/SpenceKonde/DxCore - it would be very nice to have support for it ;). It seems it works with __AVR_ATmega4809__ defines correctly - except issue I mentioned here.

ArminJo commented 2 years ago

Thanks for reporting. 🥇 I added || defined(__AVR_ATmega4809__) to line 314. If you can tell me which macro is set for AVR32DB28 (like __AVR_ATmega4809__) I can add this macro to line 314 too, to support it natively. You may have to look at the verbose compile output for the macro.