From e09d95067c20d126c3d24886d41938186856f8dd Mon Sep 17 00:00:00 2001 From: Jerry Needell Date: Tue, 17 Apr 2018 21:46:15 -0400 Subject: [PATCH] update tick.c (fix LOAD value) update PulseIn.c (do not enable interrupts for trigger_duration > 1000 --- ports/atmel-samd/common-hal/pulseio/PulseIn.c | 5 +++-- ports/atmel-samd/tick.c | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/ports/atmel-samd/common-hal/pulseio/PulseIn.c b/ports/atmel-samd/common-hal/pulseio/PulseIn.c index bf6dfa8d58..0b551858c8 100644 --- a/ports/atmel-samd/common-hal/pulseio/PulseIn.c +++ b/ports/atmel-samd/common-hal/pulseio/PulseIn.c @@ -283,8 +283,9 @@ void common_hal_pulseio_pulsein_resume(pulseio_pulsein_obj_t* self, if (trigger_duration > 0) { gpio_set_pin_pull_mode(self->pin, GPIO_PULL_OFF); gpio_set_pin_direction(self->pin, GPIO_DIRECTION_OUT); - - common_hal_mcu_disable_interrupts(); + if(trigger_duration < 1000 ){ // only disable interrupts for < 1 ms + common_hal_mcu_disable_interrupts(); + } gpio_set_pin_level(self->pin, !self->idle_state); common_hal_mcu_delay_us((uint32_t)trigger_duration); gpio_set_pin_level(self->pin, self->idle_state); diff --git a/ports/atmel-samd/tick.c b/ports/atmel-samd/tick.c index 5c66df3cb0..9000be4740 100644 --- a/ports/atmel-samd/tick.c +++ b/ports/atmel-samd/tick.c @@ -52,7 +52,7 @@ void SysTick_Handler(void) { void tick_init() { uint32_t ticks_per_ms = common_hal_mcu_processor_get_frequency() / 1000; - SysTick_Config(ticks_per_ms); + SysTick_Config(ticks_per_ms-1); NVIC_EnableIRQ(SysTick_IRQn); }