Par pitanja JTAG komunikaciji

Diskusija o MSP, ARM / LPC, PLC kontrolerima.

Moderators: pedja089, stojke369, [eDo], trax

Post Reply
Cvik_Dasa
Napredujem
Napredujem
Posts: 157
Joined: 23-11-2010, 05:13

Par pitanja JTAG komunikaciji

Post by Cvik_Dasa »

Pozdrav svima! Prije bi čojek našo 100€ nego mene al eto .... kuća poso, više poso nego kuća :azdaja:


No uglavnom, pokušavam isprogramirat FPGA preko bin file-a bez programatora i taj dio radi, jednostavno sam s logičkim analizatorom pratio komunikaciju između FPGA i usb blastera, napisao arduino program da čita bin file s sd kartice i ok uspio sam isprogramirat FPGA.

E sad pošto sve to trebam prebacit na STM32 a i bilo bi ok zapravo razumjet što se događa u komunikaciji zanima me dal neko ima kakvu literaturu o JTAG komunikaciji?? ovo sve što sam na google-u našao mi ne služi praktički nićemu.... sve je to površno.

Zapravo me zanima recimo nalazim se u data registru i hoću iči u instruction registar, dali smijem iči u "run test/idle state" ili moram odma u instruction registar ili će ono što je uprisano u DR biti izbrisano?
Odnosno dali je isto:
exit DR -> update DR -> select DR -> select IR -> capture IR -> shift IR
kao i:
exit DR -> update DR -> ->run test/idle -> select DR -> select IR -> capture IR -> shift IR

Isto tako nije mi baš najjasnije zašto nekad program ide kroz exit DR i update DR s data line = 1 a nekad je 0?

Zašto nekada program više puta u isti registar upisuje istu vrijednost??? Recimo dva tri puta prolazi kroz instruction registar i upisuje iste vrijednosti??

no kao što vidite nemam pojma ništa o JTAG-u pa ako neko ima nekakvu literaturu bilo bi super.


Ako nekoga interesira arduino program .. eto ga

Code: Select all

#include <SPI.h>
#include <SD.h>


const int chipSelect = 4;	//SPI_sd card
const int TDO = 5;
const int TCK = 6;
const int TMS = 7;



void setup() {


	pinMode(TDO, OUTPUT);
	pinMode(TMS, OUTPUT);
	pinMode(TCK, OUTPUT);

	digitalWrite(TDO, LOW);
	digitalWrite(TMS, LOW);
	digitalWrite(SCK, LOW);


	Serial.begin(9600);

	BeforeFile();  


	File dataFile = SD.open("Led73_bin.bin");


	if (dataFile) {
		while (dataFile.available()) {

			byte i = dataFile.read();


			shiftOut(TDO, TCK, LSBFIRST, i);


		}
		dataFile.close();
		AfterFile();
	}

}

void loop() {
}



