Page 1 of 1
AVR-Doper HID mode problem
Posted: Sun Jul 29, 2007 9:52 am
by ahulap
I have build simplified version of AVR-Doper and it works in serial port mode, but in HID mode avrdude can't connect to programmer:
avrdude.EXE: avrdoper_open(): Device not found.
HID device with VID=0x16C0 PID=0x05DF is present and windows says, that it is OK.
PS: how to post files here? I want to post my version of board...
Posted: Mon Jul 30, 2007 4:29 pm
by christian
Can you compile avrdude yourself and enable debug logs in ser_avrdoper.c by defining the macro USB_DEBUG?
I can't think of any reason why avrdude should not find the device, except maybe if you have registered another driver, maybe libusb-win32 for the VID/PID combination. Can you verify that?
Posted: Mon Jul 30, 2007 7:27 pm
by ahulap
I have tested bootloadHID with this hardware and it is works! So, i think, it is alright with HID mode.
I'm using avrdude 5.3.1 from WinAVR-20070525 package (also tryed from WinAVR-20070122). Now i will download cygwin and try to build avrdude myself...
Posted: Tue Jul 31, 2007 7:23 pm
by ahulap
It is something with avrdude from WinAVR package. I have downloaded avrdude.exe (from some user post at avrdude homepage) and it's works. Strange...
Posted: Fri Aug 10, 2007 7:50 pm
by juergens
I had the same problems. My solution was to try a newer version of avrdude. I found the following precompiled win32-binary
http://yuki-lab.jp/hw/avrdude-GUI/avrdu ... 32-bin.zip
there are 3 obvious differences:
* newer version (WinAVR-20070525 installs 5.3.1)
* the newer binary is a debug-version (2MB size versus 229kB)
* the binary uses the native windows api -- '6 busses found'-message on startup is missing (produced by usblib)
Posted: Tue Aug 14, 2007 7:21 pm
by ahulap
I have rebuild avrdude-5.4 using cygwin. All works, but i have foung strange thing in 'readInterfaceType' function:
Code: Select all
PORT_DDR_SET(HWPIN_ISP_MOSI);
PORT_PIN_SET(HWPIN_ISP_MOSI);
// _delay_us(10);
PORT_DDR_CLR(HWPIN_ISP_MOSI);
PORT_PIN_CLR(HWPIN_ISP_MOSI); /* deactivate pullup */
useHIDInterface = PORT_PIN_VALUE(HWPIN_ISP_MOSI) == 0;
It sets line output 1, then input without pullup and then checks if line is low. It is not working in my device - always CDC mode. Maybe i don't understand why this is done, but i think, that to check, if the line is pulled low by jumper, it is needed to enable pullup, wait and than check...
But, since CDC mode working very unstable on my PC, i have disabled CDC interface to free space for bootloadHID, witch enables pull-up and then checks. And it detects closed jumper perfectly
Posted: Tue Aug 14, 2007 7:38 pm
by christian
The idea behind this code is to use the port pin for dual purposes. The HID jumper has a series resistor in order to prevent disturbing the normal port function.
Since it's not guaranteed that the pull-down with 1k series resistor reads reliably low, we measure the discharge of the pin's capacity. We output a 1 level, then switch to high impedance and sample the pin. If the jumper is open, the 1 level is still there, due to the capacitance. If it's closed, the capacitor will be discharged and we measure 0.
If you have a large parasitic capacitance or leakage currents (e.g. into the HC126), then this method may fail.
Posted: Tue Aug 14, 2007 8:09 pm
by ahulap
I'm still don't undestand.
AVR pins have internal pullups in range 20k...100k. With 1k resistor it creates a voltage divider. Voltage on MOSI pin with jumper closed and pull-up enabled will be ~1/21 VCC (with 20k pullup, with larger pullup - even smaller, up to 1/101). In some datasheets minimum low voltage is 0.2 VCC, in others 0.1 VCC, so in our worst case of 1/20 VCC it will sure work.
PS: since i can't buy 74HC125, i substitute it with 4 BC547 transistors, and MOSI connected directly to the emitter.
Posted: Tue Aug 14, 2007 8:16 pm
by christian
Yes, you are right with this computation. I can't remember exactly why I did it this way, maybe because I was working with capacitive sensors before that and wanted to re-use the principle.
The transistors are probably not a good substitute for level conversion. We should come up with a low-cost version of AVR-Doper which has no level converters. I'll do that when I have some spare time...
Posted: Wed Aug 15, 2007 9:43 am
by ahulap
christian wrote:The transistors are probably not a good substitute for level conversion.
Why not? 4 NPN transistors are the simplest way to substitute 74HC125. Without any software modifications, i think, it is impossible to implement connection/disconnection of programmer to target: SCK and MOSI are always outputs, RESET and MISO are inverted...
How i did:
RESET and MISO - simple transistor invertor. No collector pullup is needed because there is a pullup on RESET on target and internal MISO pullup in programmer's MCU.
OE - controls bases of SCK and MOSI transistors. When disconnected, OE helds low closing transistors regardless of SCK and MOSI state. When connected, OE switches to input with pullup, allowing transistors to be opened (external pullup may be needed to be sure to open transistors with low current transfer ratio).
SCK and MOSI - connected to emitters. Collectors of this transistors have pullups to Vtarget. When these lines held high, transitors closes, collector pullup activates and SCK or MOSI line is Vtarget. When lines are low, transistors opens and SCK or MOSI pulldowns to 0 (OE must be activated in thes case).
Posted: Wed Aug 15, 2007 8:25 pm
by christian
OK, the transistors MAY be a substitute. I don't want to take the time to think it through thoroughly. I took quite a bit of time to think through all cases (target voltage higher or lower than programmer) with the HC126.
The simple version without level converters would be a compile time firmware option.