CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Zigbee

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
sam6154



Joined: 17 Feb 2014
Posts: 2
Location: Chennai

View user's profile Send private message

Zigbee
PostPosted: Mon Feb 17, 2014 1:26 am     Reply with quote

i haven't worked with zigbee till now hence i am in need of guidance for interfacing cc2530 and pic16f877a.
Thanks in advance.
temtronic



Joined: 01 Jul 2010
Posts: 9246
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon Feb 17, 2014 8:31 am     Reply with quote

cc2530 is a 3 volt device
16f877a is an 'old' device

do you have a cc2530 chip or premade module?
If module, post link to datasheet
If chip, I'm out as it's a very,very complicated SMT device needing a LOT of very,very careful PCB layout and connections.

Zigbee ,if run in AT(aka 'transparent') mode , is easy,but slow.


hth
jay
Zloi



Joined: 26 Oct 2012
Posts: 11
Location: Croatia

View user's profile Send private message

Re: Zigbee
PostPosted: Mon Feb 17, 2014 12:44 pm     Reply with quote

sam6154 wrote:
i haven't worked with zigbee till now hence i am in need of guidance for interfacing cc2530 and pic16f877a.
Thanks in advance.


Read the "CC2530ZNP Interface Specification.pdf", as mentioned keep an eye on voltage levels.
You need to to load cc2530 module with TI ZNP firmware (ZNP zigbee network processor), then decide on interface you are going to use to communicate with PIC mcu, (UART or SPI) and finaly,
write your own C PIC drivers.
I worked with SPI interface, here is code snippet.

Code:



void ZNP_Sys_Version(void){
   for(i=0;i<=ZNP_Data_Array_Size;i++){
   Data[i]=0;
   }
      printf(bputc,"PIC -> ZNP System verzion information\n\r");
      ZNP_Write[0]=0x00;
      ZNP_Write[1]=0x21;
      ZNP_Write[2]=0x02;
      ZNP_Send_Command(ZNP_Write,3);
}

void ZNP_Clear_Device(void){
   for(i=0;i<=ZNP_Data_Array_Size;i++){
   Data[i]=0;
   }
      printf(bputc,"PIC -> ZNP Clear Device on Reset\n\r");
      ZNP_Write[0]=0x03;
      ZNP_Write[1]=0x26;
      ZNP_Write[2]=0x05;
      ZNP_Write[3]=0x03;
      ZNP_Write[4]=0x01;
      ZNP_Write[5]=0x03;   //Clear device on reset
      ZNP_Send_Command(ZNP_Write,6);
}


void ZNP_Write_Logical_Type(unsigned int8 type){
   for(i=0;i<=ZNP_Data_Array_Size;i++){
   Data[i]=0;
   }
      if(type==0x00){
         printf(bputc,"PIC -> ZNP logical type Coordinator\n\r");
      }else if(type==0x01){
         printf(bputc,"PIC -> ZNP logical type Router\n\r");
      }else if(type==0x02){
         printf(bputc,"PIC -> ZNP logical type End Device\n\r");
      }
      ZNP_Write[0]=0x03;
      ZNP_Write[1]=0x26;
      ZNP_Write[2]=0x05;
      ZNP_Write[3]=0x87;
      ZNP_Write[4]=0x01;
      ZNP_Write[5]=type;
      ZNP_Send_Command(ZNP_Write,6);
}

void ZNP_Write_PAN_ID(unsigned int8 b1,unsigned int8 b2){
   for(i=0;i<=ZNP_Data_Array_Size;i++){
   Data[i]=0;
   }
      printf(bputc,"PIC -> ZNP Write Pan ID %X%X\n\r",b1,b2);
      ZNP_Write[0]=0x04;
      ZNP_Write[1]=0x26;
      ZNP_Write[2]=0x05;
      ZNP_Write[3]=0x83;
      ZNP_Write[4]=0x02;
      ZNP_Write[5]=b1;
      ZNP_Write[6]=b2;
      ZNP_Send_Command(ZNP_Write,7);
}

void ZNP_Write_Channel(unsigned int8 b1,unsigned int8 b2,unsigned int8 b3,unsigned int8 b4 ){
   for(i=0;i<=ZNP_Data_Array_Size;i++){
   Data[i]=0;
   }
      printf(bputc,"PIC -> ZNP Write Channel %X%X%X%X\n\r",b4,b3,b2,b1);
      ZNP_Write[0]=0x06;
      ZNP_Write[1]=0x26;
      ZNP_Write[2]=0x05;
      ZNP_Write[3]=0x84;
      ZNP_Write[4]=0x04;
      ZNP_Write[5]=b1;   //Clear device on reset
      ZNP_Write[6]=b2;
      ZNP_Write[7]=b3;
      ZNP_Write[8]=b4;
      ZNP_Send_Command(ZNP_Write,9);
}


void ZNP_Soft_Reset(void){
   for(i=0;i<=ZNP_Data_Array_Size;i++){
   Data[i]=0;
   }

      printf(bputc,"PIC -> ZNP Device Soft Reset\n\r");
      ZNP_Write[0]=0x01;
      ZNP_Write[1]=0x41;
      ZNP_Write[2]=0x00;
      ZNP_Write[3]=0x00;
      ZNP_Send_AREQ(ZNP_Write,4);
}


