Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Altera_Forum
Honored Contributor I
712 Views

Need some help regarding the serial port(beginner)

We tried to link 2 DE2 boards together each connected to a seperate desktop computer. The goal was to write something in the Altera monitor terminal on one desktop and have it show up in the terminal of the other. 

The code we ended up with didn't work and I'd be thankful if someone could read through it and see why it doesn't. 

This was the code used:  

.text 

.global _start 

 

_start: 

 

movia sp, 0x007FFFFC # Max stack value 

 

movia r6, 0x10001000 # Default address for the data register of JTAG 

 

movia r7, 0x10001010 # Default address for the data register of the serial port 

 

 

.macro PUSH reg 

subi sp, sp, 4 

stw \reg, 0(sp) 

.endm 

 

.macro POP reg 

ldw \reg, 0(sp) 

addi sp, sp, 4  

.endm 

 

 

MAIN_LOOP: 

call READ_JTAG 

call READ_SERIAL 

br MAIN_LOOP 

 

READ_JTAG: 

# Read data from the JTAG port 

 

ldwio r4, 0(r6) 

andi r8, r4, 0x8000 

beq r8, r0, END_PUT 

andi r5, r4, 0x00ff 

PUSH r31 

call WRITE_JTAG 

call WRITE_SERIAL 

POP r31 

ret 

 

WRITE_JTAG: 

# Write data to the JTAG port 

ldwio r4, 4(r6) 

andhi r4, r4, 0xffff 

beq r4, r0, END_PUT 

stwio r5, 0(r6) 

ret 

 

READ_SERIAL:# Read data from the serial port 

ldwio r3, 0(r7) 

andi r8, r3, 0x8000 

beq r8, r0, END_PUT 

andi r5, r3, 0x00ff 

PUSH r31 

call WRITE_JTAG 

POP r31 

ret 

 

WRITE_SERIAL: 

# Write data to the serial port 

ldwio r3, 4(r7) 

andhi r3, r3, 0xffff 

beq r3, r0, END_PUT 

stwio r5, 0(r7) 

ret 

 

END_PUT: 

ret 

 

.end 

 

0 Kudos
0 Replies