Precautions For Inter-core Data Transfer
the cache needs to be especially careful because it can cause your data to be accessed incorrectly. If core A needs to access the memory of core B, this section of core B memory needs to be careful if there is a cache, which is generally not recommended
SPI调试总结
SPI时序可能出现问题,需要用逻辑分析仪Kingst VIS或者示波器查看波形变化,为什么出现延时情况,读写寄存器为什么会出现这么大的时间延时。结果发现和系统调用有很大的关系,xxx.elf的进程在运行过程中采用的是默认的优先级配置的nice值默认为0,会出现被抢占的情况,所以整体的延时会出现60us的情况。正常情况下是7-8us.整个配置MMIC的时间。
知乎学习链接
https://www.zhihu.com/people/ljgibbs/posts
https://www.zhihu.com/people/lgjjeff
‘’’C
//tcp server,can reconnection and recv data from tcp client
#include <stdio.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
#define PORT 11011
#define IP_ADDR “192.168.30.60”
int main(){
int server_fd, client_fd;
struct sockaddr_in server_addr,client_addr;
// 创建 socket
server_fd = socket(AF_INET, SOCK_STREAM, 0);
if(server_fd < 0){
printf("Error creating socket!");
return 1;
}
// 设置地址与端口信息
server_addr.sin_family = AF_INET;
server_addr.sin_addr.s_addr = inet_addr(IP_ADDR);
server_addr.sin_port = htons(PORT);
// 绑定socket与地址信息
if(bind(server_fd, (struct sockaddr*)&server_addr, sizeof(server_addr)) < 0){
printf("Bind failed!");
return 1;
}
// 开始监听
if (listen(server_fd, 5) < 0){
printf("Listen failed!");
return 1;
}
while(1){
socklen_t client_len = sizeof(client_addr);
// 等待客户端连接请求
client_fd = accept(server_fd, (struct sockaddr*)&client_addr, &client_len);
if(client_fd < 0){
continue;
}
// 设置 client_fd 为非阻塞模式
fcntl(client_fd, F_SETFL, O_NONBLOCK);
while(1){
// 尝试接收数据
char buffer[1024];
int byte_num = recv(client_fd, buffer, 1024, 0);
// 连接已关闭
if(byte_num == 0){
close(client_fd);
break;
}
// 打印接收到的数据
//if(byte_num > 0){
// printf("Received data: %s", buffer);
//}
// 遍历缓冲区每个字节
for(int i=0; i < byte_num; i++) {
// 将字节转换为整数打印
printf("%x ", (int)buffer[i]);
}
printf("\n");
}
// 关闭客户端 socket
close(client_fd);
}
return 0;
}
‘’’