16F690 and USART problem with a xbee

Thread Starter

n2o3l4p

Joined Apr 22, 2010
3
Hi all, I am using mikroC pro and the documentation example on how to communicate via USART with a PIC16F690 connected to a 802.15.4 xbee.

The xbee is working great and it receives signals via radio communications.. the problem is the pic is not responding. It cannot even see that data is arrived.

The pic is connected with a pull-up resistor between mclr pin and Vdd (5V), the xbee is at 3.3V so there's a resistive partitor (10k/18k) between pic Tx and xbee Rx pins (to avoid damage xbee module)

Tx of the pic is linked at Rx of the xbee, and Rx of the pic is linked at Tx of the xbee with the partitor.

There's a led on RB6 I use to check whether this code works:


Rich (BB code):
char  uart_rd;

void main() {

// Light up RB6, RB5 digital input
   TRISB = 0b00100000;
  PORTB.F6 = 0;
  
  UART1_Init(9600);               // Initialize UART module at 9600 bps
  Delay_ms(100);                  // Wait for UART module to stabilize

  while (1) {                     // Endless loop
   if (UART1_Data_Ready()) {     // If  data is received,
     uart_rd = UART1_Read();     //   read the  received data,
     UART1_Write(uart_rd);       //   and send data  via UART
     if(PORTB.F6)
        PORTB.F6 = 0;
      else
         PORTB.F6 = 1;
        Delay_ms(1000);
    }
  }
}

But till now, the led never switched off...

I tried to send all kind of data via xbee... pic cannot see it. Led won't switch off. Baud rate is correct.

Configuration bits for pic:CONFIG :$2007 : 0x03F4
alias INTERNAL RC NO CLOCK + MASTER CLEAR ENABLE EXTERNAL + BOD ENABLED / SBOREN DISABLED


Someone can help please?
 

t06afre

Joined May 11, 2009
5,934
I do not know your compiler. But in order to calculate correct transmission speed it has to know your current CPU clock speed. Have given the compiler this information? It is 4 MHz by default in the PIC16f690 with internal RC i think. I would also have turned the watchdog timer OFF.
Have you read about the UART in the datasheet?
 

Thread Starter

n2o3l4p

Joined Apr 22, 2010
3
Read the datasheet but cannot get one point: is there a specific clock setting for my pic to communicate with the EUSART technology?

It should not I think
 

t06afre

Joined May 11, 2009
5,934
Is your problem receiving or transmitting data? In all cases I would have used the debugger in MPLAB and checked all registers related to serial transmission. In my data sheet this is summed up in table 12.1,12.2,12.5 Check and double check the register content against expected values
 
Last edited:
Top