load USART RX data into an array

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

I have a "frame" of about 52 bytes that I am sending into the USART Rx pin. I would like to read this in and load the data into an array that I could later grab from. Using USARTC0.DATA, how would I load the "frame" into an array this size?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
char frame[52];

for (i = 0; i < 52; i++) {

    while (~USARTC0.STATUS & USART_RXCIF_bm);

    frame[i] = USARTC0.DATA;

}

Gamu The Killer Narwhal
Portland, OR, US
_________________
Atmel Studio 6.2
Windows 8.1 Pro
Xplained boards mostly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You can do this using the DMA:
AVR1307

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You can also do this using a FIFO buffer that is found in ASF.

ISR(USARTC0_RXC_vect){

   switch(fifo_push_uint8_t(&fifo_rx_buffer, USARTC0.DATA)){
        case FIFO_OK:
          //Do something or not
          break;
        case FIFO_ERROR_OVERFLOW:
          //Do something or not
          break;
   }
}