void BeforeFile(){
	digitalWrite(TDO, HIGH);
	digitalWrite(TMS, HIGH);
	for (int v = 0; v< 6; v++){Clock();}

	digitalWrite(TMS, LOW);
	Clock();                  //In Run test/idle

	shift_DR();

	shiftOut(TDO, TCK, LSBFIRST, 0xFF);
	shiftOut(TDO, TCK, LSBFIRST, 0xC0);
	shiftOut(TDO, TCK, LSBFIRST, 0xEC);
	shiftOut(TDO, TCK, LSBFIRST, 0x0F);

	digitalWrite(TDO, HIGH);
	for (int v = 0; v< 95; v++){Clock();}


	From_Register_To_Shift_Ir();  //in shift ir

	shiftOut(TDO, TCK, LSBFIRST, 0xFF);
	shiftOut(TDO, TCK, LSBFIRST, 0xC0);
	shiftOut(TDO, TCK, LSBFIRST, 0xEC);
	shiftOut(TDO, TCK, LSBFIRST, 0x0F);
	digitalWrite(TDO, HIGH);
	for (int v = 0; v< 95; v++){Clock();}

	From_Register_To_Shift_Ir();  //in shift ir

	shiftOut(TDO, TCK, LSBFIRST, 0xFF);
	shiftOut(TDO, TCK, LSBFIRST, 0xC0);
	shiftOut(TDO, TCK, LSBFIRST, 0xEC);
	shiftOut(TDO, TCK, LSBFIRST, 0x0F);
	digitalWrite(TDO, HIGH);
	for (int v = 0; v< 95; v++){Clock();}

	From_Register_To_Shift_Dr();  //in shift ir

	shiftOut(TDO, TCK, LSBFIRST, 0xFF);
	shiftOut(TDO, TCK, LSBFIRST, 0xC0);
	shiftOut(TDO, TCK, LSBFIRST, 0xEC);
	shiftOut(TDO, TCK, LSBFIRST, 0x0F);
	digitalWrite(TDO, HIGH);
	for (int v = 0; v< 95; v++){Clock();}


	From_Register_To_Shift_Ir();

	Clock();

	shiftOut(TDO, TCK, LSBFIRST, 0xFF);

	From_Register_To_Shift_Dr();
	digitalWrite(TMS, HIGH);
	digitalWrite(TDO,LOW);
	Clock();
	digitalWrite(TDO,HIGH);
	Clock();
	Clock();
	Clock();
	digitalWrite(TMS, LOW);
	Clock();
	Clock();
	shiftOut(TDO, TCK, LSBFIRST, 0xFE);
	shiftOut(TDO, TCK, LSBFIRST, 0xFF);
	digitalWrite(TDO,HIGH);
	Clock();

	From_Register_To_Shift_Ir();


	digitalWrite(TDO,LOW);
	Clock();
	shiftOut(TDO, TCK, LSBFIRST, 0x03);

	digitalWrite(TMS, HIGH);
	Clock();
	digitalWrite(TDO,HIGH);
	Clock();
	digitalWrite(TMS, LOW);  
	shiftOut(TDO, TCK, LSBFIRST, 0xFF);
	shiftOut(TDO, TCK, LSBFIRST, 0xFF);

	digitalWrite(TMS, HIGH);
	digitalWrite(TDO, HIGH);
	Clock();
	digitalWrite(TMS, LOW); 
	Clock();
	Clock();
	digitalWrite(TDO, LOW);
	shiftOut(TDO, TCK, LSBFIRST, 0x00);
	shiftOut(TDO, TCK, LSBFIRST, 0x00);
	shiftOut(TDO, TCK, LSBFIRST, 0x00);
	shiftOut(TDO, TCK, LSBFIRST, 0x00);
	shiftOut(TDO, TCK, LSBFIRST, 0x50);
	shiftOut(TDO, TCK, LSBFIRST, 0x15);
	shiftOut(TDO, TCK, LSBFIRST, 0x00);

	Clock();
	Clock();
	Clock();
	Clock();
	Clock();
	Clock();
	Clock();

	digitalWrite(TMS, HIGH);
	Clock();
	digitalWrite(TDO, HIGH);
	Clock();
	digitalWrite(TMS, LOW);
	Clock();
	digitalWrite(TMS, HIGH);
	Clock();
	Clock();
	digitalWrite(TMS, LOW);
	Clock();
	Clock();
	digitalWrite(TDO, LOW);
	Clock();

	shiftOut(TDO, TCK, LSBFIRST, 0x68);
	digitalWrite(TMS, HIGH);
	digitalWrite(TDO, HIGH);
	Clock();
	Clock();
	digitalWrite(TMS, LOW);
	shiftOut(TDO, TCK, LSBFIRST, 0xFF);
	shiftOut(TDO, TCK, LSBFIRST, 0xFF);
	digitalWrite(TMS, HIGH);
	digitalWrite(TDO, HIGH);
	Clock();
	Clock();
	digitalWrite(TMS, LOW);
	Clock();
	Clock();
	digitalWrite(TDO, LOW);
	Clock();
	shiftOut(TDO, TCK, LSBFIRST, 0x01);
	digitalWrite(TMS, HIGH);
	Clock();
	digitalWrite(TDO, HIGH);
	Clock();
	digitalWrite(TMS, LOW);

	for (int i = 0; i<255; i++){
		shiftOut(TDO, TCK, LSBFIRST, 0xFF);
		shiftOut(TDO, TCK, LSBFIRST, 0xFF);
		shiftOut(TDO, TCK, LSBFIRST, 0xFF);
		shiftOut(TDO, TCK, LSBFIRST, 0xFF);
		shiftOut(TDO, TCK, LSBFIRST, 0xFF);
		shiftOut(TDO, TCK, LSBFIRST, 0xFF);
		shiftOut(TDO, TCK, LSBFIRST, 0xFF);
		shiftOut(TDO, TCK, LSBFIRST, 0xFF);
	}

	digitalWrite(TMS, HIGH);
	digitalWrite(TDO, HIGH);
	Clock();
	digitalWrite(TMS, LOW);
	Clock();
	Clock();

	for (int i = 0; i<37; i++){
		shiftOut(TDO, TCK, LSBFIRST, 0xFF);
	}
	
	return;
}

