完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛|
发送端代码:
int main(void) { int data[12]={0}; RIE_Responses RIE_Response = RIE_Success; WdtGo(T3CON_ENABLE_DIS); //uart-----start Urt_Init(UART_BAUD_19200); Urt_PinSetup(FALSE); printf("**************************rn"); printf("rn TX发送端初始化完成 rn"); printf("**************************rn"); //uart-----end // Initialise the Radio if (RIE_Response == RIE_Success) RIE_Response = RadioInit(DR_38_4kbps_Dev19_2kpbs); // Set the Frequency to operate at 915 MHz if (RIE_Response == RIE_Success) RIE_Response = RadioSetFrequency(915000000); // Set the PA and Power Level if (RIE_Response == RIE_Success) RIE_Response = RadioTxSetPA(DifferentialPA,PowerLevel15); if (RIE_Response == RIE_Success) RIE_Response = RadioTxPacketFixedLen(12, "HELLO WORLD"); printf("n输入要发送的数据:"); while (1) { Delay1(); RadioTxPacketFixedLen(12, "hello 123456"); } } 接收端代码: int main(void) { unsigned char Buffer[0x20]; RIE_U8 PktLen; RIE_S8 RSSI; RIE_U8 flag=0; RIE_Responses RIE_Response = RIE_Success; WdtGo(T3CON_ENABLE_DIS); //---------------UART code start--------------------- Urt_Init(UART_BAUD_19200); Urt_PinSetup(FALSE); printf("rn**************************rn"); printf("rn RX接收端初始化完成!nr"); printf("rn**************************rn"); //-----------------UART code end--------------------- // Initialise the Radio if (RIE_Response == RIE_Success) RIE_Response = RadioInit(DR_38_4kbps_Dev19_2kpbs); // Set the Frequency to operate at 915 MHz if (RIE_Response == RIE_Success) RIE_Response = RadioSetFrequency(915000000); if (RIE_Response == RIE_Success) RIE_Response = RadioRxPacketFixedLen(12); printf("nr正在接收数据nr"); if (RIE_Response == RIE_Success) { while (!RadioRxPacketAvailable()); } if (RIE_Response == RIE_Success) RIE_Response = RadioRxPacketRead(sizeof(Buffer), &PktLen, Buffer, &RSSI); if (RIE_Response == RIE_Success) printf("nr-> %s @ RSSI %d",Buffer,(int)RSSI); else printf("nr-> ERROR"); while(1) { //-------------接收数据---------------- RIE_Response = RadioRxPacketFixedLen(12); if (RIE_Response == RIE_Success) { while (!RadioRxPacketAvailable()); } if (RIE_Response == RIE_Success) RIE_Response = RadioRxPacketRead(sizeof(Buffer), &PktLen, Buffer, &RSSI); //-------------------------------------- printf("nr收到的数据:%s RSSI:%d",Buffer,(int)RSSI); } } 发送端和接收端的代码如上所附,通信时通信距离只有十几厘米,是不是有需要 注意的地方我没有注意到,期待解答。 |
|
相关推荐
1个回答
|
|
|
|
|
只有小组成员才能发言,加入小组>>
寻求ADF5355类似的微波源,在DC-15GHz内,锁频时间在1ms内
1788 浏览 0 评论
1630 浏览 0 评论
999 浏览 0 评论
1101 浏览 0 评论
ADF5355失锁: 在用ADF5355进行多次扫频时,延时给了500ms还是经常会失锁
1189 浏览 0 评论
ADC3442采集,分析数据出现有规则毛刺,请问是哪方面的问题啊?
2845浏览 3评论
2087浏览 2评论
给ADUM4223 增加信号驱动15V电压就不正常, 波动很大会被烧是什么情况?
2120浏览 2评论
1174浏览 2评论
使用ADI官方提供的no-OS來接收GPS L1(1575.42MHz)的資料
1405浏览 1评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-2 16:51 , Processed in 0.730402 second(s), Total 72, Slave 55 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
1623