Hi, i work on a cc2530 chip and i have few problem with my zigbee communication.
I can not transmit a data between two module.
I was inspired of this website : prog3.com/.../9897695
And my code is:
#include <CC2510.H> //----------------------------------------------------------------------------- // Global Constants //----------------------------------------------------------------------------- #define FRMFILT0 XREG( 0x6180 ) #define FREQCTRL XREG( 0x618F ) #define TXPOWER XREG( 0x6190 ) #define CCACTRL0 XREG( 0x6196 ) #define FSCAL1 XREG( 0x61AE ) #define TXFILTCFG XREG(0x61FA) #define AGCCTRL1 XREG(0x61B2) #define AGCCTRL2 XREG(0x61B3) #define RFIRQM0 XREG(0x61A3) #define FSMSTAT1 XREG(0x6193) //----------------------------------------------------------------------------- // Global VARIABLES //----------------------------------------------------------------------------- // Function PROTOTYPES //----------------------------------------------------------------------------- void PORT_Init (void); void sendUart(char mot); void serial_IT(void); void Rf_send (char*pbuf, int len); void RF_ERR(void); void RF_GEN(void); //----------------------------------------------------------------------------- // MAIN Routine //----------------------------------------------------------------------------- void main (void) { PORT_Init(); Rf_send('A',1); } //----------------------------------------------------------------------------- // PORT_Init //----------------------------------------------------------------------------- // void PORT_Init (void) { P0INP = 0x00; //Port 0 Input Mode P1INP = 0x00; //Port 1 Input Mode P2INP = 0x00; //Port 2 Input Mode P0SEL = 0x0C; //Port 0 Function Select, P02 et P03 Uart0 P1SEL = 0x00; //Port 1 Function Select P2SEL = 0x00; //Port 2 Function Select P0DIR = 0x04; //Port 0 Direction,P02 en output(TX) P1DIR = 0x13; //Port 1 Direction, p10,P11,p14 en output P2DIR = 0x00; //Port 2 Direction P0 = 0x00; P1 = 0x00; P2 = 0x00; U0CSR |= 0x80;//Uart 0 control r0x86, enable UART mode U0BAUD = 0xEF;//USART 0 Baud Rate Control, BAUD_M //augmenté un peu pour obtenir la bonne valeur U0GCR = 0x09;//USART 0 Generic Control, BAUD_E URX0IE = 1;//USART0 RX Interrupt Enable U0CSR |= 0x40; //init rf FRMFILT0 =0x0C; // static receiving filter, which receives all packets TXPOWER =0xD5; // transmitting power is 1dBm FREQCTRL =0x0B; // select channel 11 CCACTRL0 =0xF8; // smartRF software to generate the recommended value //READ seaction 23.15.1 p 259, c'est recommandé de faire ça FSCAL1 = 0x00; TXFILTCFG = 0x09; AGCCTRL1 = 0x15; AGCCTRL2 = 0xFE; TXFILTCFG = 0x09; RFIRQM0 |= (1<<6); // RF data packet receiving interrupt enable IEN2 |= (1<<0); // RF interrupt enable RFST =0xED; // remove RF receive buffer ISFLUSHRX RFST =0xE3; // RF receiver enable ISRXON EA = 1; //global interruption } void sendUart(char mot) { U0DBUF = mot; } void serial_IT(void) interrupt 2 { char mot; P1 = 0x13; mot = U0DBUF; sendUart(mot);//echo } //----------------------------------------------------------------------------- // RF Error Interrupt Service Routine (ISR) //----------------------------------------------------------------------------- // void RF_ERR (void) interrupt 0 { P1 = 0x01; } //----------------------------------------------------------------------------- // RF generail Interrupt Service Routine (ISR) //----------------------------------------------------------------------------- // void RF_GEN (void) interrupt 16 { EA =0; P1 = 0x02; // receives a complete packet if (RFIF&0x40 == 1) //flag reception bit 7 sur 8. { //P1 = 0x13; //(rf_receive_isr); // call receiving interrupt handling function S1CON =0; // clear interrupt flag RFIF =RFIF & 0xBF ; // RF after receiving the packet interrupt clear } EA =1; } void Rf_send (char*pbuf, int len) { int i = 0; RFST =0xE3; // RF receiver enable ISRXON //The state is not active and waiting to send / not receiving SFD while (FSMSTAT1 & (1<<1)==1); while (FSMSTAT1 & (1<<5)==1); RFIRQM0 &=~ (1<<6); // prohibit receiving data packet interrupt IEN2 &=~ (1<<0); // remove RF global interrupt RFST =0xEE; // clear ISFLUSHTX send buffer RFIRQF1 = RFIRQF1 & ~(1 << 1); // filling the buffer filling process need to add 2 bytes, CRC check automatic filling RFD = len+2; for (i=0;i<len; i++) { RFD=*pbuf++; } RFST =0xE9; // send packet ISTXON while(RFIRQF1 & 0x02 == 0);// wait for sent RFIRQF1 = RFIRQF1 & ~(1 << 1); // clear to send complete flag RFIRQM0 |= (1<<6); // RX interrupt reception IEN2 |= (1<<0); }
I have no interruption on the receiver but the transmitter seems to send correctly.
Have you an idea of a solution?
Sorry for my bad english, i'm french.