George Shering
Posts: 11
Joined: Tue Dec 16, 2014 8:14 am

fifo and multicore.h

Sun Apr 11, 2021 2:22 pm

Problem 1:
I do not seem to have pico/multicore.h. is there something wrong with my installation.

Problem 2:
I feed sequences of 10 char into a hardware UART with fifos enabled. It only sees a single char, the first one, correctly . I feed the second UART in parallel using the interrupt to receive the data and I get all 10 correctly. The fifo is enabled? do I need to allocate memory for it somehow?

Please help.

EvanEscent
Posts: 28
Joined: Thu Apr 01, 2021 10:45 pm
Location: Blighty
Contact: Website Yahoo Messenger Facebook Skype Twitter

Re: fifo and multicore.h

Sun Apr 11, 2021 2:45 pm

Re [2]: maybe a daft question but are you waiting for the fifo
to empty before you send additional data? If not you'll lose it.
I read, I tinker, I test, I repeat.
Sometimes I learn.

lurk101
Posts: 581
Joined: Mon Jan 27, 2020 2:35 pm
Location: Cumming, GA (US)

Re: fifo and multicore.h

Sun Apr 11, 2021 3:05 pm

EvanEscent wrote:
Sun Apr 11, 2021 2:45 pm
Re [2]: maybe a daft question but are you waiting for the fifo
to empty before you send additional data? If not you'll lose it.
You shouldn't need to wait for empty. Better to wait for 'not full'.
The old semiconductor paradigms are rapidly becoming a thing of the past.
Today, it's about the best transistors, architectures, and accelerators for the job.

EvanEscent
Posts: 28
Joined: Thu Apr 01, 2021 10:45 pm
Location: Blighty
Contact: Website Yahoo Messenger Facebook Skype Twitter

Re: fifo and multicore.h

Sun Apr 11, 2021 3:39 pm

lurk101 wrote:
Sun Apr 11, 2021 3:05 pm
EvanEscent wrote:
Sun Apr 11, 2021 2:45 pm
Re [2]: maybe a daft question but are you waiting for the fifo
to empty before you send additional data? If not you'll lose it.
You shouldn't need to wait for empty. Better to wait for 'not full'.
This is true, depending on the responsiveness of the code.
I used empty imprecisely when I meant what you said. :)
I read, I tinker, I test, I repeat.
Sometimes I learn.

George Shering
Posts: 11
Joined: Tue Dec 16, 2014 8:14 am

Re: fifo and multicore.h

Sun Apr 11, 2021 3:59 pm

char numbytes;
while(1)
{
index=0;
dshot(100,1); // asks for 10 characters
busy_wait_us_32(2000);
numbytes=uart_is_readable(uart0);
if (numbytes>0)
{
for (int i=0;i<numbytes;i++) SerialBuf = uart_getc(uart0);

Wait 20ms then loop. numbytes is always 1. and SerialBuf[1] is changing and correct.
Reading the character on interrupt and filling the array there gives the same first character and the correct subsequent characters. I also checked on an oscilloscope.
Tried uart_set_fifo_enabled(uart0, true); both true and false.
it seems that there is never more than 1 byte in the buffer.

kilograham
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 618
Joined: Fri Apr 12, 2019 11:00 am
Location: austin tx

Re: fifo and multicore.h

Sun Apr 11, 2021 3:59 pm

George Shering wrote:
Sun Apr 11, 2021 2:22 pm
Problem 1:
I do not seem to have pico/multicore.h. is there something wrong with my installation.
Please help.
You need to add pico_multicore to the target_link_libraries of your application; worth reading chapter 2 here https://datasheets.raspberrypi.org/pico ... -c-sdk.pdf

George Shering
Posts: 11
Joined: Tue Dec 16, 2014 8:14 am

Re: fifo and multicore.h

Mon Apr 12, 2021 4:24 pm

multicore.h
I am trying to generate uart_rx whidh uses multicore
Thanks for the tip kilograham. I have started reading, but also to progress tried to generate uart_rx as a stand-alone example.
got as far as

-- Configuring done
CMake Error: Error required internal CMake variable not set, cmake may not be built correctly.

CMakeLists.txt is:

cmake_minimum_required(VERSION 3.16)
set(PICO_SDK_PATH /home/george/pico/pico-sdk)
include(pico_sdk_import.cmake)

project(uart_rx)

pico_sdk_init()

add_executable(pio_uart_rx)

pico_generate_pio_header(pio_uart_rx /home/george/pico/uart_rx/uart_rx.pio)

target_sources(pio_uart_rx PRIVATE uart_rx.c)

target_link_libraries(pio_uart_rx PRIVATE
pico_stdlib
pico_multicore
hardware_pio
)

pico_add_extra_outputs(pio_uart_rx)

Any suggestions?

kilograham
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 618
Joined: Fri Apr 12, 2019 11:00 am
Location: austin tx

Re: fifo and multicore.h

Mon Apr 12, 2021 6:03 pm

do

Code: Select all

project(pio_uart_rx C ASM)
and recreate an empty build directory again first.

George Shering
Posts: 11
Joined: Tue Dec 16, 2014 8:14 am

Re: fifo and multicore.h

Mon Apr 12, 2021 8:28 pm

Thanks kilograham. I see my mistake. It generates with project(pio_uart_rx).
But I had to remove the C ASM parts. I hope it will run.
I don't understand the "Code: Select all". It rejected that also.
Maybe as I read more!
I am developing on Ubuntu 20.04 on Intel!

pic0
Posts: 48
Joined: Tue Jan 26, 2021 11:04 am

Re: fifo and multicore.h

Mon Apr 12, 2021 10:17 pm

Hi,
George Shering wrote:
Mon Apr 12, 2021 8:28 pm
I don't understand the "Code: Select all". It rejected that also.
this is just a feature of this forum. "code" means this block is formatted for showing programming code. And when you click on "Select all", all of the code in this block will be selected so you can easy copy it.

George Shering
Posts: 11
Joined: Tue Dec 16, 2014 8:14 am

Re: fifo and multicore.h

Tue Apr 13, 2021 4:28 am

Code tested and runs. Thanks again kilograham.
I will ask on a more appropriate forum about the hardware uart fifo problem.

Return to “SDK”