The only thing the handler does (for the moment) is count how many times it has been called (counter++). It does not clear an interrupt mask and also it does not reload the timer, so it might or might not called more than once. I am aware of that.
This is what happens:
- when using "normal" FRC1 interrupt, NOTHING happens, the interrupt handler is never called (counter remains at zero)
- when using the "NMI" FRC1 interrupt, the handler is called, but the timer is reloaded automatically and the handler is called again and again, without the timer being reloaded by me and without setting "autoreload".
I am NOT using any os_timer* functions. I am NOT using pwm (not even -lpwm linked).
This is my testing code:
enum
{
FRC1_DIVIDE_BY_1 = 0,
FRC1_DIVIDE_BY_16 = 4,
FRC1_DIVIDE_BY_256 = 8
};
enum
{
FRC1_EDGE_INT = 0,
FCR1_LEVEL_INT = 1
};
enum
{
FRC1_AUTO_LOAD = 0x0040,
FRC1_ENABLE_TIMER = 0x0080,
};
unsigned int ints;
static void intr_handler(void)
{
ints++;
}
ICACHE_FLASH_ATTR static void intr_test(void)
{
RTC_REG_WRITE(FRC1_CTRL_ADDRESS, FRC1_ENABLE_TIMER | FRC1_DIVIDE_BY_16 | FRC1_EDGE_INT);
ETS_FRC_TIMER1_INTR_ATTACH(intr_handler, NULL); // non-NMI interrupt
//ETS_FRC_TIMER1_NMI_INTR_ATTACH(intr_handler); // NMI interrupt, choose one
TM1_EDGE_INT_ENABLE();
ETS_FRC1_INTR_ENABLE();
RTC_REG_WRITE(FRC1_LOAD_ADDRESS, 256);
RTC_CLR_REG_MASK(FRC1_INT_ADDRESS, FRC1_INT_CLR_MASK);
}