ESP8266 Developer Zone The Official ESP8266 Forum 2016-08-27T01:08:10+08:00 https://bbs.espressif.com:443/feed.php?f=7&t=2630 2016-08-27T01:08:10+08:00 2016-08-27T01:08:10+08:00 https://bbs.espressif.com:443/viewtopic.php?t=2630&p=9639#p9639 <![CDATA[Re: Strange behaviour FRC1 timer / interrupt handler]]> it works.

According to the "documentation" (ehhhrmm, just examples found here and there), LEVEL_INT would be 0x1 and EDGE_INT would be 0x0. It seems it's the other way around actually?

It IS an EDGE interrupt now, because I don't need to clear the interrupt mask to have the ISR called again.

How comes it seems to for others nonetheless?

Statistics: Posted by eriksl — Sat Aug 27, 2016 1:08 am


]]>
2016-08-26T23:26:37+08:00 2016-08-26T23:26:37+08:00 https://bbs.espressif.com:443/viewtopic.php?t=2630&p=9637#p9637 <![CDATA[Re: Strange behaviour FRC1 timer / interrupt handler]]>

Code:

static inline uint32_t ETS_INTR_ENABLED(void) // FIXME
{
    uint32_t enabled;
    __asm__ __volatile__("esync; rsr %0,intenable":"=a" (enabled));
    return enabled;
}


I can see that the FRC1 interrupts are enabled.

Without enabling FRC1 interrupts, it reads 521, bit 9 is clear
With enabeling FRC1 interrupts, it reads 721, bit 9 is set

Statistics: Posted by eriksl — Fri Aug 26, 2016 11:26 pm


]]>
2016-08-23T18:42:56+08:00 2016-08-23T18:42:56+08:00 https://bbs.espressif.com:443/viewtopic.php?t=2630&p=9589#p9589 <![CDATA[Re: Strange behaviour FRC1 timer / interrupt handler]]>
I copied this code in various variants from examples (because of documentation lacking...), and apparently it does work for those people...

I deactivated all code that does something with interrupts, i.e. the UART handler and the code that is run by os_timer_arm etc.

What to try next? I have no idea. Could it be the RTC clock calibration (see SDK function)?

Statistics: Posted by eriksl — Tue Aug 23, 2016 6:42 pm


]]>
2016-08-19T18:10:46+08:00 2016-08-19T18:10:46+08:00 https://bbs.espressif.com:443/viewtopic.php?t=2630&p=8587#p8587 <![CDATA[Strange behaviour FRC1 timer / interrupt handler]]>
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:

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,
};

enum
{
   FRC1_NMI_SOURCE = 0x8000
};

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);
}

Statistics: Posted by eriksl — Fri Aug 19, 2016 6:10 pm


]]>