AVR-Doper HID mode problem
AVR-Doper HID mode problem
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...
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...
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)
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)
I have rebuild avrdude-5.4 using cygwin. All works, but i have foung strange thing in 'readInterfaceType' function:
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
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
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.
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.
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.
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.
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...
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...
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).
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.
The simple version without level converters would be a compile time firmware option.