Ordering res and other data in your DAT section (not urgent, looking for some documentation)
I likely missed this in the documentation but I can't seem to find it....
I was having trouble accessing declarer data in my DAT sections. I found the problem but I can't seem to find where this behavior is explained. Here is some sample code that shows the problem
PUB start DIRA := 1 OUTA := 1 flag := 0 cognew(@SetPASM, @flag) repeat while (flag == 0) OUTA := 0 DAT org 0 SetPASM mov value, #1 mov time, delay add time, cnt waitcnt time, #0 wrlong value, PAR Loop jmp #Loop delay long 6_000 ' With this line the program works as expected value res 1 time res 1 flag long 0 'delay long 6_000 ' With that line commented out and this line included, the program appears to hang
The program should turn the LED on, start a cog running the PASM, and wait for it to set the flag then turn the LED off. I was finding that this only works with
delay is defined before any of the
res items. When it is declared after, the program just hangs. From some debugging I can see that once loaded in PASM
delay does have a non-zero value, but I think it is so small that by the time it calls
waitcnt the counter register is already holding a higher value than time, so program is effectively waiting counter register to roll over, making it looks like it is hung.