使用UART配置BLE

⚠️
嗨,...感谢您来论坛。令人兴奋的消息!我们现在正在迁至我们的新论坛平台,将提供更好的功能,并包含在主对话框网站中。所有帖子和帐户都已迁移。我们现在只接受新论坛上的流量 - 请发布任何新线程https://www.dialog-seminile.com/support.。我们将在未来几天修复错误/优化搜索和标记。
9 posts / 0 new
最后一篇
Hamiddhosseini
离线
最后一次露面:5 months 1 week ago
加入:2020-05-12 12:04
使用UART配置BLE

你好呀,

我正在尝试使用UART与BLE并行。出于我的项目目的,无附庸术和DSP不适用,不可能做出足够的修改。因此,我决定在与BLE_APP_PERITIELALAL示例中使用示例项目中演示的UART功能。

据说,在导入所需的一些库之后并在BLE示例中启用DMA模式;我跟着这个powccess:

  • 订阅ADC值1时,我想每5秒开始读取数据。
void user_svc1_adc_val_1_cfg_ind_handler(ke_msg_id_t const msgs,struct custs1_val_write_ind const * param,ke_task_id_t const dest_id,ke_task_id_t const src_id){//在中央订阅时生成指示(param-> value [0]){printf_string(UART2,“用户已经订阅了ADC特征!\ n \ r“);sendrecsm_op();}}
  • I tried using different interupt modes:
ke_msg_id_t timer_used_SendRec_SM __SECTION_ZERO(“retention_mem_area0"); //@RETENTION MEMORY uart_t * uart = UART2; const int READ_CHAR_COUNT = 5; static char buffer_BLE[READ_CHAR_COUNT + 1]; volatile bool uart_receive_finished = false; volatile uint16_t data_received_cnt = 0; //Function Definitions void SendRecSM_op() { //blocking_receive_uart(); intr_receive_uart(); //dma_receive_uart(); app_easy_timer(500,uart_chk_buffer_cb); } static void uart_receive_cb(uint16_t length){ data_received_cnt = length; uart_receive_finished = true; } void dma_receive_uart(){ uart_receive_finished = false; data_received_cnt = 0; uart_register_rx_cb(uart, uart_receive_cb); //Time to ask for data! uart_receive(uart, (uint8_t *)buffer_BLE, READ_CHAR_COUNT, UART_OP_DMA); } void uart_chk_buffer_cb() { arch_printf("\n\rChecking the buffer!\n\r"); if (uart_receive_finished){ buffer_BLE[READ_CHAR_COUNT] = 0; // make it a null terminated string printf_string(uart,buffer_BLE); } } void intr_receive_uart(){ uart_receive_finished = false; data_received_cnt = 0; uart_register_rx_cb(uart, uart_receive_cb); //Time to ask for data! arch_printf("UART is in Interrupt mode!\n\r"); arch_printf("Please input the data!"); uart_receive(uart, (uint8_t *)buffer_BLE, READ_CHAR_COUNT, UART_OP_INTR); } void blocking_receive_uart(){ printf_string(uart,"UART is in Blocking mode!\n\r"); printf_string(uart,"Please input the data!"); uart_receive(uart, (uint8_t *)buffer_BLE, READ_CHAR_COUNT, UART_OP_BLOCKING); buffer_BLE[READ_CHAR_COUNT] = 0; // make it a null terminated string printf_string(uart,buffer_BLE); }

在阻止收到的情况下,我不使用计时器。但是,如果我不立即输入数据,则计划崩溃“而(!Uart_data_ready_getf(Uart_id));”命令in.“UART_READ_BYTE()”

In case of interrupted receives, I use the said timer. However, the program runs only once. In other words, it only prints“检查缓冲区!”and regardless of what I would do, everything would freeze.

  • 如果我坚持原始代码和使用“虽然(!recept_uart_finished);”由于代码相同的代码,程序管理程序将崩溃。

我想知道,我能做什么来解决这些问题?是否有一些我没有为UART配置的东西?有一个更好的方法吗?(除了使用无附带或DSP外,因为它们看起来非常难以修改)

关键词:
设备:
PM_DIALOG.
离线
最后一次露面:10小时36分钟前
职员
加入:2018-02-08 11:03
嗨Hamiddhosseini,

嗨Hamiddhosseini,

你能澄清你想要完成的事情吗?如果我理解正确,你只需要打印uart的消息?我的理解是否正确?您是否尝试使用Arch_PRNTF()API打印您的日期?

您使用的是哪个BLE示例?请注意如果您使用的任何可用睡眠模式,则关闭所有外设域(包括UART)。这意味着您不能在睡眠模式下具有任何UART活动。

谢谢,PM_DIALOG.

孙梦君
离线
最后一次露面:4周1日前
加入:2020-03-03 02:40
我有同样的问题和

我有同样的问题,并定义了arch_ leep_关。

在DA14585,SDK6.0.12中,BLE_APP_PERITERAL。

Hamiddhosseini
离线
最后一次露面:5 months 1 week ago
加入:2020-05-12 12:04
你好呀,

你好呀,

感谢您的回复,我在Ble_App_Perizalal示例上基于我的工作,我试图在这个例子中添加发送和接收数据通过UART。

现在,我已经设法解决了这个问题。现在我理解在此示例中不可能使用拦截模式。但是,我在编写中断和DMA模式时犯了一个小错误。

孙梦君
离线
最后一次露面:4周1日前
加入:2020-03-03 02:40
你是如何解决这个问题的

你是如何解决这个问题的?

Hamiddhosseini
离线
最后一次露面:5 months 1 week ago
加入:2020-05-12 12:04
所以,我的问题是

所以,我的问题是app_easy_timer. I had forgotten to call this function again inside the callback. Therefore, it would only run once. If you think you have the same problem, you can check one of the examples of using this function in the SDK.

PM_DIALOG.
离线
最后一次露面:10小时36分钟前
职员
加入:2018-02-08 11:03
Hi There,

Hi There,

我建议使用最新的SDK版本,该版本是SDK6.0.14。你能澄清你想要完成的事情,这样我都可以了解我如何帮助你吗?

谢谢,PM_DIALOG.

Hamiddhosseini
离线
最后一次露面:5 months 1 week ago
加入:2020-05-12 12:04
谢谢,我的问题得到解决

谢谢,我的问题现在已经解决了。如果需要澄清,我不知道这个问题的哪个部分模糊不清,请告诉我。

孙梦君
离线
最后一次露面:4周1日前
加入:2020-03-03 02:40
Thank you very much for your

Thank you very much for your reply. I will try this method.