This shouldn't work
rjo__
Posts: 2,114
'Hack from one of Chip's example 'Sends any received characters from PST back to PST at 3,000,000 baud CON 'Baud and pin settings SYS_CLK = 80_000_000 BAUD_RATE = 3000000 RX_PIN = 63 TX_PIN = 62 dat org hubset #$FF wrpin pm_tx, #TX_PIN 'set asynchronous tx mode in smart pin wxpin bitper, #TX_PIN 'set tx bit period wrpin pm_rx, #RX_PIN 'set asynchronous rx mode in smart pin wxpin bitper, #RX_PIN 'set rx bit period or dirb, #TX_PIN or dirb, #RX_PIN .recv rdpin y,#RX_PIN 'get data from rx pin shr y,#32-8 .send wrpin y,#TX_PIN 'send back received character jmp #.recv pm_tx long %1_11_11100_0000_0000_00_0_0000000000000 'async tx byte mode pm_rx long %1_10_11110_0000_0000_00_0_0000000000000 'async rx byte mode bitper long SYS_CLK/BAUD_RATE 'number of clocks per bit period, 3..65536 x long 0 y long 0
serial at 3MBaud in 4 actual lines of code...wtf?
no ptest or anything:)
BUT that isn't what gets me... what get's me is... (and thank you to Ozpropdev for getting this into my brain):
dat orgh file "rjoVGA_640_x_480_8bpp.obj" file "simpleserialecho.obj"
This actually works... go figure.
but of course this doesn't work:
DAT orgh file "simpleserialecho.obj" file "rjoVGA_640_x_480_8bpp.obj"
As an ex-FBI director recently said...
There are lots of questions.
Rich
Comments
Here's a working version: (reduced to 2 Mbaud for my system) EDIT: Updated asynconfig to use floating point so it's not limited to 32-bit maths
So, universal arrangement should be
tanks
… I've spent the last few days discovering that I removed a jumper from all but one of my Propcams… and that is why nothing worked. I don't know how I am going to debug my brain. What I currently do is play sudoku and if I don't win I either take a nap or watch Fox business until I can win at sudoku... but I did that and still wasted two days looking in all the wrong places to figure out my issue.
This is a question straight out of my mythical autonomous wheelchair project:
I know how to use a serial line to load code into the lut of a running cog…but once I do that how do I change to lut exec to actually execute from there?
My code in cogexec should end with?
That's pretty useful actually. The namespace gets crowded with big codes...
Make sure the target copying address matches the specified ORG address. As Cluso mentioned, using SETQ2 is the way to do the copying. Eg:
Either way... time for a drink!!!
Thanks
So, it's up to you to make sure the ORG'd code/data actually gets placed in the desired location at run time.
It maybe that the loaded address and the assembler ORG directive are the same address, in which case there is nothing to copy, but with something like lutram you can be sure you'll be needing to do the copying within your program.
A jump to the newly loaded code with address in the $200 to $3FF range.
https://forums.parallax.com/discussion/165903/how-to-write-lut-exec-assembly-code
This would allows dynamic programming without the need to reboot or reset the P2.
Maybe it isn't possible.
Don't see why that would not be possible unless I missed some serious changes recently. Being able to run code from or store data in lut was possible a while back in the chip design.
It's important to be comfortable with using ORG. You're still going to be using it for making explicit lutexec code. That's why I'm making some effort to explain its general use.
I just wanted to make sure you understood what I am trying to do. Start in cog exec... load a binary over a serial line... execute that binary in Lut exec and then switch back to cog exec. It seems like there should be a register or switch somewhere:)
Thanks
it is just that between COG ram and LUT ram is a small space for the special registers so COG code can not just extend into LUT you need to JMP/CALL into the memory above $1FF.
So If you compile your snippets with org $200 you can load them anywhere in HUB ram, load them into the LUT with setq2 and rdlong and call #$200 from HUBexec. Running code in the LUT and returning to HUBexec when done.
All this would run on the same COG.
Enjoy!
Mike
You are overthinking it. Once you have loaded the code into LUT you simply jump to it (or CALL it) in the address range of $200 - $3ff. On completion, the code executing in LUT simply jumps back (or RETs) to the code in COG space. There are some specific limitations on code running in LUT, but kicking off execution is dead simple.
I think we are close enough so that I can tinker a bit. But first … just to be sure:)
If I combine https://forums.parallax.com/discussion/165903/how-to-write-lut-exec-assembly-code with the answers you and Evanh have offered... it seems like all I have to do is:
Compile the lut code with org $200 declared. Load the resulting binary into the lut using a serial line from CogExec and then jmp to $200 once it has loaded.
Does that sound about right?
When I want to go from LutExec back to CogExec is it just another jmp? (to where)? Maybe issue a coginit at that point from the lut?
well the jmp back can go anywhere you want. The simplest way would be a call into LUT and a ret to return to the line in HUBexec after the call to LUT
Enjoy!
Mike
Easy to compile a code snippet for LUT. Just ORG $200 (as has been said). Now you can download that, or serial load it, or whatever, directly (if you like - preferred in your example) into LUT.
Then you can CALL or JMP to LUT to execute it if you are loading it via the same COG,
Now, if you want to make extra space available (for code and register space) you can run the COG/LUT loading code from HUB in HUBEXEC mode, and then CALL/JMP to COG/LUT.
BTW DrAcula wrote code to do this sort of thing on P1 for COG called COGLETS IIRC. Try searching for his thread.