aboutsummaryrefslogtreecommitdiffstats
path: root/Projects/AVRISP/Lib
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2009-12-09 12:01:01 +0000
committerDean Camera <dean@fourwalledcubicle.com>2009-12-09 12:01:01 +0000
commit9c8ed168e5805059db7978e6a9a4ad24347c7a6e (patch)
tree335ca20c5911c30724585c42f78e7ade01379646 /Projects/AVRISP/Lib
parente4cfd5208fdb51942ad8857dd5e1d96f5216f73b (diff)
downloadlufa-9c8ed168e5805059db7978e6a9a4ad24347c7a6e.tar.gz
lufa-9c8ed168e5805059db7978e6a9a4ad24347c7a6e.tar.bz2
lufa-9c8ed168e5805059db7978e6a9a4ad24347c7a6e.zip
Fix inverted bit-banged USART logic in the AVRISP project for PDI programming. Add a delay to the clock toggling in the AVRISP project to ensure that the programming speed does not exceed 10MHz under any conditions to satisfy the limits in the datasheet for all target voltages. Fix incorrect pin being used as the DATA in in PDI programming mode.
Diffstat (limited to 'Projects/AVRISP/Lib')
-rw-r--r--Projects/AVRISP/Lib/PDIProtocol.c4
-rw-r--r--Projects/AVRISP/Lib/PDITarget.c4
-rw-r--r--Projects/AVRISP/Lib/PDITarget.h6
3 files changed, 7 insertions, 7 deletions
diff --git a/Projects/AVRISP/Lib/PDIProtocol.c b/Projects/AVRISP/Lib/PDIProtocol.c
index d98c51c43..864d4e9c3 100644
--- a/Projects/AVRISP/Lib/PDIProtocol.c
+++ b/Projects/AVRISP/Lib/PDIProtocol.c
@@ -110,9 +110,7 @@ static void PDIProtocol_EnterXPROGMode(void)
/* Must hold DATA line high for at least 90nS to enable PDI interface */
PDIDATA_LINE_PORT |= PDIDATA_LINE_MASK;
asm volatile ("NOP"::);
- #if (F_CPU > 8000000)
asm volatile ("NOP"::);
- #endif
/* Toggle CLOCK line 16 times within 100uS of the original 90nS timeout to keep PDI interface enabled */
for (uint8_t i = 0; i < 16; i++)
@@ -120,7 +118,7 @@ static void PDIProtocol_EnterXPROGMode(void)
/* Enable access to the XPROG NVM bus by sending the documented NVM access key to the device */
PDITarget_SendByte(PDI_CMD_KEY);
- for (uint8_t i = 0; i < 8; i++)
+ for (uint8_t i = 0; i < sizeof(PDI_NVMENABLE_KEY); i++)
PDITarget_SendByte(PDI_NVMENABLE_KEY[i]);
/* Read out the STATUS register to check that NVM access was successfully enabled */
diff --git a/Projects/AVRISP/Lib/PDITarget.c b/Projects/AVRISP/Lib/PDITarget.c
index 98d4bded4..03dd77998 100644
--- a/Projects/AVRISP/Lib/PDITarget.c
+++ b/Projects/AVRISP/Lib/PDITarget.c
@@ -52,9 +52,9 @@ void PDITarget_SendByte(uint8_t Byte)
for (uint8_t i = 0; i < 8; i++)
{
if (Byte & 0x01)
- PDIDATA_LINE_PORT |= PDIDATA_LINE_MASK;
- else
PDIDATA_LINE_PORT &= ~PDIDATA_LINE_MASK;
+ else
+ PDIDATA_LINE_PORT |= PDIDATA_LINE_MASK;
Byte >>= 1;
diff --git a/Projects/AVRISP/Lib/PDITarget.h b/Projects/AVRISP/Lib/PDITarget.h
index 294d1a98b..00ce68bb3 100644
--- a/Projects/AVRISP/Lib/PDITarget.h
+++ b/Projects/AVRISP/Lib/PDITarget.h
@@ -65,7 +65,7 @@
#define PDIDATA_LINE_PORT PORTB
#define PDIDATA_LINE_DDR DDRB
#define PDIDATA_LINE_PIN PINB
- #define PDIDATA_LINE_MASK (1 << 2)
+ #define PDIDATA_LINE_MASK (1 << 3)
#define PDICLOCK_LINE_PORT RESET_LINE_PORT
#define PDICLOCK_LINE_DDR RESET_LINE_DDR
@@ -91,7 +91,9 @@
#define PDI_NVMENABLE_KEY (uint8_t[]){0x12, 0x89, 0xAB, 0x45, 0xCD, 0xD8, 0x88, 0xFF}
#define TOGGLE_PDI_CLOCK MACROS{ PDICLOCK_LINE_PORT ^= PDICLOCK_LINE_MASK; \
- PDICLOCK_LINE_PORT ^= PDICLOCK_LINE_MASK; }MACROE
+ asm volatile ("NOP" ::); \
+ PDICLOCK_LINE_PORT ^= PDICLOCK_LINE_MASK; \
+ asm volatile ("NOP" ::); }MACROE
/* Function Prototypes: */
void PDITarget_SendByte(uint8_t Byte);