XMMC and cog threads
Hi all, I have some time today and am having fun playing.
I am wondering if I can use cog threads with the XMMC from my SD card on my GG PPUSB board.
This is a simple example of what I am trying to do.
LMM and PPUSB works:
I am wondering if I can use cog threads with the XMMC from my SD card on my GG PPUSB board.
This is a simple example of what I am trying to do.
/**
* @file cog_thread.c
* This is the main cog_thread program start point.
*/
#include <stdio.h>
#include <sys/thread.h>
#include <propeller.h>
#define STACK_SIZE 16
static int cogStack[STACK_SIZE];
static _thread_state_t threadData;
void cogFunc(void *arg);
/**
* Main program function.
*/
int main(void)
{
int cogID;
waitcnt(CNT + CLKFREQ);
cogID = _start_cog_thread(cogStack+STACK_SIZE, cogFunc, (void*)0, &threadData);
printf("CogID: %d\n", cogID);
return 0;
}
void cogFunc(void *arg)
{
for(;;) {
waitpeq(0x00, 0x01 << 16);
}
}
LMM and PPUSB works:
CogID: 1XMMC and PPUSB-SDXMMC does not:
CogID: -1

Comments
According to http://propgcc.googlecode.com/hg/doc/Library.html, _start_cog_thread is LMM-only and will always return an error in the XMM* modes. It is a limitation of the XMMC and XMM kernels that you can have only one running XMM C cog, so you must use pthreads (http://forums.parallax.com/showthread.php?137776-What-is-a-pthread) to get multithreading. You can also load additional cogs with PASM and cog-mode C programs.
The rest of the PropGCC users might be more sure to see and respond if you posted follow-up questions in the Propeller GCC Alpha Test Forum?
Yes, I meant to put the original post in that sub thread.
A good place to start might be the demos. Check out the propboe demo, especially the propboe/libsrc subdirectory - the I2C driver is written in cog mode C.