I'm trying to get multicore working on my pico,
#include <stdio.h>
#include "pico/stdlib.h"
#include "pico/multicore.h"
void core1_main()
{
stdio_init_all();
while (1)
{
uint32_t t = multicore_fifo_pop_blocking();
printf("hellow world %d \n", t);
}
}
int main()
{
multicore_launch_core1(&core1_main);
uint32_t i = 0;
while (1)
{
sleep_ms(250);
multicore_fifo_push_blocking(i++);
}
}
This is a very basic task I'm trying to get to work. I'm trying to learn more about this multicore magic. Basically I'm starting waiting on core1 for some data to come through. Then I simply print it out and wait for the next piece of data.
On core 0 I push a number onto the FIFO once every 250ms.
I don't get any error in compilation but running the code produces no output whatsoever.
What am I doing wrong here? Is there something that I should pat attention to?
I've tried quite a few things to get something multicore, but no use.
UPDATE This gives me some output. I added a wait for the USB to get connected and initialised. Now I get some message from core 2.
#include <stdio.h>
#include "pico/stdlib.h"
#include "pico/multicore.h"
// const uint led = PICO_DEFAULT_LED_PIN;
void core1_main()
{
printf("hellow world from second core");
printf("hellow world from second core");
printf("hellow world from second core");
}
int main()
{
stdio_init_all();
while (!stdio_usb_connected())
;
while (!stdio_usb_init())
;
multicore_launch_core1(core1_main);
printf("hellow wow \n");
uint32_t i = 0;
while (1)
{
printf("hellow nice %d\n", i++);
sleep_ms(1000);
}
}
This is the output I get. Notice the message from second core comes through only once.I confused, why?
Also changing the position of stdio_init_all()
breaks something and no more output.