计算CC2500信道的一段小程序(FCC 兼容)
日期: 2012-07-26 作者: Gamepader 分类: 手柄 标签: 2.4G, Network, 单片机, 程序设计 评论: 2 超过201人围观
最近在做一个RF模块测试架,其中一个功能是根据输入的频率来检测当前频率的丢包率(PER)和误码率(BER). 本来想直接做成输入信道号,但是后来一想,还是考虑一下做UI的童鞋的感受吧,于是写了一个小函数进行频率到信道的转换。 为了在MCU上测试不出问题,先来验证一下我的简单算法,就有了下面这段c语言程序:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | #include "Stdio.h" #include "Conio.h" int main(void) { unsigned long a; unsigned char channel; printf("This is a demo to calculat CC2500's data.\r\n"); printf("Input Frequency, Output Channel Number.\r\n"); printf("Base=2.402GHz,Space=333.2519kHz,DataRate:249.939kHz\r\n"); printf("So,Let's start!\r\n\r\n"); while(1) { printf("Press 'q' to exit,Other key to continue\r\n\r\n"); if(getch()!='q') { /* 此处添加代码 */ printf("Input (RF_FREQ-2,400,000)(kHz)= "); scanf("%ld",&a); channel=(a-2000)/333;/*333@2.402*/ printf("Channel= %u\r\n",channel); } else { for(channel=20;channel;--channel) { printf("%d ",channel); } getch(); return 0; } } } |
代码在TC2.0环境下测试通过,下载地址在这里(freq2channel.c,685Bytes),Windows平台下编译好的exe文件在这里(freq2channel.exe,12.5KB)。
原创文章,转载请注明来自//www.gamepader.com/archives/2012/07/a-fcc-compatible-code-to-calculat-channel-of-cc2500.html
本文链接:https://blog.gamepader.com/2012/07/a-fcc-compatible-code-to-calculat-channel-of-cc2500.html本文分类:
>>手柄
除特别标注,本站所有文章均为原创、转载请注明出处。
-- EOF -- ,Leave a msg~~ ^_^
亲,原创文章哦