Giter Site home page Giter Site logo

pico_dma_uart's People

Contributors

dipswitch avatar rossihwang avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

pico_dma_uart's Issues

Continuous UART read data on uart_dreq using DMA on Pico

Hello,
I'm using dma to read data from neo m8n gps module, it sends nmea sentences every 100 ms.
Since it's a lots of data roughly an uint8_t 400 element array.
So, I set up the dma and uart as following but I'm not able to read data more than 64 bytes. Only the ring buffer is creating problems here, if it's set to values more that 6 the the pico along with usb hangs. My keyboard and mouse also don't works or malfunctions😂.

//-----------------------------------------------------------------//
#include <string.h>
#include <pico/time.h>
#include <stdio.h>
#include "pico/stdlib.h"
#include <hardware/dma.h>
#include <hardware/uart.h>

#define gps_buf_max_expctd_len 64
uint32_t gps_raw_buff[gps_buf_max_expctd_len];

static void UART_setup(int baud){
uart_init(uart1, 2400);
gpio_set_function(8, GPIO_FUNC_UART);
gpio_set_function(9, GPIO_FUNC_UART);
int __unused actual = uart_set_baudrate(uart1, baud);
uart_set_hw_flow(uart1, false, false);
uart_set_format(uart1, 8, 1, UART_PARITY_NONE);
uart_set_fifo_enabled(uart1, false);
}

static void configure_dma() {
int chan = 0;//dma_claim_unused_channel(true);
dma_channel_config config = dma_channel_get_default_config(chan);
channel_config_set_transfer_data_size(&config, DMA_SIZE_8);
channel_config_set_read_increment(&config, false);
channel_config_set_write_increment(&config, true);
channel_config_set_ring(&config, true, 6);
channel_config_set_dreq(&config, uart_get_dreq(uart1, false));

dma_channel_configure(
    chan,
    &config,
    gps_raw_buff,
    &uart1_hw->dr,
    UINT32_MAX,
    true
);

}

int main() {

stdio_usb_init();
UART_setup(9600);
sleep_ms(100);
GPS_init();
configure_dma();


while(1){
    sleep_ms(100);


    printf("%.*s\n------------------------------\n", gps_buf_max_expctd_len, gps_raw_buff);
    
}

}

Note: uart and usb both enabled at CMakeLists.txt
Also gps data rate10Hz, and baud115200(including pico uart to 115200) was set using GPS_init();

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.