Different memory modes (one cog compiled as COG RAM)
whicker
Posts: 749
I've tried reading through the documentation but my question remains:
I would like to use a SimpleIDE project that primarily uses one of the larger memory modes like LMM or CMM.
However, I still would like to start another separate driver cog with C code compiled with the COG RAM memory model.
The majority of the code can be slow-ish, but the driver needs to be fast, but the driver shouldn't just be straight assembly language.
Here is what I understand so far:
The VGA text driver appears to launch another cog with this bit of arcane magick:
So it's essentially just starting a cog with assembled machine code in a huge byte array.
What I'm wanting is more of a maintainable and readable way of launching a cog driver that still written in C, more maintainable than that blob of hex code.
I have also seen references to a file type of .cogc, but don't know if this relates at all to what I want to do.
Could anyone offer any examples of how I would go about starting COG Ram C complied code in an otherwise LMM or CMM project?
The driver is mostly self-contained, but wants to access a block of memory in the hub ram (pass it a pointer, obviously), and of course has a few startup parameters (what pins to use, etc). I feel it's pretty generic enough to not get too specific.
I would like to use a SimpleIDE project that primarily uses one of the larger memory modes like LMM or CMM.
However, I still would like to start another separate driver cog with C code compiled with the COG RAM memory model.
The majority of the code can be slow-ish, but the driver needs to be fast, but the driver shouldn't just be straight assembly language.
Here is what I understand so far:
The VGA text driver appears to launch another cog with this bit of arcane magick:
static vgaSpin thisobj; static uint8_t dat[] = { 0x4f, 0xa8, 0xfd, 0xa0, 0x08, 0xb0, 0xfd, 0xa0, 0xd4, 0xaa, 0xbd, 0x5c, 0x02, 0xb0, 0xfd, 0xe4, 0xe7, ... }; ... Okay = (thisobj.Cog = (cognew((int32_t)(&(*(int32_t *)&dat[0])), Vgaptr) + 1));
So it's essentially just starting a cog with assembled machine code in a huge byte array.
What I'm wanting is more of a maintainable and readable way of launching a cog driver that still written in C, more maintainable than that blob of hex code.
I have also seen references to a file type of .cogc, but don't know if this relates at all to what I want to do.
Could anyone offer any examples of how I would go about starting COG Ram C complied code in an otherwise LMM or CMM project?
The driver is mostly self-contained, but wants to access a block of memory in the hub ram (pass it a pointer, obviously), and of course has a few startup parameters (what pins to use, etc). I feel it's pretty generic enough to not get too specific.
Comments
Have a look in the propgcc demos.
There is propgcc/demos/toggle/cog_c_toggle which contains about the simplest example of running an LMM main program which starts function to toggle a LED that runs entirely in cog. Just like starting PASM from Spin except the COG code is written in C.
full_duplex_serial_ht also does this but this time the COG code is a complete full duplex serial receiver and transmitter running in two "threads". Works up 115200 baud.
https://code.google.com/p/propside/source/browse/#hg%2Fpropside-demos%2FC-VGA
vgademo.c is the main program for LMM/CMM. vga.cogc is the driver.
The demo draws rectangles, but can be extended.
It looks like using _COGMEM in relevant global variable declarations,
and _NATIVE void main(...) is a key to the answer.
I'll try and run with that.
Another useful site is here: https://sites.google.com/site/propellergcc/
These first two are supposed to be merged somehow later ....
Then there is the learn.parallax.com site: parallax http://learn.parallax.com/propellerc