Code for maximum throughput in my case

Discussion in 'Embedded Systems and Microcontrollers' started by aamirali, Sep 22, 2014.

  1. aamirali

    Thread Starter Member

    Feb 2, 2012
    1. I have a application in which I have 30 inputs/30 outputs/4 adc & uart to send data to PC.

    Data send to PC continuously -> 30 input & 4 adc data (total 20 bytes with some header.
    Data receive from PC anytime -> 10 bytes (to set/reset outputs)

    I am using Atmega1280v , with 8Mhz crystal, Avrstudio 6.

    2. I need to achieve maximum throughput in the system i.e to send data at maximum rate to PC as possible/

    What I have done:
    1. Enable receive interrupt & set a global flag as soon as 10 byte user data is received. If global flag is set then receptin is disabled unless main clears it

    2. Read 30 input data & 4 adc data & send it to PC.

    3. Check if global recive flag is set, set/reset output & clear the flag to enable reception.

    4. Go to step 2./

    Is there any faster way to do it, my objective is to maximize throughput i.e send data at maximum rate as possible?
  2. elabsp

    New Member

    Oct 23, 2013
    try to increase ur serial baud rate
  3. Papabravo


    Feb 24, 2006
    It is not only receive interrupts that you need, but transmit interrupts as well. You need to implement FIFO queues, using circular buffers, on both receive and transmit and be able to demonstrate that you can send at or approaching the synchronous limit. Change your crystal to 7.3728 MHz so you have no error in deriving a higher baudrate like 115,200 bits per second. The sacrifice in instruction execution is small compared to the increase in baudrate with error free transmission and reception.