text: hello all, I'm trying to send and receive a string through an XBEE module, but all I am getting is the XBEE sample data which means that the string is not being transferred. My code is as follows, (please bear in mind that I am new to mechatronics), any ideas ? I am using the AT32UC3C2512 which is why i can't use the data direction registers commands (DDRB, UDR0, ... )
  #include <asf.h>
  int main (void)
  {
  uint8_t tx_buf[] = "\n\rHHHH";
  uint8_t tx_length = 6;
  uint8_t received_byte;
  uint8_t i;
  const gpio_map_t USART_GPIO_MAP =
  {
  #if defined(AVR32_USART3)
  {83, 5},
  {84, 5},
  {82, 5},
  {117, 0},
  #endif
  };
  const usart_options_t USART_OPTIONS =
  {
  .baudrate = 9600,
  .channelmode = USART_NORMAL_CHMODE,
  .charlength = 8,
  .paritytype = USART_NO_PARITY,
  .stopbits = USART_1_STOPBIT,
  };
  board_init();
  sysclk_init();
  gpio_enable_module(USART_GPIO_MAP,
  sizeof(USART_GPIO_MAP) / sizeof(USART_GPIO_MAP[0]));
  usart_init_rs232(&XBEE_USART, &USART_OPTIONS, sysclk_get_main_hz());
  for (i=0; i<tx_length; i++)
  {
  usart_putchar(&XBEE_USART, tx_buf[i]);
  }
  while (true)
  {
  received_byte = usart_getchar(&XBEE_USART);
  if (received_byte == '\r') {
  for (i = 0; i < tx_length; i++) {
  usart_putchar(&XBEE_USART, tx_buf[i]);
  }
  } else
  usart_putchar(&XBEE_USART, received_byte);
  }
  }
  Thanks.
  What is an AT32UC3C2512 ?
  Did you try to send a string to your PC (via an USB serial adapter)? -1rst thing to be done, for any UC : usb_serila adapters and PC terminals are work , if you do not see on the terminal what you want to send, there is already an issue....
  Top
  - Log in or register to post comments
  Split and moved to UC3 forum.
  John Samperi
  Ampertronics Pty. Ltd.
  * Electronic Design * Custom Products * Contract Assembly
  Top
  - Log in or register to post comments
  Actually, that's something that you need to bear in mind.
  When you are new to something, you need to begin with the basics, and work up from there - rather than jump straight in over your head!
  As dbrion0606 says, you really need to be sure that you have basic wired serial comms fully understood and working before adding the complexity of radios ...
  See the "Getting Started" tips & resources here:...
  Top
  - Log in or register to post comments
  What is "... the XBEE sample data ..." ?
  Where does that sample data appear ?, (at the other end, or in your variable received_byte ?)
  I assume that XBEE_USART is #defined to be AVR32_USART3
  It is a 'good idea' to check that usart_init_rs232(,,) returns USART_SUCCESS
  Top
  - Log in or register to post comments
  hani I have deleted your other posts as you requested, please keep everything here from now on regarding this topic.
  John Samperi
  Ampertronics Pty. Ltd.
  * Electronic Design * Custom Products * Contract Assembly
  Top
  - Log in or register to post comments
  I have used dozens of XBEE modules and i never have heard about or have seen Sample Data. XBEE modules out of the box are simple serial to rf modules. You can take two of them out of the box and have comms between two PCs or microcontrollers at 9600 baud in minutes.
  Can you post a schematic of how all of this is connected?
  Are you sure you are communicating at 9600?
  Just thought of something....if you sent three "###" to the module it will switch to command mode. What are you sending to the XBEE?
  Which model XBEE? There is the standard unit and the one that has a micro on help, I changed the router from API mode to AT, also redefined the packetization timout RO as 0 and it worked fine !
  I also re-wrote the code as follows
  Top
  - Log in or register to post comments
  Will do, thanks !
  Top
  - Log in or register to post comments