mirror of
https://github.com/avrdudes/avrdude.git
synced 2026-09-21 00:26:22 +03:00
Always set Xmega JTAG bit clock when using PICkit4 or SNAP
If the bitclock isn't explicity set, the programmer crashes and needs a power cycle to recover
This commit is contained in:
30
src/jtag3.c
30
src/jtag3.c
@@ -1068,16 +1068,28 @@ static int jtag3_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
||||
my.set_sck = jtag3_set_sck_mega_jtag;
|
||||
}
|
||||
|
||||
if(pgm->bitclock && my.set_sck) {
|
||||
unsigned int clock = 1E-3/pgm->bitclock; // kHz
|
||||
if(my.set_sck) {
|
||||
unsigned int xmega_default_jtag_bitclock = 0;
|
||||
|
||||
if(!(pgm->extra_features & HAS_BITCLOCK_ADJ))
|
||||
pmsg_warning("setting bitclock despite HAS_BITCLOCK_ADJ missing in pgm->extra_features\n");
|
||||
pmsg_notice2("%s(): trying to set JTAG clock to %u kHz\n", __func__, clock);
|
||||
parm[0] = clock & 0xff;
|
||||
parm[1] = (clock >> 8) & 0xff;
|
||||
if(my.set_sck(pgm, parm) < 0)
|
||||
return -1;
|
||||
if(!pgm->bitclock) {
|
||||
// ICkit 4 and SNAP requires the bitclock to be explicity set when programming Xmegas using JTAG
|
||||
if(my.set_sck == jtag3_set_sck_xmega_jtag && (str_starts(pgmid, "pickit4") || str_starts(pgmid, "snap"))) {
|
||||
xmega_default_jtag_bitclock = 7500; // Use a default Xmega JTAG bitclock of 7500 kHz
|
||||
pmsg_notice2("%s(): programmer requires a JTAG clock speed to be specified\n", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
if(pgm->bitclock || xmega_default_jtag_bitclock) {
|
||||
unsigned int clock = pgm->bitclock? 1E-3/pgm->bitclock: xmega_default_jtag_bitclock; // kHz
|
||||
|
||||
if(!(pgm->extra_features & HAS_BITCLOCK_ADJ))
|
||||
pmsg_warning("setting bitclock despite HAS_BITCLOCK_ADJ missing in pgm->extra_features\n");
|
||||
pmsg_notice2("%s(): trying to set JTAG clock to %u kHz\n", __func__, clock);
|
||||
parm[0] = clock & 0xff;
|
||||
parm[1] = (clock >> 8) & 0xff;
|
||||
if(my.set_sck(pgm, parm) < 0)
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if(conn == PARM3_CONN_JTAG) {
|
||||
|
||||
Reference in New Issue
Block a user