void AfterFile(){


	digitalWrite(TDO, LOW);
	for (int i = 0; i<31; i++){
		Clock();
	}

	digitalWrite(TMS, HIGH);
	Clock();
	digitalWrite(TDO, HIGH);
	Clock();
	Clock();
	Clock();
	digitalWrite(TMS, LOW);
	Clock();
	Clock();
	digitalWrite(TDO, LOW);
	Clock();
	shiftOut(TDO, TCK, LSBFIRST, 0x02);



	digitalWrite(TMS, HIGH);
	Clock();
	digitalWrite(TDO, HIGH);
	Clock();
	digitalWrite(TMS, LOW);
	shiftOut(TDO, TCK, LSBFIRST, 0xFF);
	shiftOut(TDO, TCK, LSBFIRST, 0xFF);
	digitalWrite(TDO, HIGH);
	digitalWrite(TMS, HIGH);
	Clock();
	digitalWrite(TMS, LOW);
	Clock();
	Clock();
	digitalWrite(TDO, LOW);
	Clock();

	for (int i = 0; i< 150; i++){
		shiftOut(TDO, TCK, LSBFIRST, 0x00);
	}
	Clock();
	Clock();
	digitalWrite(TMS, HIGH);
	Clock();
	digitalWrite(TDO, HIGH);
	Clock();
	digitalWrite(TMS, LOW);
	Clock();
	digitalWrite(TMS, HIGH);
	Clock();
	Clock();
	digitalWrite(TMS, LOW);
	Clock();
	Clock();
	digitalWrite(TDO, LOW);
	Clock();

	shiftOut(TDO, TCK, LSBFIRST, 0xFF);
	shiftOut(TDO, TCK, LSBFIRST, 0xFF);
	From_Register_To_Shift_Ir();

	Clock();
	shiftOut(TDO, TCK, LSBFIRST, 0x01);
	digitalWrite(TMS, HIGH);
	Clock();
	digitalWrite(TDO, HIGH);
	Clock();
	digitalWrite(TMS, LOW);
	Clock();

	for (int i = 0; i< 150; i++){
		shiftOut(TDO, TCK, LSBFIRST, 0xFF);
	}

	digitalWrite(TDO, HIGH);
	digitalWrite(TMS, HIGH);
	Clock();
	Clock();
	digitalWrite(TMS, LOW);
	Clock();
	Clock();
	digitalWrite(TDO, LOW);
	Clock();

	shiftOut(TDO, TCK, LSBFIRST, 0x03);
	digitalWrite(TMS, HIGH);
	Clock();
	digitalWrite(TDO, HIGH);
	Clock();
	digitalWrite(TMS, LOW);

	shiftOut(TDO, TCK, LSBFIRST, 0xFF);
	shiftOut(TDO, TCK, LSBFIRST, 0xFF);
	digitalWrite(TMS, HIGH);
	Clock();
	digitalWrite(TMS, LOW);
	Clock();
	Clock();
	shiftOut(TDO, TCK, LSBFIRST, 0x00);
	shiftOut(TDO, TCK, LSBFIRST, 0x00);
	shiftOut(TDO, TCK, LSBFIRST, 0x00);
	shiftOut(TDO, TCK, LSBFIRST, 0x00);
	shiftOut(TDO, TCK, LSBFIRST, 0xA8);
	shiftOut(TDO, TCK, LSBFIRST, 0xCA);
	shiftOut(TDO, TCK, LSBFIRST, 0x1F);
	Clock();
	Clock();

	digitalWrite(TDO, HIGH);
	Clock();
	digitalWrite(TDO, LOW);
	Clock();
	digitalWrite(TDO, HIGH);
	Clock();
	digitalWrite(TDO, LOW);
	Clock();
	digitalWrite(TDO, HIGH);
	Clock();
	digitalWrite(TDO, LOW);
	digitalWrite(TMS, HIGH);
	Clock();
	digitalWrite(TDO, HIGH);
	Clock();
	digitalWrite(TMS, LOW);
	Clock();
	digitalWrite(TMS, HIGH);
	Clock();

	Clock();
	Clock();
	Clock();
	Clock();
	Clock();
	digitalWrite(TDO, HIGH);
	delay(2000);
	return;
}

void  shift_DR(){

	digitalWrite(TMS, HIGH);
	Clock();                  //dr scan
	digitalWrite(TMS, LOW);
	Clock();                  //capture dr
	Clock();                  //shift dr
	return;
}

void From_Register_To_Shift_Ir(){

	digitalWrite(TDO, HIGH);
	digitalWrite(TMS, HIGH);
	Clock();
	Clock();
	Clock();
	Clock();
	digitalWrite(TMS, LOW);
	Clock();
	Clock();
	return;
}


void From_Register_To_Shift_Dr(){

	digitalWrite(TDO, HIGH);
	digitalWrite(TMS, HIGH);
	Clock();
	Clock();
	Clock();
	digitalWrite(TMS, LOW);
	Clock();
	Clock();

	return;
}

void Clock(){
	digitalWrite(TCK, HIGH);

	digitalWrite(TCK, LOW);

	return;
}

Program je majko moja mila :ohno: užaš našta to liči ali to je samo za početak da vidim dali je uopće moguće isprogramirat FPGA s sd kartice tako da nema brige.
User avatar
Black
Odlično uznapredovao
Odlično uznapredovao
Posts: 981
Joined: 17-12-2008, 15:44

Re: Par pitanja JTAG komunikaciji

Post by Black »

Mozda glupo pitanje ali: dalisi odgovor potražio u datashetu?
jazz
Pravo uznapredovao :)
Pravo uznapredovao :)
Posts: 207
Joined: 21-10-2010, 21:18
Location: Hrvatska

Re: Par pitanja JTAG komunikaciji

Post by jazz »

Da odgovorim na stariji post, možda nekome pomogne. Na slici je prikazan TAP Controller State Machine IEEE Std 1149.1 koji se koristi kod TI MSP430 mikrokontrolera (slau320). Vjerojatno se slični dijagram može naći u dokumentaciji za bilo koji mikrokontroler drugog proizvođača.
jtag.jpg
jtag.jpg (29.16 KiB) Viewed 7536 times
Post Reply