当前位置: 首页 > news >正文

pico 的两个双核相关函数的延时问题

pico高级API函数中,
multicore_fifo_pop_timeout_us 和  multicore_fifo_push_timeout_us 的延时参数,
如修改为500微秒以上时,其延时似乎远远超过设定值,其反馈速度似乎被主核的交互所左右 ,而修改为200以下时,反馈出现阶越:运行这两个函数 的core1的打印速度快速增加,显示其延时更加与设定值相符。

测试的代码:

#include <stdio.h>
#include "pico/stdlib.h"#include "pico/multicore.h"
#define FLAG_VALUE 2void core1_entry() {uint32_t g=0;
bool ifthereisp=false;
uint64_t timeout_u=500;   //这儿修改为500微秒以上时,core1的打印速度和core0 1hz基本同步 ,而修改为200以下时,反馈出现阶越:core1的打印速度快速增加。
uint32_t out;lable2:multicore_fifo_push_timeout_us ( FLAG_VALUE,timeout_u) ;if( !multicore_fifo_pop_timeout_us (timeout_u,&out) )printf("Hmm, that's not right on core 1!\n");elseprintf("Its all gone well on core 1! %u  \n",out);
goto lable2;while (1)tight_loop_contents();
}int main() {stdio_init_all();sleep_ms(1000);
printf("Hello, fakeone\n");sleep_ms(1000);multicore_launch_core1(core1_entry);uint32_t g=0;// Wait for it to start up
lable:g = multicore_fifo_pop_blocking();if (g != FLAG_VALUE)printf("Hmm, that's not right on core 0!\n");else {multicore_fifo_push_blocking(FLAG_VALUE);printf("It's all gone well on core 0!\n");}
sleep_ms(1000);
goto lable;while (true) {printf("Hello, world!\n");sleep_ms(1000);}return 0;
}

关键函数介绍官方原文:

bool multicore_fifo_pop_timeout_us     (     uint64_t      timeout_us,
        uint32_t *      out
    )         

Pop data from the read FIFO (data from the other core) with timeout.

This function will block until there is data ready to be read or the timeout is reached

See the note in the fifo section for considerations regarding use of the inter-core FIFOs
Parameters

timeout_us     the timeout in microseconds
out     the location to store the popped data if available
Returns

true if the data was popped and a value copied into out, false if the timeout occurred before data could be popped


bool multicore_fifo_push_timeout_us     (     uint32_t      data,
        uint64_t      timeout_us
    )         

Push data on to the write FIFO (data to the other core) with timeout.

This function will block until there is space for the data to be sent or the timeout is reached
Parameters

data     A 32 bit value to push on to the FIFO
timeout_us     the timeout in microseconds
Returns

true if the data was pushed, false if the timeout occurred before data could be pushed

附pico例程原代码:


#include <stdio.h>
#include "pico/stdlib.h"
#include "pico/multicore.h"#define FLAG_VALUE 123void core1_entry() {multicore_fifo_push_blocking(FLAG_VALUE);uint32_t g = multicore_fifo_pop_blocking();if (g != FLAG_VALUE)printf("Hmm, that's not right on core 1!\n");elseprintf("Its all gone well on core 1!");while (1)tight_loop_contents();
}int main() {stdio_init_all();printf("Hello, multicore!\n");multicore_launch_core1(core1_entry);// Wait for it to start upuint32_t g = multicore_fifo_pop_blocking();if (g != FLAG_VALUE)printf("Hmm, that's not right on core 0!\n");else {multicore_fifo_push_blocking(FLAG_VALUE);printf("It's all gone well on core 0!");}}

http://www.lryc.cn/news/70130.html

相关文章:

  • Doxygen源码分析: QCString类依赖的qstr系列C函数浅析
  • 华为OD机试之一种字符串压缩表示的解压(Java源码)
  • Microsoft Project Online部署方案
  • 飞浆AI studio人工智能课程学习(3)-在具体场景下优化Prompt
  • 企业工程行业管理系统源码-专业的工程管理软件-提供一站式服务
  • Ehcache 整合Spring 使用页面、对象缓存
  • Spring Cloud中的服务路由与负载均衡
  • rails routes的使用
  • Linux基础内容(21)—— 进程消息队列和信号量
  • STM32实现基于RS485的简单的Modbus协议
  • springboot服务端接口公网远程调试 - 实现HTTP服务监听【端口映射】
  • zabbix监控之javasnmp自定义监控
  • Inertial Explorer处理pospac数据总结
  • tps和qps的区别是什么?怎么理解
  • 【Java系列】深入解析枚举类型
  • 网络原理(五):IP 协议
  • MySQL---空间索引、验证索引、索引特点、索引原理
  • 选择合适的 MQTT 云服务:一文了解 EMQX Cloud Serverless、Dedicated 与 BYOC 版本
  • uvc驱动ioctl分析下
  • 数据库可视化神器,你在用哪一款呢
  • CMD与DOS脚本编程【第三章】
  • 多激光雷达手眼标定
  • SQL执行过程
  • K8S 部署 seata
  • ClickHouse:(二)数据类型
  • 项目文档(request页面代码逻辑)
  • 后端传到前端的JSON数据大写变小写--2023
  • 学习【菜鸟教程】【C++ 类 对象】【C++ 类的静态成员】
  • 计算机四大件笔记
  • 【vue上传文件——hash】