spi_clk_divisor
时间:04-09
整理:3721RD
点击:
Hello friends,
i am working on rabbit 4000 with RF transceiver. i dont know how to connect RF transceiver to my module i.es what are the pins from the RF transceiver should be connected to my processor. my task is just transmitting one data to RF transceiver and get back the data what i hav transmitted by the same module!? am i correctly doing? can do both at a time? how to check whether my RF module transmitting a data as well as receiving the same data? i have connected RF transceiver's pins like mosi to output miso to input of my rcm4000. and Nss to my slave select, my Serial clock to SCK of RF transceiver, and all as well. so find me if i wrong. and give ur mail id for me ask some doubts pls. pls reply me as soon as possible. thanks in advance.
here i have attached my code. pls verify this and get back to me as soon as possible. /*PB7 acts as the CS line on the RF
PB0 is the serial B clock line(SCLK)
PC4 is the data output(MOSI)
PC5 is the data input(MISO)*/
//#define SPI_SER_A
#define SPI_SER_B
#define SPI_CLK_DIVISOR 5
#class static
#define DS2_BIT 2
#define DS3_BIT 3
#use "spi.lib"
#use RCM40xx.LIB
void main()
{
unsigned int i,j;
const int RF_writdata[2]={0,1}; //here is the input for RF transmitter.
int RF_readdata[2]; //this line for receiving data.
brdInit(); //to initilize the board
SPIinit(); //SPI initiliz
while(1)
{
// for(i=0;i<10;i++)
{
BitWrPortI(PBDR, &PBDRShadow,0,7); // SET CS LOW
}
//j=0;here may need 'for' loop. so look aftr smtime
//BitWrPortI(PBDR, &PBDRShadow,1, 7); //SET CS HIGH
for(j=0;j<2;j++)
for(i=0;i<8;i++)
{
SPIWrRd(RF_readdata[i],RF_writdata[i],3); //i send the data to RF txr.
}
BitWrPortI(PBDR, &PBDRShadow,1, 7); //SET CS HIGH
printf("\n\ntransmited value is %x %x", RF_writdata[0],RF_writdata[1]);
// BitWrPortI(PBDR, &PBDRShadow, 1, 7); //SET CS LOW
//j=1;
// for(i=0;i<4000;i++); //just for dalay
// for(i=0;i<4000;i++); //just for delay
// for(i=0;i<10;i++)
// {
// BitWrPortI(PBDR, &PBDRShadow, 1,7); //SET CS LOW
// }
// BitWrPortI(PBDR, &PBDRShadow, 0, 7); //SET CS HIGH
// SPIRead(RF_readdata,5); //here i am readin the output from RF Rx
// BitWrPortI(PBDR, &PBDRShadow, 0, 7); //SET CS LOW
printf("\n\nrecieved values are %c %c",RF_readdata[0],RF_readdata[1]);
//using the red datas from rf rx i am toggle the LED which connected with portB.
while(1)
{
BitWrPortI(PBDR, &PBDRShadow, RF_readdata[0], 2);
for(i=0;i<65351;i++);
BitWrPortI(PBDR, &PBDRShadow, RF_readdata[1], 2);
for(i=0;i<65351;i++);
BitWrPortI(PBDR, &PBDRShadow, RF_readdata[0], 3);
for(i=0;i<65351;i++);
BitWrPortI(PBDR, &PBDRShadow, RF_readdata[1], 3);
}//RF_readdata[0]=0;
//RF_readdata[1]=0;
}
}
i am working on rabbit 4000 with RF transceiver. i dont know how to connect RF transceiver to my module i.es what are the pins from the RF transceiver should be connected to my processor. my task is just transmitting one data to RF transceiver and get back the data what i hav transmitted by the same module!? am i correctly doing? can do both at a time? how to check whether my RF module transmitting a data as well as receiving the same data? i have connected RF transceiver's pins like mosi to output miso to input of my rcm4000. and Nss to my slave select, my Serial clock to SCK of RF transceiver, and all as well. so find me if i wrong. and give ur mail id for me ask some doubts pls. pls reply me as soon as possible. thanks in advance.
here i have attached my code. pls verify this and get back to me as soon as possible. /*PB7 acts as the CS line on the RF
PB0 is the serial B clock line(SCLK)
PC4 is the data output(MOSI)
PC5 is the data input(MISO)*/
//#define SPI_SER_A
#define SPI_SER_B
#define SPI_CLK_DIVISOR 5
#class static
#define DS2_BIT 2
#define DS3_BIT 3
#use "spi.lib"
#use RCM40xx.LIB
void main()
{
unsigned int i,j;
const int RF_writdata[2]={0,1}; //here is the input for RF transmitter.
int RF_readdata[2]; //this line for receiving data.
brdInit(); //to initilize the board
SPIinit(); //SPI initiliz
while(1)
{
// for(i=0;i<10;i++)
{
BitWrPortI(PBDR, &PBDRShadow,0,7); // SET CS LOW
}
//j=0;here may need 'for' loop. so look aftr smtime
//BitWrPortI(PBDR, &PBDRShadow,1, 7); //SET CS HIGH
for(j=0;j<2;j++)
for(i=0;i<8;i++)
{
SPIWrRd(RF_readdata[i],RF_writdata[i],3); //i send the data to RF txr.
}
BitWrPortI(PBDR, &PBDRShadow,1, 7); //SET CS HIGH
printf("\n\ntransmited value is %x %x", RF_writdata[0],RF_writdata[1]);
// BitWrPortI(PBDR, &PBDRShadow, 1, 7); //SET CS LOW
//j=1;
// for(i=0;i<4000;i++); //just for dalay
// for(i=0;i<4000;i++); //just for delay
// for(i=0;i<10;i++)
// {
// BitWrPortI(PBDR, &PBDRShadow, 1,7); //SET CS LOW
// }
// BitWrPortI(PBDR, &PBDRShadow, 0, 7); //SET CS HIGH
// SPIRead(RF_readdata,5); //here i am readin the output from RF Rx
// BitWrPortI(PBDR, &PBDRShadow, 0, 7); //SET CS LOW
printf("\n\nrecieved values are %c %c",RF_readdata[0],RF_readdata[1]);
//using the red datas from rf rx i am toggle the LED which connected with portB.
while(1)
{
BitWrPortI(PBDR, &PBDRShadow, RF_readdata[0], 2);
for(i=0;i<65351;i++);
BitWrPortI(PBDR, &PBDRShadow, RF_readdata[1], 2);
for(i=0;i<65351;i++);
BitWrPortI(PBDR, &PBDRShadow, RF_readdata[0], 3);
for(i=0;i<65351;i++);
BitWrPortI(PBDR, &PBDRShadow, RF_readdata[1], 3);
}//RF_readdata[0]=0;
//RF_readdata[1]=0;
}
}
