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.12)
project(MultiCogBlinky_Demo)
create_simple_executable(${PROJECT_NAME} MultiCogBlinky_Demo.cpp)
static const uint16_t COGS = 8;
static const uint16_t STACK_SIZE = 16;
static uint32_t cog_stack[STACK_SIZE][COGS];
static volatile uint32_t wait_time;
static volatile uint32_t startCnt;
static volatile int8_t syncStart;
int main(
int argc,
char *argv[]) {
int8_t n;
int8_t cog;
Pin pin;
uint32_t nextCnt;
const Pin::Mask pins[] = {
Pin::P16,
Pin::P17,
Pin::P18,
Pin::P19,
Pin::P20,
Pin::P21,
Pin::P22,
Pin::P23
};
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);
}
pin.set_mask(pins[0]);
pin.set_dir_out();
syncStart = 1;
nextCnt = wait_time + startCnt;
while (1) {
pin.set();
pin.clear();
}
}
Pin pin;
uint32_t nextCnt;
pin.set_mask(*(Pin::Mask *) arg);
pin.set_dir_out();
while (syncStart == 0);
nextCnt = wait_time + startCnt;
while (1) {
pin.toggle();
}
}