Using Pic18F2221, this is the code for RX Xbee:
// RECEPTOR Zigbee code for mikroC Version: 7.0.0.3
//
//config WDT = OFF
//config LVP = OFF // Este bit debe estar desactivado para poder usar PORTA5
//config OSC = HSPLL
//config PWRT = ON //Power On timer enable
//——————————————–
// subrutina de inicializacion
void initialization (void)
{
LATA=0;
ADCON1=0x0f;
CMCON=0×07;
TRISA=0;
PORTA=0;
PORTB=0;
LATB=0;
TRISB=0;
PORTB=0;
LATC=0;
TRISC=0xc0;
PORTC=0;
}
//——————————————–
void main (void)
{
unsigned short i;
unsigned int counter=0;
initialization();
USART_init(2400);
porta.ra0= 1;
while(1){
if (Usart_Data_Ready()){
i = Usart_Read();
if (i==0×12){
counter++;
}
}
if (counter==0){
PORTB=0b10111110;
}
if (counter==1){
PORTB=0b00000110;
}
if (counter==2){
PORTB=0b01111100;
}
if (counter==3){
PORTB=0b01011110;
}
if (counter==4){
PORTB=0b11000110;
}
if (counter==5){
PORTB=0b11011010;
}
if (counter==6){
PORTB=0b11111010;
}
if (counter==7){
PORTB=0b00001110;
}
if (counter==8){
PORTB=0b11111110;
}
if (counter==9){
PORTB=0b11011110;
}
if (counter>9){
counter=0;
}
}
}
// end of file
=================================================================
Using Pic18F2221, this is the code for TX Xbee:
// Transmisor Zigbee code for mikroC Version: 7.0.0.3
//
//config WDT = OFF
//config LVP = OFF // Este bit debe estar desactivado para poder usar PORTA5
//config OSC = HSPLL
//config PWRT = ON //Power On timer enable
//——————————————–
// subrutina de inicializacion
void initialization (void)
{
LATA=0;
ADCON1=0x0f;
CMCON=0×07;
TRISA=0;
PORTA=0;
PORTB=0;
LATB=0;
TRISB=0;
PORTB=0;
LATC=0;
TRISC=0xc0;
PORTC=0;
}
//——————————————–
void main (void)
{
initialization();
USART_init(2400);
while(1){
porta = ~porta;
USART_Write(30);
Delay_ms(10000);
porta = ~porta;
USART_Write(31);
Delay_ms(10000);
porta = ~porta;
USART_Write(32);
Delay_ms(10000);
porta = ~porta;
USART_Write(33);
Delay_ms(10000);
porta = ~porta;
USART_Write(34);
Delay_ms(10000);
porta = ~porta;
USART_Write(35);
Delay_ms(10000);
porta = ~porta;
USART_Write(36);
Delay_ms(10000);
porta = ~porta;
USART_Write(37);
Delay_ms(10000);
porta = ~porta;
USART_Write(38);
Delay_ms(10000);
porta = ~porta;
USART_Write(39);
Delay_ms(10000);
porta = ~porta;
USART_Write(40);
Delay_ms(10000);
}
}
// end of file