multicore conflict happened in using microSD card and fdserial
KevinKK
Posts: 27
I try to make a project that ActiviryBot can navigate/avoid with a mounted turning Ping))) sensor , play music from microSD card and communicate with Bluetooth. I try to use three additional cogs, however, the playing microSD card cog and bluetooth communication cog just can't run correctly in the same program. When I block either of the two cogs, the problem will not happen.
Does anyone can tell me that the two cogs can't open it simultaneously ? mult.c
Does anyone can tell me that the two cogs can't open it simultaneously ? mult.c
Comments
You call SD_mount from the main program and wav_play as well. You're also starting up a separate cog with play_sound which also calls sd_mount and wav_play. You can't do that. You can use locks (semaphores) to prevent both cogs from accessing sd_mount and wav_play at the same time.
In bt_control, you're using global variable c. As long as you don't use c from another cog, you should be ok. It's better to either use local variables or make up a unique name like bt_control_c that's harder to accidentally use from more than one cog.
Here's how your using your cogs:
cog 0: main
cog 1: fdserial
cog 2: play_sound
cog 3: turn_table
cog 4: bt_control
cog 5: sd driver
cog 6: wav_play streamer
cog 7: wav_play audio output
nonexistent cog 8: servos which don't run because there are no more cogs for it
EDIT: wav_play does sd_mount, but sd_mount is probably smart enough not to have two SD drivers, so this probably doesn't matter.
Stopping any other cog will let the servos get a cog, which is why the servos only work if you comment out the SD or bluetooth cogs starts.
Also, you should probably get rid of the curly braces on this line: The prototypes don't agree. You're putting an array of arrays of chars (an array of strings) into an array of chars (a string). I'm surprised that line compiles.
EDIT: The prototypes do agree. It's an array of arrays, not an array of pointers to arrays. It will still be less confusing if you get rid of the curly braces.