> I am trying to transfer 256 bytes of at data 1M baud rate from my PC to a= n Atmega328 > microcontroller. I am using checksum to verify the integrity of the data = and I am > emptying the received data into a ring buffer as quickly as possible. Thi= s is all I > have in my interrupt subroutine: > temp =3D UDR0; > BufferWrite(&rx_buffer,&temp); > The data is transferred properly only at speeds upto 250K baud rate. It r= esults in > error beyond that point. The Atmega 328 datasheet specifies that it possi= ble to > transfer at speeds upto 2M baud rate. The ring buffer size is about 400 b= ytes and I > am looking for some suggestions to achieve higher baud rates while mainta= ining the > data integrity. > Sai Use assembler instead of C? At that rate I suspect you should write the interrupt routine in assembler,= and use a highly optimised ring buffer architecture where you need to upda= te only the write pointer, and then the read routine works out how full the= buffer is by taking the difference between the write and read pointers. It= is possible to do this in a manner that doesn't involve race conditions on= the pointers. I presume the UART can buffer more than one character. Immediately before l= eaving the interrupt routine I would check to see if there is another chara= cter ready to be read instead of incurring the overhead of register restore= and save before getting the next character. --=20 Scanned by iCritical. --=20 http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .