Hello,
I'm using nRF5 SDK with version 15 and nRF52832 IC. I want to sample some data with 3200Hz sampling rate. I can set the timer minimum 1ms Which means 1000Hz. How can I adjust the Timer for microSecond values.
Best Regards
Hello,
I'm using nRF5 SDK with version 15 and nRF52832 IC. I want to sample some data with 3200Hz sampling rate. I can set the timer minimum 1ms Which means 1000Hz. How can I adjust the Timer for microSecond values.
Best Regards
I assume you are referring to the app timer. The app timer uses ISRs to accomplish its task. There is no realistic way to execute microsecond ISRs on a 64MHz processor.
If you need to sample data at microsecond intervals you will need to use ppi/gpiote to execute that and likely DMA to handle the data.
Can you give me an example code about How to do it with ppi/gpiote ?
I am also using the SoftDevice.
I do not see a reference in your code for timer_led. You should post the entire main.c
Plus it would be better for you to start with my example. Your approach requires the gpio driver and an ISR to work. Both of these require much more code execution.
I can only share some parts of my code
void timer_led_event_handler(nrf_timer_event_t event_type, void* p_context) { switch (event_type) { case NRF_TIMER_EVENT_COMPARE0: { nrf_gpio_pin_toggle(17); } break; default: //Do nothing. break; } } static void TimerInit1(void) { nrf_drv_timer_config_t timer_cfg = NRF_DRV_TIMER_DEFAULT_CONFIG; err_code = nrf_drv_timer_init(&TIMER_LED, &timer_cfg, timer_led_event_handler); APP_ERROR_CHECK(err_code); time_ticks = nrf_drv_timer_ms_to_ticks(&TIMER_LED, time_ms); nrf_drv_timer_extended_compare(&TIMER_LED, NRF_TIMER_CC_CHANNEL0, time_ticks, NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK, true); nrf_drv_timer_enable(&TIMER_LED); }
Are you using the soft device?
Yes, I am using the SoftDevice.
Well no ISR approach will work for you anyway when using the SD. As I pointed out above, you cannot do this with an ISR while using the SD. Please re-read my prior response.
Since you can only do it completely in hardware ie, ppi/gpiote there will not likely be an example specific to your needs. Also, you will have to give a lot more information about the source and type of data for anyone to help.
Well no ISR approach will work for you anyway when using the SD. As I pointed out above, you cannot do this with an ISR while using the SD. Please re-read my prior response.
Since you can only do it completely in hardware ie, ppi/gpiote there will not likely be an example specific to your needs. Also, you will have to give a lot more information about the source and type of data for anyone to help.
I want to sample some data with 3200Hz sampling rate from SPI interface. There is an accelerometer connected via SPI interface.
How do I need to configure the ppi ?
Much better and specific! You should repost this using the question you just gave "I want to sample some data with 3200Hz sampling rate from SPI interface. There is an accelerometer connected via SPI interface." add to it this "I am also using the softdevice."
I have done a lot with ppi/gpiote but I haven't used SPI for anything on this device and wouldn't want to waste your time.
According to the devzone there is support for SPI with DMA and the data transfers can be triggered by timer events so I think you are in good shape to solve it. Essentially the SPI/DMA transfer will happen in hardware behind the scenes and you will just use the processor on the nRF to pick up an array from memory at a much slower pace. It can handle the data in slower chunks but not at 3200Hz.
I just remembered that the ioT Thingy has an accelerometer on it. All the source code for it is posted on the nordic site. It uses nRF52832. You should be able to easily repurpose the code if you don't get a quick response on your new post.