Setting up port in assembly

Technical questions regarding the XTC tools and programming with XMOS.
Post Reply
diltsman
Member++
Posts: 21
Joined: Sun Mar 03, 2013 11:26 pm

Setting up port in assembly

Post by diltsman »

I am trying to simply drive the XK-1A LEDs. I have the following code where I think that I am configuring the port and the default clock. I am using the simulator to test this code. It appears to freeze on the second out command. Obviously I missed something. My guess is with the port setup. Could anyone point out what I missed?

Code: Select all

  .section .cp.const4, "caM", @progbits, 4
XS1_PORT_4F: .word 0x40500
XS1_CLKBLK_REF: .word 0x6
CTRL_INUSE_ON: .word 0x0008
CTRL_RUN_STARTR: .word 0x000f
  .text
  .align 2
  .globl _start
_start:
  ldap r11, _cp
  set cp,r11

  ldw r10, cp[XS1_PORT_4F]
  ldw r11, cp[XS1_CLKBLK_REF]

  ldw r9, cp[CTRL_INUSE_ON]
  setc res[r11], r9

  ldw r9, cp[CTRL_INUSE_ON]
  setc res[r10], r9		# CTRL_INUSE_ON

loop:
  ldc r9, 0x03
  out res[r10], r9
  ldc r9, 0x03
  out res[r10], r9

  bu loop


User avatar
segher
XCore Expert
Posts: 844
Joined: Sun Jul 11, 2010 1:31 am
Contact:

Post by segher »

You do not need to set the ports to use the refclk: it is the default
after reset. [EDIT: You're not doing that, I misread].

You do however need to enable and start the refclk:

Code: Select all

ldc r0,6 ; setc res[r0],8 ; setc res[r0],0x0f # enable and start refclk
Post Reply