Need an example of how to write to an array in the hub from the assembler in a cog.
frank freedman
Posts: 1,983
Now that the ADC function is working, I am looking for an example of how to write into an array in the hub established by the C part of the program from the high speed asm function in a cog. What I have tried does not quite work.
Thanks,
Frank
Thanks,
Frank
Comments
You could let the C compiler do the "heavy lifting" of accessing the array:
Once you get this code to compile, you can read the assembler that the compiler generates, and replace the "array[index] = value" line in the source code by assembly code if it's too inefficient.
===Jac
Just plain wrlong (or wrbyte) should work fine. You'll need to get the address of the array into a register, of course -- that can be done either by passing the array address in PAR, or by using the GAS assembler and accessing the array label directly. See the gas_toggle demo for an example of the latter (it uses some integer variables rather than arrays, but the principle is exactly the same).
Jac's suggestion of looking at the assembler output of the C compiler is also a good one.
Eric
Thanks,
Frank
Hi Frank,
I added some simple things to the gas_toggle demo and was able to write values back to the mailbox address.
If you need fill an array, you will need to pass the array base address through the mailbox and save the address using the cog code.
Maybe you can post an example of what you have now?
Thanks,
FF
what I have:
clockgen_firmware.s
acq_firmware.s
ADC.c
First real hack in C in many years, not that much time with it to begin with though.
Hi Frank,
Could you post some code (even if they're only fragments), or perhaps give us a better idea of what you're working on? We might be able to help you better that way. We can't tell you what you're doing wrong if we have to guess what you're doing...
===Jac
Eric