Vermes
Advanced Member level 4
Atxmega has many advantages in comparison to AVR. It is faster (32MHz), has more peripherals (5 UARTs, 16 PWM channels) and module construction.
It is easy to implement a new protocol for programming in USBasp. PDI requires a constant clock signal and it disconnects wher the frequency drops below 10kHz. Time requirements of that type are problematic for V-USB (USB implementation used in USBasp), because the USB transmission is handled by software and cannot do anything else in that time.
Picture above presents gaps in the clock signal caused by interruptions of V-USB.
Interruption for handling a simple transfer of control type takes only 40-50us and it is enough not to interrupt the PDI connection handled by software. Sending greater number of data at once interferes with the clock, but you can cope with that when you organize the work of the programmer, so that it collects the data and use them in the moment when there is no transmission.
Presented here implementation switches to the clock generation by timer for the time of USB transmission.
Picture shows on the left: software clock, on the right: clock from timer.
Physical connection:
Standard USBaspis for 5V, and PDI of Atxmega operates at 3,3V, the simplest way to decrease the voltage is a Zener diode.
SCK controls PDI DATA and MOSI is PDI CLK. If you have USBasp operating at 3,3V, just connect it as a normal PDI:
Power supply:
When you want to power the system from the programmer, add a 3,3V stabilizer to the 5V USBasp.
Software:
- Firmware UABasp with PDI handling can be downloaded from
HERE and patch uspasp-pdi-usbaspfirmware-20120816.txt (attachment)
Unpack, add patch, compile:
Code:tar xvzf usbasp.2011-05-28.tar.gz cd usbasp.2011-05-28/firmware patch <full/path/of/usbasp-pdi-usbaspfirmware-20120816.diff make main.hex
and install it in the programmer.
Note! Atmega48 is not supported, because there is no place for the additional code in the memory.
- AVRDUDE with USBasp support and PDI:[/b]
you need sources in version r1092 and patch usbasp-pdi-avrdude2091-20120816.txt (attachment)
Code:svn co svn://svn.sv.gnu.org/avrdude/trunk -r 1092 cd trunk/avrdude patch <full/path/of/usbasp-pdi-avrdude2091-20120816.diff ./bootstrap ./configure make * ./avrdude -C avrdude.conf -c usbasp -p x16a4 -U flash:w:../../../xmega/xmegatest.hex -E noreset * avrdude: AVR device initialized and ready to accept instructions * Reading | ################################################## | 100% 0.02s * avrdude: Device signature = 0x1e9441 avrdude: NOTE: Programmer supports page erase for Xmega devices. Each page will be erased before programming it, but no chip erase is performed. To disable page erases, specify the -D option; for a chip-erase, use the -e option. avrdude: reading input file "../../../xmega/xmegatest.hex" avrdude: input file ../../../xmega/xmegatest.hex auto detected as Intel Hex avrdude: writing flash (440 bytes): * Writing | ################################################## | 100% 0.29s * avrdude: 440 bytes of flash written avrdude: verifying flash memory against ../../../xmega/xmegatest.hex: avrdude: load data flash data from input file ../../../xmega/xmegatest.hex: avrdude: input file ../../../xmega/xmegatest.hex auto detected as Intel Hex avrdude: input file ../../../xmega/xmegatest.hex contains 440 bytes avrdude: reading on-chip flash data: * Reading | ################################################## | 100% 0.27s * avrdude: verifying ... avrdude: 440 bytes of flash verified * avrdude done. Thank you.
Final effect – LED flashing:
Link to original thread (useful attachment) - Programator ATxmega za złotówkę, czyli obsługa PDI w USBASP