diff options
Diffstat (limited to 'Projects/AVRISP-MKII/Lib/XPROG')
-rw-r--r-- | Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.c | 2 | ||||
-rw-r--r-- | Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.c | 4 | ||||
-rw-r--r-- | Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.c | 12 | ||||
-rw-r--r-- | Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.h | 7 |
4 files changed, 13 insertions, 12 deletions
diff --git a/Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.c b/Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.c index a894793c7..c0f04c6bd 100644 --- a/Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.c +++ b/Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.c @@ -65,7 +65,7 @@ static void TINYNVM_SendReadNVMRegister(const uint8_t Address) */
static void TINYNVM_SendWriteNVMRegister(const uint8_t Address)
{
- /* The TPI command for writing to the I/O space uses weird addressing, where the I/O address's upper
+ /* The TPI command for reading from the I/O space uses strange addressing, where the I/O address's upper
* two bits of the 6-bit address are shifted left once */
XPROGTarget_SendByte(TPI_CMD_SOUT | ((Address & 0x30) << 1) | (Address & 0x0F));
}
diff --git a/Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.c b/Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.c index 08936a202..07dce5011 100644 --- a/Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.c +++ b/Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.c @@ -175,10 +175,6 @@ static void XPROGProtocol_LeaveXPROGMode(void) /* Clear the RESET key in the RESET PDI register to allow the XMEGA to run */
XPROGTarget_SendByte(PDI_CMD_STCS | PDI_RESET_REG);
XPROGTarget_SendByte(0x00);
-
- /* Clear /RESET key twice (for some reason this needs to be done twice to take effect) */
- XPROGTarget_SendByte(PDI_CMD_STCS | PDI_RESET_REG);
- XPROGTarget_SendByte(0x00);
XPROGTarget_DisableTargetPDI();
}
diff --git a/Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.c b/Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.c index 3a74e1531..15467fe84 100644 --- a/Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.c +++ b/Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.c @@ -162,7 +162,7 @@ void XPROGTarget_EnableTargetPDI(void) /* Set up the synchronous USART for XMEGA communications -
8 data bits, even parity, 2 stop bits */
- UBRR1 = (F_CPU / 500000UL);
+ UBRR1 = (F_CPU / XPROG_HARDWARE_SPEED);
UCSR1B = (1 << TXEN1);
UCSR1C = (1 << UMSEL10) | (1 << UPM11) | (1 << USBS1) | (1 << UCSZ11) | (1 << UCSZ10) | (1 << UCPOL1);
#else
@@ -203,7 +203,7 @@ void XPROGTarget_EnableTargetTPI(void) /* Set up the synchronous USART for TINY communications -
8 data bits, even parity, 2 stop bits */
- UBRR1 = (F_CPU / 500000UL);
+ UBRR1 = (F_CPU / XPROG_HARDWARE_SPEED);
UCSR1B = (1 << TXEN1);
UCSR1C = (1 << UMSEL10) | (1 << UPM11) | (1 << USBS1) | (1 << UCSZ11) | (1 << UCSZ10) | (1 << UCPOL1);
#else
@@ -239,16 +239,18 @@ void XPROGTarget_DisableTargetPDI(void) /* Tristate all pins */
DDRD &= ~((1 << 5) | (1 << 3));
- PORTD &= ~((1 << 3) | (1 << 2));
+ PORTD &= ~((1 << 5) | (1 << 3) | (1 << 2));
#else
/* Turn off software USART management timer */
TCCR1B = 0;
- /* Tristate all pins */
+ /* Set DATA and CLOCK lines to inputs */
BITBANG_PDIDATA_DDR &= ~BITBANG_PDIDATA_MASK;
BITBANG_PDICLOCK_DDR &= ~BITBANG_PDICLOCK_MASK;
- BITBANG_PDICLOCK_PORT &= ~BITBANG_PDICLOCK_MASK;
+
+ /* Tristate DATA and CLOCK lines */
BITBANG_PDIDATA_PORT &= ~BITBANG_PDIDATA_MASK;
+ BITBANG_PDICLOCK_PORT &= ~BITBANG_PDICLOCK_MASK;
#endif
}
diff --git a/Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.h b/Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.h index 0c54ad4cf..7166c1023 100644 --- a/Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.h +++ b/Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.h @@ -58,7 +58,7 @@ /* Defines: */
#if ((BOARD == BOARD_XPLAIN) || (BOARD == BOARD_XPLAIN_REV1))
#define XPROG_VIA_HARDWARE_USART
- #else
+ #else
#define BITBANG_PDIDATA_PORT PORTB
#define BITBANG_PDIDATA_DDR DDRB
#define BITBANG_PDIDATA_PIN PINB
@@ -80,8 +80,11 @@ #define BITBANG_TPICLOCK_MASK (1 << 1)
#endif
+ /** Serial carrier TPI/PDI speed when hardware TPI/PDI mode is used */
+ #define XPROG_HARDWARE_SPEED 500000
+
/** Number of cycles between each clock when software USART mode is used */
- #define BITS_BETWEEN_USART_CLOCKS 80
+ #define BITS_BETWEEN_USART_CLOCKS 100
/** Total number of bits in a single USART frame */
#define BITS_IN_USART_FRAME 12
|