TI中文支持网
TI专业的中文技术问题搜集分享网站

cc1110 接收数据接收一个数据包后,就不能继续接收,停在while (!RFTXRXIF);代码如下

/***********************************************************************************
Filename: comlab_09_19_11_868_smartrfcc1110.c

Description:
HW:
smartrfccxx10 Green LED: HAL_LED_SET_1() HAL_LED_CLR_1() HAL_LED_TGL_1()
Red LED: HAL_LED_SET_2() HAL_LED_CLR_2() HAL_LED_TGL_2()
S1: HAL_BUTTON_1_PUSHED()
S2: HAL_BUTTON_2_PUSHED()

srf04_soc Green LED: HAL_LED_SET_1() HAL_LED_CLR_1() HAL_LED_TGL_1()
Yellow LED: HAL_LED_SET_3() HAL_LED_CLR_3() HAL_LED_TGL_3()
S1: HAL_BUTTON_1_PUSHED()
Joystick: HAL_JOYSTICK_PUSHED()
HAL_JOYSTICK_UP()
HAL_JOYSTICK_DOWN()
HAL_JOYSTICK_LEFT()
HAL_JOYSTICK_RIGHT()
LCD: void halLcdWriteLine(uint8 line, const char* text)

srf04_tranciever Green LED: HAL_LED_SET_1() HAL_LED_CLR_1() HAL_LED_TGL_1()
Red LED: HAL_LED_SET_2() HAL_LED_CLR_2() HAL_LED_TGL_2()
Yellow LED: HAL_LED_SET_3() HAL_LED_CLR_3() HAL_LED_TGL_3()
Blue LED: HAL_LED_SET_4() HAL_LED_CLR_4() HAL_LED_TGL_4()
S1: HAL_BUTTON_1_PUSHED()
Joystick: HAL_JOYSTICK_PUSHED()
HAL_JOYSTICK_UP()
HAL_JOYSTICK_DOWN()
HAL_JOYSTICK_LEFT()
HAL_JOYSTICK_RIGHT()
LCD: void halLcdWriteLine(uint8 line, const char* text)

***********************************************************************************/

/***********************************************************************************
* INCLUDES
*/
#include "hal_types.h"
#include "ioCCxx10_bitdef.h"
#include "hal_mcu.h"
#include "hal_board.h"
#include "stdlib.h"
#include<stdio.h>

extern void initUARTtest(void);

/***********************************************************************************
* CONSTANTS
*/
#define N 4//17
#define SRX 0x02
#define STX 0x03
#define SIDLE 0x04
/***********************************************************************************
* LOCAL VARIABLES
*/
uint8 txBuffer[N + 1];
//uint8 rxBuffer[N + 3];
uint8 rxBuffer[N];
char asciiString[11];
uint32 packetsSent;
uint32 packetsReceived;

