Use PropGCC's native interface to blink an LED from each of the Propeller's 8 cogs. Each cog will be invoking instructions out of HUB memory, not COG memory. For a simpler and more object-oriented way to start new cogs, check out PropWare::Runnable
cmake_minimum_required(VERSION 3.3)
project(MultiCogBlinky_Demo)
create_simple_executable(${PROJECT_NAME} MultiCogBlinky_Demo.cpp)
const uint16_t COGS = 8;
const uint16_t STACK_SIZE = 16;
static uint32_t cog_stack[STACK_SIZE][COGS];
static _thread_state_t thread_data;
volatile uint32_t wait_time;
volatile uint32_t startCnt;
volatile int8_t syncStart;
int main(
int argc,
char *argv[]) {
int8_t n;
int8_t cog;
uint32_t nextCnt;
};
wait_time = 50 * MILLISECOND;
syncStart = 0;
for (n = 1; n < COGS; n++) {
cog = (int8_t) _start_cog_thread(cog_stack[n] + STACK_SIZE,
run_cog, (
void *) &pins[n], &thread_data);
}
startCnt = CNT;
syncStart = 1;
nextCnt = wait_time + startCnt;
while (1) {
nextCnt = waitcnt2(nextCnt, wait_time);
nextCnt = waitcnt2(nextCnt, wait_time);
}
}
uint32_t nextCnt;
while (syncStart == 0);
nextCnt = wait_time + startCnt;
while (1) {
nextCnt = waitcnt2(nextCnt, wait_time);
}
}