Hi all,
I am working on a wireless project which establishes a wireless connection using CC2510. I am having a CC2510 mini development board with me. I have written a code for a transmitter which will continously send a character. In the another module i have written a code for receiver which will receive the character that the transmitter is sending.
The problem is the receiver is not displaying the correct character. Also it is always entering the receiver overflow condition. So please anyone check the code and suggest me any changes that the recever should not enter the overflow condition and correct character is displayed
/****************** CODE FOR RECEIVING A CONTINUOUS CHARACTER *********************/
#include<ioCC2510.h>
#include<ioCCxx10_bitdef.h>
#include<hal_cc8051.h>
#include<hal_types.h>
#include<hal_defs.h>
#define PKT_LENGTH 3
#define DEVICE_ADDRESS 0x01
#define DESTINATION_ADDRESS 0x00
unsigned char ch;
unsigned int i=0,j=0,k=0,l=0;
void send(unsigned char );
#pragma vector=RF_VECTOR
__interrupt void rf_interrupts(void)
{
if(RFIF&RFIF_IRQ_SFD)
{
RFIF&=~RFIF_IRQ_SFD;
i++;
}
if(RFIF&RFIF_IRQ_RXOVF)
{
RFIF&=~RFIF_IRQ_RXOVF;
RFST=RFST_SIDLE;
RFST=RFST_SRX;
j++;
}
}
#pragma vector=RFTXRX_VECTOR
__interrupt void rftxrxif_interrupt(void)
{
ch=RFD;
send(ch);
RFTXRXIF=0;
k++;
}
void main(void)
{
P1SEL=0xFC; /*selects the port to work as either general purpose or peripheral*/
PERCFG=0x01;/*making the USART0 to operate as UART 0 with alternate 2*/
CLKCON=0x00;
SLEEP&=~SLEEP_OSC_PD;
while(!(SLEEP&SLEEP_XOSC_S));
SLEEP|=SLEEP_OSC_PD;
U0BAUD=131;/*setting the baud rate*/
U0GCR=0x08; /*setting the baud rate*/
U0CSR|=U0CSR_MODE;/*making the USART0 to operate in UART mode*/
/* RF settings SoC */
FSCTRL1 = 0x0A; // Frequency Synthesizer Control
FSCTRL0 = 0x00; // Frequency Synthesizer Control
FREQ2 = 0x5D; // Frequency Control Word, High Byte
FREQ1 = 0x44; // Frequency Control Word, Middle Byte
FREQ0 = 0xEC; // Frequency Control Word, Low Byte
MDMCFG4 = 0x28; // Modem configuration
MDMCFG3 = 0x83; // Modem Configuration
MDMCFG2 = 0x03; // Modem Configuration
MDMCFG1 = 0x23; // Modem Configuration
MDMCFG0 = 0x3B; // Modem Configuration
CHANNR = 0x00; // Channel Number
DEVIATN = 0x00; // Modem Deviation Setting
FREND1 = 0xB6; // Front End RX Configuration
FREND0 = 0x10; // Front End TX Configuration
MCSM0 = 0x14; // Main Radio Control State Machine Configuration
FOCCFG = 0x1D; // Frequency Offset Compensation Configuration
BSCFG = 0x1C; // Bit Synchronization Configuration
AGCCTRL2 = 0xC7; // AGC Control
AGCCTRL1 = 0x00; // AGC Control
AGCCTRL0 = 0xB2; // AGC Control
FSCAL3 = 0xA9; // Frequency Synthesizer Calibration
FSCAL2 = 0x0A; // Frequency Synthesizer Calibration
FSCAL1 = 0x00; // Frequency Synthesizer Calibration
FSCAL0 = 0x11; // Frequency Synthesizer Calibration
TEST2 = 0x81; // Various Test Settings
TEST1 = 0x35; // Various Test Settings
TEST0 = 0x0B; // Various Test Settings
PA_TABLE0 = 0xFE; // PA Power Setting
PKTCTRL1 = 0x04; // Packet Automation Control
PKTCTRL0 = 0x45; // Packet Automation Control
ADDR = DEVICE_ADDRESS; // Device Address
PKTLEN = 0xFF; // Packet Length
MCSM2 = 0x07;
MCSM1 = 0x32;
IEN0 = 0x81;
IEN2 = 0x01;
RFIM = 0xFF;
SYNC0 = 0xAA;
SYNC1 = 0xAA;
RFST=RFST_SRX;
while(1)
{
while((MARCSTATE&MARCSTATE_MARC_STATE)!=MARC_STATE_RX)
{
asm("NOP");
asm("NOP");
}
}
}
void send(unsigned char c)
{
U0DBUF=c;
while(!(U0CSR&U0CSR_TX_BYTE));
U0CSR&=~U0CSR_TX_BYTE;
l++;
}
Thanks & Regards
N S S Sandeep