need help in RFID interfacing to 89c52
Tell us more about your application
i would like to use cc2500 as transceiver and used as slave with 89c52 need sent or receive data if it present on cc2500 and take that data in pic controller and need operate relays
#include <reg51.h>
#define Enable 1
#define Disable 0
void Tx_data ();
void Rx_data ();
void Inituart(void);
//---------------------------------------------------------------
//
//---------------------------------------------------------------
unsigned char Bdelay_us;
unsigned char Bdelay_ms;
unsigned char Btemp1;
unsigned char Btemp2;
unsigned char Bloop_a;
unsigned char Bdata_buffer;
unsigned char Bp_r_data;
unsigned char Btx_data1;
unsigned char Btx_data2;
unsigned char Btx_data3;
unsigned char Brx_data1;
unsigned char Brx_data2;
unsigned char Brx_data3;
unsigned char BRSSI;
unsigned char BCRC;
unsigned char BLed_counter;
union{
unsigned char byte;
struct{
unsigned char bit0:1;
unsigned char bit1:1;
unsigned char bit2:1;
unsigned char bit3:1;
unsigned char bit4:1;
unsigned char bit5:1;
unsigned char bit6:1;
unsigned char bit7:1;
}bits;
}Bflag1;
#define bCC2500_CC1100_recive_packet_ok Bflag1.bits.bit0
#define bMCU_timeout_flag Bflag1.bits.bit1
#define bCC2500_CC1100_interrupt_flag Bflag1.bits.bit2
//---------------------------------------------------------------
//
//---------------------------------------------------------------
#include "MCU.h"
#include "Chipcon.h"
void main()
{
while(1)
{
void Inituart(void);
Tx_data();
FDelay_ms(200);
Rx_data();
}
}
void Tx_data ()
{
FDelay_ms(50);
TL1=TIME_L_BYTE_4M;
TH1=TIME_H_BYTE_4M;
bMCU_timeout_flag=Disable;
Btx_data1=0x58;
Btx_data2=0x39;
Btx_data3=BLed_counter;
FRF_CC2500_CC1100_transmit_packet_data();
bCC2500_CC1100_interrupt_flag=Disable;
INT0=1;
FCC2500_CC1100_receive_mode();
while((bCC2500_CC1100_interrupt_flag==Disable)&&(b MCU_timeout_flag==Disable));
bCC2500_CC1100_recive_packet_ok_flag=Disable;
if(bCC2500_CC1100_interrupt_flag==Enable)
{
FRF_Interrupt_CC2500_CC1100_rx_data();
}
FCC2500_CC1100_idle_mode();
FCC2500_CC1100_clear_rx_fifo();
FCC2500_CC1100_sleep_mode();
if(bCC2500_CC1100_recive_packet_ok_flag==Enable)
{
if(Brx_data1==0x58)
{
if(Brx_data2==0x39)
{
FDelay_ms(500);
P1=0xFF;
}
}
}
}
void Rx_data()
{
FMCU_Initial();
FPower_on_reset_CC2500_CC1100();
FCC2500_CC1100_Initial_all_registers();
FCC2500_CC1100_Initial_PA_table();
FCC2500_CC1100_clear_rx_fifo();
FCC2500_CC1100_clear_tx_fifo();
FCC2500_CC1100_frequency_calibration();
FDelay_4us(200);
bCC2500_CC1100_interrupt_flag=Disable;
INT0=1;
FCC2500_CC1100_receive_mode();
while(1)
{
if(bCC2500_CC1100_interrupt_flag==Enable)
{
bCC2500_CC1100_recive_packet_ok_flag=Disable;
FRF_Interrupt_CC2500_CC1100_rx_data();
FCC2500_CC1100_clear_rx_fifo();
if(bCC2500_CC1100_recive_packet_ok_flag==Enable)
{
if(Brx_data1==0x58)
{
if(Brx_data2==0x39)
{
Btx_data1=0x58;
Btx_data2=0x39;
Btx_data3=Brx_data3;
FRF_CC2500_CC1100_transmit_packet_data();
FDelay_ms(20);
P1=0xff; }
}
}
bCC2500_CC1100_interrupt_flag=Disable;
INT0=1;
FCC2500_CC1100_receive_mode();
}
}
}
void Inituart(void)
{
TMOD = 0x20; //timer1 working mode 1
TL1 = 0xfd; //f7=9600 for 16mhz Fosc,and ...
TH1 = 0xfd; //...fd=19200 for 11.0592mhz Fosc
SCON = 0xd8; //uart mode 3,ren==1
PCON = 0x80; //smod=0
TR1 = 1; //start timer1
}
this is my code but it doesnt working is there any modification or correction needed please help me
interfacing RFID 相关文章:
- Wireless in-line switch interfacing lora technology
- doubt in interfacing wireless sensors
- interfacing zigbee module with zigbee-modbus gateway
- Sim 100 GSM Module interfacing
- Variation in the sensitivity of the receiver with interfacing
- RF transceiver nRF2401 interfacing with the PIC micro controller 16f877A
