Xtensa ESP32: Corrects timer initialization and timer input frequency.

This commit is contained in:
Gregory Nutt 2016-12-19 11:50:28 -06:00
parent a9a39800a4
commit 097f09cb02
2 changed files with 6 additions and 9 deletions

View File

@ -170,20 +170,15 @@ static int esp32_timerisr(int irq, uint32_t *regs)
void xtensa_timer_initialize(void) void xtensa_timer_initialize(void)
{ {
uint64_t divisor; uint32_t divisor;
uint32_t count; uint32_t count;
/* Configured the timer0 as the system timer. /* Configured the timer0 as the system timer.
* *
* divisor = BOARD_CLOCK_FREQUENCY / ticks_per_sec * divisor = BOARD_CLOCK_FREQUENCY / ticks_per_sec
* = BOARD_CLOCK_FREQUENCY / (ticks_per_usec * 1000000)
* = (1000000 * BOARD_CLOCK_FREQUENCY) / ticks_per_usec
*
* A long long calculation is used to preserve accuracy in all cases.
*/ */
divisor = (1000000ull * (uint64_t)BOARD_CLOCK_FREQUENCY) / CONFIG_USEC_PER_TICK; divisor = BOARD_CLOCK_FREQUENCY / CLOCKS_PER_SEC;
DEBUGASSERT(divisor <= UINT32_MAX);
g_tick_divisor = divisor; g_tick_divisor = divisor;
/* Set up periodic timer */ /* Set up periodic timer */

View File

@ -56,7 +56,9 @@
#if 0 #if 0
# define BOARD_CLOCK_FREQUENCY 80000000 # define BOARD_CLOCK_FREQUENCY 80000000
#else #else
# define BOARD_CLOCK_FREQUENCY BOARD_XTAL_FREQUENCY /* Hmmm... actually appears to be running at about 2 x the XTAL frequency */
# define BOARD_CLOCK_FREQUENCY (2 * BOARD_XTAL_FREQUENCY)
#endif #endif
#endif /* __CONFIGS_ESP32_CORE_INCLUDE_BOARD_H */ #endif /* __CONFIGS_ESP32_CORE_INCLUDE_BOARD_H */