[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-gcc-list] Fine Tuning code timings

From: Alex Shepherd
Subject: [avr-gcc-list] Fine Tuning code timings
Date: Sun, 23 Dec 2007 20:16:45 +1300

Hi Guys,

I'm trying to fine tune some C code timing issues for a software UART
written in AVRGCC.

Essentially when I go to transmit a byte, I capture the value of Timer1, set
the output compare value to the current timer value + the bit period,
activate the Tx pin and then wait for the interrupt handler to output the
rest of the bits in the byte.

The problem I'm having is that the latency between the timer interrupt
firing and the code in the interrupt handler that drives the pin state is
causing some error. I need some way to calculate the amount of time to
reduce the initial timer period by so that the pin state driving logic in
the interrupt handler executes at the right time. 

What I would like to try and find out (and why I'm asking on this list):

Is there any way to figure out using compiler tricks/magic how far into a
function or interrupt handler a line of code is so that I can use this
offset value to tune the initial start-bit timer value. The subsequent bit
timings are ok as they are generated using the same code path?

I have experimented using LABELS in the code and trying to do pointer
arithmetic but they don't seem to be accessible outside the function or I
was just doing it wrong. 

Merry Christmas

Alex Shepherd

reply via email to

[Prev in Thread] Current Thread [Next in Thread]