/***********************************************************************************
* @fn main
*
* @brief Describe what the function is doing
*
* @param none
*
* @return 0
*/
void main(void) {
uint8 length,i,j;

// Initialize board
halBoardInit();
initUARTtest(); // Modulated = true // Carrier frequency = 868.299866 // Sync word qualifier mode = 16/16 sync word bits detected // Preamble count = 3
// Packet length mode = Variable packet length mode. Packet length configured by the first byte after sync word // PA ramping = false // Address config = No address check // Channel number = 0 // Manchester enable = false // CRC enable = true // Whitening = false // TX power = 0 // RX filter BW = 58.035714 // Data rate = 1.19948 // Packet length = 12
// Base frequency = 868.299866 // Channel spacing = 199.951172 // Modulation format = 2-FSK // Device address = 0 // Deviation = 5.157471
SYNC1 = 0x2D;
SYNC0 = 0xD4;
PKTLEN = N; // 数据包长
PKTCTRL1 = 0x00; // Packet automation control.
PKTCTRL0 = 0x00; // 固定包长.包的自动化控制
FSCTRL1 = 0x08;//0x08; // Frequency synthesizer control.
// FSCTRL0 = 0x00; // Frequency synthesizer control.
//ADDR = 0x00; // Device address.
FREQ2 = 0x21; // 频率, high byte.
FREQ1 = 0x65; // Frequency control word, middle byte.
FREQ0 = 0x6A; // Frequency control word, low byte.
MDMCFG4 = 0x66; // Modem configuration.
MDMCFG3 = 0x83; // Modem configuration.
MDMCFG2 = 0x02; // 发送模式 同步字配置
MDMCFG1 = 0x12; // 3个前导码
MDMCFG0 = 0xF8; // Modem configuration. DEVIATN = 0x51; // Modem deviation setting (when FSK modulation is enabled).
//MCSM2 = 0x07; // Main Radio Control State Machine configuration.
//MCSM1 = 0x1F; // Main Radio Control State Machine configuration. MCSM0 = 0x18; // Main Radio Control State Machine configuration.
FOCCFG = 0x1D; // 频偏补偿配置
FSCAL3 = 0xE9; // 频率合成器校准
FSCAL2 = 0x2A; // Frequency synthesizer calibration.
FSCAL1 = 0x00; // Frequency synthesizer calibration.
FSCAL0 = 0x1F; // Frequency synthesizer calibration.
TEST2 = 0x88; // Various test settings.
TEST1 = 0x31; // Various test settings.
TEST0 = 0x09; // Various test settings.
//CHANNR = 0x00; // Channel number.
//BSCFG = 0x1C; //位同步配置

//AGCCTRL2 = 0xC7; // AGC control.
//AGCCTRL1 = 0x00; // AGC control.
//AGCCTRL0 = 0xB2; // AGC control.
//FREND1 = 0xB6; // 前端接收配置
//FREND0 = 0x10; // Front end RX configuration. PA_TABLE0 = 0x50; // PA output power setting.
RFIF = 0;// RF 中断标志
RFTXRXIF = 0;

#ifdef RX
RFST = SRX; while (TRUE) {
//while (!RFTXRXIF);
// RFTXRXIF = 0;
//length = RFD;
//rxBuffer[0] = length;
// for (uint8 j = 1; j <= length + 2; j++) {
for (uint8 j = 0; j <= 3; j++) {
while (!RFTXRXIF);
RFTXRXIF = 0;
rxBuffer[j] = RFD;
} for(i=0;i<3;i++)
{
//rfdata[i]=radioPktBuffer[i];
printf("%x",rxBuffer[i]);
}
if(rxBuffer[length + 2] & 0x80) {
HAL_LED_TGL_1();
}
}
#endif
#ifdef TX
while (TRUE) {
// Create TX Packet
txBuffer[0] = N;
for (uint8 i = 1; i <= N; i++)
txBuffer[i] = i;
RFST = STX;
while (!RFTXRXIF);
RFTXRXIF = 0;
RFD = txBuffer[0];
for (uint8 m = 1; m <= N; m++) {
while (!RFTXRXIF); RFTXRXIF = 0;
RFD = txBuffer[m];
} while ((RFIF & 0x10) == 0); // Wait for IRQ_DONE
RFIF &= ~0x10;
RFTXRXIF = 0;
HAL_LED_TGL_2();
}
#endif

}

readlove1 readlove1:

回复 Susan Yang:

 Susan Yang,您好!你发的程序,是用DMA的方式,我需要用非DMA的方式来实现,现在遇到的问题就是RFTXRXIF 不产生。能收到一组数据包后就不再置1了。我这个代码也是在http://e2e.ti.com/上找的。不知道是不是非DMA的方式无法实现接收,官方例程也没有非DMA的例子。

赞(0)
未经允许不得转载:TI中文支持网 » cc1110 接收数据接收一个数据包后,就不能继续接收,停在while (!RFTXRXIF);代码如下
分享到: 更多 (0)