void jtagsetup(){
P5DIR|=MOSI+SCK+TMS;
P5DIR&=~MISO;
+ /*
P5OUT|=0xFFFF;
P5OUT=0;
+ */
P4DIR|=TST;
P2DIR|=RST;
msdelay(100);
if(bit==7)
SETTMS;//TMS high on last bit to exit.
- CLRTCK;
- SETTCK;
- /* read MISO on trailing edge */
+ TCKTOCK;
+ /* read MISO on trailing edge */
byte |= READMISO;
}
RESTORETCLK;
// exit state
- CLRTCK;
- SETTCK;
+ TCKTOCK;
// update state
CLRTMS;
- CLRTCK;
- SETTCK;
+ TCKTOCK;
return byte;
}
if(bit==bitcount-1)
SETTMS;//TMS high on last bit to exit.
- CLRTCK;
- SETTCK;
+ TCKTOCK;
/* read MISO on trailing edge */
word |= READMISO;
}
RESTORETCLK;
// exit state
- CLRTCK;
- SETTCK;
+ TCKTOCK;
// update state
CLRTMS;
- CLRTCK;
- SETTCK;
+ TCKTOCK;
return word;
}
-/*
-//! Shift 16 bits in and out.
-unsigned int jtagtrans16(unsigned int word){ //REMOVEME
- unsigned int bit;
- SAVETCLK;
-
- for (bit = 0; bit < 16; bit++) {
- // write MOSI on trailing edge of previous clock
- if (word & 0x8000)
- {SETMOSI;}
- else
- {CLRMOSI;}
- word <<= 1;
-
- if(bit==15)
- SETTMS;//TMS high on last bit to exit.
-
- CLRTCK;
- SETTCK;
- // read MISO on trailing edge
- word |= READMISO;
- }
- RESTORETCLK;
-
- // exit state
- CLRTCK;
- SETTCK;
- // update state
- CLRTMS;
- CLRTCK;
- SETTCK;
-
- return word;
-}*/
//! Stop JTAG, release pins
void jtag_stop(){
P4OUT=0;
}
-unsigned int drwidth=20;
+unsigned int drwidth=16;
//! Shift all bits of the DR.
unsigned long jtag_dr_shift20(unsigned long in){
// idle
SETTMS;
- CLRTCK;
- SETTCK;
+ TCKTOCK;
// select DR
CLRTMS;
- CLRTCK;
- SETTCK;
+ TCKTOCK;
// capture IR
- CLRTCK;
- SETTCK;
+ TCKTOCK;
// shift DR, then idle
return(jtagtransn(in,20));
unsigned int jtag_dr_shift16(unsigned int in){
// idle
SETTMS;
- CLRTCK;
- SETTCK;
+ TCKTOCK;
// select DR
CLRTMS;
- CLRTCK;
- SETTCK;
+ TCKTOCK;
// capture IR
- CLRTCK;
- SETTCK;
+ TCKTOCK;
// shift DR, then idle
return(jtagtransn(in,16));
}
+//! Shift native width of the DR
+unsigned long jtag_dr_shiftadr(unsigned long in){
+ unsigned long out=0;
+
+ // idle
+ SETTMS;
+ TCKTOCK;
+ // select DR
+ CLRTMS;
+ TCKTOCK;
+ // capture IR
+ TCKTOCK;
+
+
+ out=jtagtransn(in,drwidth);
+
+ // shift DR, then idle
+ return(out);
+}
+
//! Shift 8 bits of the IR.
unsigned char jtag_ir_shift8(unsigned char in){
// idle
SETTMS;
- CLRTCK;
- SETTCK;
+ TCKTOCK;
// select DR
- CLRTCK;
- SETTCK;
+ TCKTOCK;
// select IR
CLRTMS;
- CLRTCK;
- SETTCK;
+ TCKTOCK;
// capture IR
- CLRTCK;
- SETTCK;
+ TCKTOCK;
// shift IR, then idle.
return(jtagtrans8(in));