I am liking the http://www.xmos.com chips but want to get a lower level understanding of what is going on. Basically assembler. I am trying to sort out something as simple as an led blinker, set the led, count to N clear the led, count to N, loop forever.
Sure I can disassemble a 10 line XC program, but if you have tried that you will see there is a lot of bloat in there that is in every program, what bits are to support the compiler output and what bits are actually setting up the gpio?
EDIT:
XC code
#include out port bled = PORT_BUTTONLED ; int main () { bled <: 0b0011 ; while (1) ; return 0; }
Commands to build
source SetEnv xcc bob.xc -target=XC-1A -o bob.xe xsim --max-cycles 2000 --vcd-tracing "-o bob.vcd -ports -cycles -threads -timers -instructions -functions" bob.xe
EDIT 5
Here is the answer
.globl _start _start: ldc r0,4 ldc r2,8 ldc r3,16 ldc r1, 100 notmain: sub r1,r1,1 bt r1, notmain ldap r11,constants set dp,r11 ldc r3, 0x6 setc res[r3], 0x8 setc res[r3], 0xf ldw r3,dp[0x0] setc res[r3],0x8 ldc r1,0x6 setclk res[r3],r1 top: ldc r0, 0x8 out res[r3], r0 bl delay ldc r0, 0x4 out res[r3], r0 bl delay ldc r0, 0x2 out res[r3], r0 bl delay ldc r0, 0x1 out res[r3], r0 bl delay ldc r0, 0x2 out res[r3], r0 bl delay ldc r0, 0x4 out res[r3], r0 bl delay bu top constants: .word 0x00040200 delay: ldc r2, 1000 da: ldc r1, 10000 db: sub r1,r1,1 bt r1, db sub r2,r2,1 bt r2, da retsp 0x0
building and loading the above assembler m.s:
xcc m.s -target=XC-1A -nostartfiles -o m.xe xrun m.xe
you can sim and look at the pads/pins of the chip if you get rid of the delays so that you can see something happen in a reasonable length sim
xsim --max-cycles 2000 --vcd-tracing "-o m.vcd -ports -cycles -threads -timers -instructions -functions -pads" m.xe
but gtkwave doesnt like the syntax so to view that m.vcd file with gtkwave I have to edit the .vcd file and
from: $var wire 1 paa10 0:X0D61 $end to: $var wire 1 paa10 X0D61 $end
Basically remove the 0: for all the paa variable definition lines.
With the above assembler x0d14, x0d15, x0d19, x0d20 are the pads that wiggle can see the connection from their documentation.
That magic number comes from an include file:
#define XS1_PORT_4C 0x40200
EDIT 6
Henk, thanks for jumping in to help. I was reviewing how far I had gotten and didnt understand the 0x6 and the setclk stuff and was going to have to re-ask a question or dig deeper. The code below does start to wiggle the port but then the xcore appears to do a thread swap and hang essentially, so it still isnt quite the simple program I was hoping for. And I understand this isnt a simple core (which is why I want to understand it at this level to make the most out of it).
.globl _start _start: ldc r1, 100 notmain: sub r1,r1,1 bt r1, notmain ldc r3,0x4020 shl r3,r3,4 setc res[r3],0x8 top: ldc r0, 0x8 out res[r3], r0 ldc r0, 0x4 out res[r3], r0 ldc r0, 0x2 out res[r3], r0 ldc r0, 0x1 out res[r3], r0 ldc r0, 0x2 out res[r3], r0 ldc r0, 0x4 out res[r3], r0 bu top