如何使用CC2530的CSMA机制发送数据?
请问怎样使用csp实现CSMA? 在zigbee协议栈中,是通过下面的代码去实现,但是我移植出来后使用不了?
还有里面 的mac定时器2的 事件是怎么理解的 RFST = WEVENT1;
mac定时器2是需要怎样的初始化以及中断函数里面该处理什么?
是需要mac定时器2中的中断函数里面做什么设置之类的么?
还有里面的随机数值产生器需要进行怎样初始化以及怎样使用?
是否有csma的相关demo可以学习下?
void macCspTxPrepCsmaUnslotted(void)
{
cspPrepForTxProgram();
/*----------------------------------------------------------------------
* Load CSP program : Unslotted CSMA transmit
*/
/*
* Wait for X number of backoffs, then wait for intra-backoff count
* to reach value set for WEVENT1.
*/
RFST = WAITX;
RFST = WEVENT1;
/* wait for one backoff to guarantee receiver has been on at least that long */
RFST = WAITW(1);
RFST = WEVENT1;
/* sample CCA, if it fails exit from here, CSPZ indicates result */
RFST = SKIP(1, C_CCA_IS_VALID);
RFST = SSTOP;
/* CSMA has passed so transmit (actual frame starts one backoff from when strobe is sent) */
RFST = STXON;
/*
* Wait for the start of frame delimiter of the transmitted frame. If SFD happens to
* already be active when STXON is strobed, it gets forced low. How long this takes
* though, is not certain. For bulletproof operation, the first step is to wait
* until SFD is inactive (which should be very fast if even necessary), and then wait
* for it to go active.
*/
RFST = WHILE(C_SFD_IS_ACTIVE);
RFST = WHILE(C_SFD_IS_INACTIVE);
/*
* Record the timestamp. The INT instruction causes an interrupt to fire.
* The ISR for this interrupt records the timestamp (which was just captured
* when SFD went high).
*/
RFST = INT;
/*
* Wait for SFD to go inactive which is the end of transmit. Decrement CSPZ to indicate
* the transmit was successful.
*/
RFST = WHILE(C_SFD_IS_ACTIVE);
RFST = DECZ;
/*
* CC2530 requires SSTOP to generate CSP_STOP interrupt.
*/
RFST = SSTOP;
如果想把CSMA部分的程序从Z-stack剥离出来的话,难度相对比较大,涉及到的东西比较多。
推荐你去参考下SimpliciTI协议栈,ti官网上可以下载,然后你看下
uint8_t MRFI_Transmit(mrfiPacket_t * pPacket, uint8_t txType)这个发送函数,同样是基于CCA的,理解起来会比较方便
我们两好像遇到了同样的问题,加qq聊一聊吧,527061709
里面的CCA发送,是一个循环等待cca空闲就发送,是么?不是csma的吧? 没有csma的后退等待检测的操作
而且SimpliciTI协议 里面好像也没涉及到timer2 MAC定时器的, 我看cc2530的用户手册里面介绍的csma,是有用到timer2的,是这样的么?
我看了一下simpliciTi协议栈,里面用到了T3定时器,我也不知道为什么不是T2,随机退避部分是有的,用到了CC2530芯片里的随机数发生器。加q详谈吧
T2是专门用来做系统时钟用,SimplicTI只是一个简单的协议栈,没有用Timer2