Giter Site home page Giter Site logo

arduino_opencm3's People

Contributors

evark avatar serasidis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

arduino_opencm3's Issues

USART gibberish

The USART always sent gibberish even after trying many baudrates and parities.

I adapted the boards.txt and platform.txt to allow using a USB to serial adapter while waiting for a new ST-Link. The adapter uses the CP210x type chip and worked fine to upload the opencm3 bin to the generic STM32f103c board using the stm32flash program. The STM32 embedded bootloader requires 8e1 mode to send the bin to flash. My system is linux64 with kernel 4.10 and arduino 1.8.0.

I modified the ~/Arduino/hardware/arduino_opencm3/stm32/cores/opencm3/Uart.cpp to fix the problem.


Old:
    usart_set_baudrate(usart, baudrate);
    //usart_set_databits(usart, bits);
    //usart_set_stopbits(usart, stopbits);
    //usart_set_parity(usart, parity);
    usart_set_flow_control(usart, USART_FLOWCONTROL_NONE);
    usart_set_mode(usart, USART_MODE_TX_RX);
    rxBuffer.clear();
    txBuffer.clear();
    txRunning=false;
    usart_enable_rx_interrupt(usart);
    usart_enable(usart);

New:
    usart_set_baudrate(usart, baudrate);
    usart_set_databits(usart, HARDSER_DATA_8);    /* fixed */
    usart_set_stopbits(usart, USART_STOPBITS_1);  /* fixed */
    usart_set_parity(usart, USART_PARITY_EVEN);   /* fixed */
    usart_set_flow_control(usart, USART_FLOWCONTROL_NONE);
    usart_set_mode(usart, USART_MODE_TX_RX);
    rxBuffer.clear();
    txBuffer.clear();
    txRunning=false;
    usart_enable_rx_interrupt(usart);
    usart_enable(usart);

The USART databits, stopbits and parity settings were commented out in the original code. That might have left the USART unconfigured and causing the gibberish to be sent. Just adding these values suddenly allowed the USART to communicate correctly. I don't know why the code was at some point commented out and if that might affect anything else like USB for example. I also doubt my fix is the best technique to solve the problem.

The arduino examples now mostly work in my setup (except for the two opencm3 versions). The adc-test.cpp even works directly as adc-test.cpp.ino within the arduino ide and shows a lot of libopencm3 code. That example might be enough for my purposes of experimenting and learning as a beginner with arduino, libopencm3, stm32 and C. I might spend more time with arduino_opencm3 now that serial communication and Serial.println works under my conditions.

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.