16F690 and USART problem with a xbee

Discussion in 'Embedded Systems and Microcontrollers' started by n2o3l4p, Apr 22, 2010.

  1. n2o3l4p

    Thread Starter New Member

    Apr 22, 2010
    3
    0
    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:


    Code ( (Unknown Language)):
    1. char  uart_rd;
    2.  
    3. void main() {
    4.  
    5. // Light up RB6, RB5 digital input
    6.    TRISB = 0b00100000;
    7.   PORTB.F6 = 0;
    8.  
    9.   UART1_Init(9600);               // Initialize UART module at 9600 bps
    10.   Delay_ms(100);                  // Wait for UART module to stabilize
    11.  
    12.   while (1) {                     // Endless loop
    13.    if (UART1_Data_Ready()) {     // If  data is received,
    14.      uart_rd = UART1_Read();     //   read the  received data,
    15.      UART1_Write(uart_rd);       //   and send data  via UART
    16.      if(PORTB.F6)
    17.         PORTB.F6 = 0;
    18.       else
    19.          PORTB.F6 = 1;
    20.         Delay_ms(1000);
    21.     }
    22.   }
    23. }
    24.  

    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?
     
  2. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    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?
     
  3. n2o3l4p

    Thread Starter New Member

    Apr 22, 2010
    3
    0
    I suppose so, 4Mhz was indicated in the mikroC compiler and baud rate was set in the code
     
  4. n2o3l4p

    Thread Starter New Member

    Apr 22, 2010
    3
    0
    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
     
  5. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    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: Apr 26, 2010
Loading...