void ZNP_ZB_APP_Register(void){
   for(i=0;i<=ZNP_Data_Array_Size;i++){
   Data[i]=0;
   }

      printf(bputc,"PIC -> ZNP APP Register\n\r");
      ZNP_Write[0]=0x0D;
      ZNP_Write[1]=0x26;
      ZNP_Write[2]=0x0A;
      ZNP_Write[3]=0x01;   //App end point
      ZNP_Write[4]=0x01;   //App profile ID0
      ZNP_Write[5]=0x01;   //App profile ID1
      ZNP_Write[6]=0X01;   //Device id0
      ZNP_Write[7]=0x01;   //devide id1
      ZNP_Write[8]=0x00;   //device verzion
      ZNP_Write[9]=0x00;   // unused
      ZNP_Write[10]=0x01;   //input comands num
      ZNP_Write[11]=0x00;   // input comands list 0
      ZNP_Write[12]=0x01;   // input comands list 1
      ZNP_Write[13]=0x01;   // output comands num
      ZNP_Write[14]=0x00;   //output comands list 0
      ZNP_Write[15]=0X01;   // output comands list 1
      ZNP_Send_Command(ZNP_Write,16);
}

void   ZNP_ZB_Start_Request(void){
   for(i=0;i<=ZNP_Data_Array_Size;i++){
   Data[i]=0;
   }
      printf(bputc,"PIC -> ZNP Start Request\n\r");
      ZNP_Write[0]=0x00;
      ZNP_Write[1]=0x26;
      ZNP_Write[2]=0x00;
      ZNP_Send_Command(ZNP_Write,3);
}

void    ZNP_Set_Tx_Power(unsigned int8 b1){
   for(i=0;i<=ZNP_Data_Array_Size;i++){
   Data[i]=0;
   }
      printf(bputc,"PIC -> ZNP Set Tx Power\n\r");
      ZNP_Write[0]=0x01;
      ZNP_Write[1]=0x21;
      ZNP_Write[2]=0x14;
      ZNP_Write[3]=b1;                                                        //set tx power to 20dBm
      ZNP_Send_Command(ZNP_Write,4);
}


void    ZNP_Get_Device_IEEE(void){
   for(i=0;i<=ZNP_Data_Array_Size;i++){
   Data[i]=0;
   }
      printf(bputc,"PIC -> ZNP Get_Device_IEEE\n\r");
      ZNP_Write[0]=0x01;
      ZNP_Write[1]=0x26;
      ZNP_Write[2]=0x06;
      ZNP_Write[3]=0x01;                                                        //set tx power to 20dBm
      ZNP_Send_Command(ZNP_Write,4);
}

void ZNP_Get_Device_Info(void){
   for(i=0;i<=ZNP_Data_Array_Size;i++){
   Data[i]=0;
   }
      printf(bputc,"PIC -> ZNP Get_Device_Info\n\r");
      ZNP_Write[0]=0x01;
      ZNP_Write[1]=0x26;
      ZNP_Write[2]=0x06;
      ZNP_Write[3]=0x00;                                                        //set tx power to 20dBm
      ZNP_Send_Command(ZNP_Write,4);
}

void Bord_Data(char *str,unsigned int8 len){
   for(i=0;i<=ZNP_Data_Array_Size;i++){
   Data[i]=0;
   }

   unsigned int8 k=1;

      printf(bputc,"du?ina = %d\n\r",len);
      printf(bputc,"PC -> BoarData\n\r");
      ZNP_Write[1]=0x26;
      ZNP_Write[2]=0x03;
      ZNP_Write[3]=0xFC;    //destination id0
      ZNP_Write[4]=0xFF;    //destination id1
      ZNP_Write[5]=0x00;    //command id0
      ZNP_Write[6]=0x00;    //command id1
      ZNP_Write[7]=0x00;    //handle
      ZNP_Write[8]=0x00;    //ack
      ZNP_Write[9]=0x03;    //radius
      ZNP_Write[10]=len;      //len of data
      while(len--){            //znp se javio, po?alji mu podatak
      ZNP_Write[10+k]=*str++;
      k++;
      }
      k=1;
      ZNP_Write[0]=ZNP_Write[10]+8; //Data dio plus fiksni dio
      for(k=0;k<=ZNP_Write[0]+2;k++){
       printf(bputc,"%X",ZNP_Write[k]);
      }
       printf(bputc,"\n\r");
      //ZNP_Send_Command(ZNP_Write,16);
}




void ZNP_Send_Command(char *pMsg, unsigned int8 len){
   output_low(MRDY_ZNP);      //Select ZNP
   while(input(SRDY_ZNP)){
   }   //Cekaj Da se znp javi

   while(len--){            //znp se javio, po?alji mu podatak
      spi_write(*pMsg++);
   }
   while(!input(SRDY_ZNP)){
   }
 //  delay_cycles (2);
   Data[0]=spi_read(0);
   Data[1]=spi_read(0);
   Data[2]=spi_read(0);
   for(i=0;i<=Data[0];i++){
      Data[i+3]=spi_read(0);
   }
   ZNP_SetDataReady();
   output_high(MRDY_ZNP);   //DeSelect ZNP
}


void ZNP_Send_AREQ(char *pMsg, unsigned int8 len){
   output_low(MRDY_ZNP);      //Select ZNP
   while(input(SRDY_ZNP)){};   //Cekaj Da se znp javi
 //  delay_cycles (2);
   while(len--){            //znp se javio, po?alji mu podatak
      spi_write(*pMsg++);
   }
   while(!input(SRDY_ZNP)){};
   output_high(MRDY_ZNP);   //DeSelect ZNP
}
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group