EnviroDIY / Arduino-SDI-12

An Arduino library for SDI-12 communication with a wide variety of environmental sensors. This library provides a general software solution, without requiring any additional hardware.
https://github.com/EnviroDIY/Arduino-SDI-12/wiki
BSD 3-Clause "New" or "Revised" License
158 stars 99 forks source link

NRF52 Support #80

Open KevinUrrutia opened 3 years ago

KevinUrrutia commented 3 years ago

Hello, I was looking to add my Adafruit NRF52 bluefruit board and am having trouble setting up the timer registers. The NRF52 has a NRF_TIMER0 type definition where there are separate registers that set the prescaler, start the timer etc. But, the issue that I am having is that when I initialize the NRF_TIMER0 it does not begin to count and hangs in the comparison while loops such as the one in write char

while((uint32_t)(NRF_TIMER0_BASE) < txBitWidth) {}

This is an example of where the timer causes the code to hang.

This is how I initialize the timer

void SDI12::init_timer(void) {
  NRF_TIMER1->TASKS_STOP = 1;
  NRF_TIMER1->MODE = TIMER_MODE_MODE_Timer;
  NRF_TIMER1->BITMODE = (TIMER_BITMODE_BITMODE_24Bit << TIMER_BITMODE_BITMODE_Pos);
  NRF_TIMER1->PRESCALER = 0b00001011;

  NRF_TIMER1->TASKS_CLEAR = 1;
  NRF_TIMER1->CC[0] = TIMEOUT * 1000;

  NRF_TIMER1->INTENSET = TIMER_INTENSET_COMPARE0_Enabled << TIMER_INTENSET_COMPARE0_Pos;

  NRF_TIMER1->SHORTS = (TIMER_SHORTS_COMPARE0_CLEAR_Enabled << TIMER_SHORTS_COMPARE0_CLEAR_Pos);
  NRF_TIMER1->TASKS_START = 1;
}
SRGDamia1 commented 2 years ago

I'm sorry, I'm not at all familiar with the timers on any of the Nordic processors. Unfortunately, I probably won't be able to look into it any time soon.