Hi Dialog,
我们的产品是盲人的障碍物检测。要升级到基于BLE的设备,我们选择DA14531模块。
组件是超声波传感器,蜂鸣器,触觉振动器,电池。
I'm trying to interface the following Ultrasonic sensor 400 S/T R 100. To generate 40 KHz burst of pulses, I configured timer 0 without PWM. I created a counter inside ISR of timer to generate transmission pulse. which I did it successfully(Refer attachment). Now after a delay of 1ms inside ISR , I'm calling adc_get_sample() function. From there I determine distance based on ultrasonic sensor principle. After running few iterations in keil debug mode .It got stuck in
static inline void dlg_error_isr(void)
{
ASSERT_WARNING(0);
}
in rwble.cThe project which is choose is BLE Barbone project. I have attached Trigger pulse generated with echo I got when obstacle is placed at 50 cm. As you can see the time interval is 3ms when coverted to distance is approx 51 cm. I have series of queries to implement this in code,
1. I'm not able to read ADC sample inside ISR.
2. What is the accuracy of your ADC ? w.r.to precision in milli voltage.
3.甚至when I run an ISR without any above functionality, I'm not able to connect to BLE scanner app.
Timer Configuration
// Enable the Timer0/Timer2 input clock
timer0_2_clk_enable();
timer0_init(TIM0_CLK_FAST, PWM_MODE_ONE, TIM0_CLK_NO_DIV);
// Set the Timer0/Timer2 input clock division factor to 2, so8 MHz输入时钟
timer0_2_clk_div_set(&clk_div_config);
// reload value for 12.5 micro second(T = 1/8 MHz * RELOAD_12.5_US = 0.125 * 100 = 12.5 micro second)
timer0_set_pwm_on_counter(TIMER_ON);
timer0_set_pwm_high_counter(NO_PWM);
timer0_set_pwm_low_counter(no_pwm);
// register callback function for SWTIM_IRQn irq
timer0_register_callback(burst_user_callback_function);
// enable SWTIM_IRQn irq
timer0_enable_irq();
ADC配置
// adc configuration
adc_offset_calibrate(ADC_INPUT_MODE_SINGLE_ENDED);
adc_config_t echo_pin_cfg =
{
.input_mode = ADC_INPUT_MODE_SINGLE_ENDED,
.input = ADC_INPUT_SE_P0_6,
.smpl_time_mult = 2,
.continuous = false,
.interval_mult = 0,
.Input_attenuator = ADC_INPUT_ATTN_4X,
.chopping = false,
.oversampling = 0
};
adc_init(&echo_pin_cfg);
Could you assist me in integrating this sensor. I need to know how can I run a Timer ISR and BLE service at same time ?
问候,
BALAJI
嗨巴拉吉,
Thanks for your question online. Let me check it and I’ll get back to you with my comments.
Thanks, PM_Dialog
嗨巴拉吉,
I am trying to replicate this behavior in the ble-app_barebone example of the SDK. So far I am using in order to toggle a gpio in the callback function:
Please let me know if I have any misconfiguration. Could you please share the burst_user_callback_function() function that you are using in your application code?
您应该能够在ISR内读取。请分享应在BLE_APP_BAREBONE示例中复制此操作以进行操作。您是否使用了任何可用的睡眠模式?
The accuracy of the ADC is given into the datasheet – please check Table 23.
Thanks, PM_Dialog
Hi Dialog,
Its actually a timer latency problem. I read Adc_smple inside12.5微秒ISR计时器,但是,当我检查MDO时adc_get_sample() API与修正60微秒。截至目前没有任何情况。谢谢你的建议。如果出现任何问题,我将将来在同一主题中发布。
Bcoz of this timer issue the BLE connection got blocked. Now its resolved.
嗨巴拉吉,
谢谢你的迹象,很高兴你有工作。如果您有任何后续问题,请提出一个新的论坛线程。
Thanks, PM_Dialog