Chapter 14: Using Jam STAPL for ISP via an Embedded Processor
14–9
Software Development
Step 1: Set Preprocessor Statements to Exclude Extraneous Code
At the top of jbistub.c, change the default PORTparameter to EMBEDDEDto eliminate
all DOS, Windows, and UNIX source code and included libraries.
#define PORT EMBEDDED
Step 2: Map JTAG Signals to Hardware Pins
The jbi_jtag_io()function contains the code that sends and receives the binary
programming data. Each of the four JTAG signals should be re-mapped to the
embedded processor’s pins. By default, the source code writes to the PC’s parallel
port. The jbi_jtag_io()signal maps the JTAG pins to the PC parallel port registers
shown in Figure 14–6.
Figure 14–6. Default PC Parallel Port Signal Mapping (Note 1)
7
0
6
TDI
X
5
0
4
3
2
1
0
I/O Port
0
0
0
TMS TCK OUTPUT DATA -
Base Address
TDO
X
X
X
---
---
---
INPUT DATA -
Base Address + 1
Note to Figure 14–6:
(1) The PC parallel port hardware inverts the most significant bit, TDO.
The mapping is highlighted in the following jbi_jtag_io() source code:
int jbi_jtag_io(int tms, int tdi, int read_tdo)
{
int data=0;
int tdo=0;
if (!jtag_hardware_initialized)
{
initialize_jtag_hardware();
jtag_hardware_initialized=TRUE;
}
data = ((tdi?0x40:0)|(tms?0x2:0));
/*TDI,TMS*/
write_byteblaster(0,data);
if (read_tdo)
{
tdo=(read_byteblaster(1)&0x80)?0:1; /*TDO*/
}
write_blaster(0,data|0x01); /*TCK*/
write_blaster(0,data);
return (tdo);
}
In the previous code, the PC parallel port inverts the actual value of TDO. The
jbi_jtag_io()source code inverts it again to retrieve the original data. The line
which inverts the TDOvalue is as follows:
tdo=(read_byteblaster(1)&0x80)?0:1;
© October 2008 Altera Corporation
MAX II Device Handbook