[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avrdude-dev] [patch #7010] Win32 enhanced bitbang_delay
From: |
Doug |
Subject: |
[avrdude-dev] [patch #7010] Win32 enhanced bitbang_delay |
Date: |
Wed, 02 Dec 2009 09:37:41 +0000 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/532.0 (KHTML, like Gecko) Chrome/3.0.195.33 Safari/532.0 |
URL:
<http://savannah.nongnu.org/patch/?7010>
Summary: Win32 enhanced bitbang_delay
Project: AVR Downloader/UploaDEr
Submitted by: dougy83
Submitted on: Wed 02 Dec 2009 09:37:40 AM GMT
Category: None
Priority: 5 - Normal
Status: None
Privacy: Public
Assigned to: None
Originator Email:
Open/Closed: Open
Discussion Lock: Any
_______________________________________________________
Details:
I read that the bitbang_delay is not calibrated for Win32 so I wrote the
following code. It uses the performance counters which are high accuracy
hardware counters (3.6MHz on my 5 yr old laptop). If the counters are not
available, it falls back to the uncalibrated delay method. Seems to have a
~3us overhead on my laptop.
void bitbang_delay(int us)
{
#if defined(WIN32NATIVE)
static LARGE_INTEGER freq;
static enum {eNotInit, eInitOK, eInitFail}freqInit = eNotInit;
if(freqInit == eNotInit)
{
if(!QueryPerformanceFrequency(&freq))
freqInit = eInitFail; // perf counters not available
else
freqInit = eInitOK;
}
if(freqInit == eInitOK)
{
LARGE_INTEGER countNow, countEnd;
QueryPerformanceCounter(&countNow);
countEnd.QuadPart = countNow.QuadPart + freq.QuadPart * us / 1000000ll;
while (countNow.QuadPart < countEnd.QuadPart)
QueryPerformanceCounter(&countNow);
}
else // no performance counters -- run normal uncalibrated delay
{
volatile int del = us * delay_decrement;
while (del > 0)
del--;
}
#else
volatile int del = us * delay_decrement;
while (del > 0)
del--;
#endif /* WIN32NATIVE */
}
_______________________________________________________
Reply to this item at:
<http://savannah.nongnu.org/patch/?7010>
_______________________________________________
Message sent via/by Savannah
http://savannah.nongnu.org/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [avrdude-dev] [patch #7010] Win32 enhanced bitbang_delay,
Doug <=