• 0

esp32: different use of UART pins: id as paramter directly


Question

hello dear folks, 

 

the UART-use is somewhat interesting: we hafe pin id as paramter directly, eg:

    u=UART(1,9600,tx=4,rx=5)

But in SPI/I2C, it is use pin object, eg:
 

    i2c=I2C(1,sda=Pin(14),scl=Pin(15))

i see some issues here:
- Not all ports support is set eg the tx/rx pins
- some of the existing ports (e.g. esp8266) are related to a so called  machine.Pin while others (e.g. esp32) take a pin number.


from what i see in the docs:

 

cf  the docs https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/peripherals/uart.html

  Quote

 

The following overview describes functions and data types used to establish communication between ESP32 and some other UART device. The overview reflects a typical workflow when programming ESP32’s UART driver and is broken down into the following sections:

Setting Communication Parameters- baud rate, data bits, stop bits, etc,

Setting Communication Pins- pins the other UART is connected to

Driver Installation- allocate ESP32’s resources for the UART driver

Running UART Communication- send / receive the data

Using Interrupts- trigger interrupts on specific communication events

Deleting Driver- release ESP32’s resources, if UART communication is not required anymore

The minimum to make the UART working is to complete the first four steps, the last two steps are optional.

The driver is identified by uart_port_t, that corresponds to one of the tree UART controllers. Such identification is present in all the following function calls.

Setting Communication Parameters

There are two ways to set the communications parameters for UART. One is to do it in one shot by calling uart_param_config()provided with configuration parameters in uart_config_tstructure.

The alternate way is to configure specific parameters individually by calling dedicated functions:

Baud rate - uart_set_baudrate()

Number of transmitted bits - uart_set_word_length()selected out of uart_word_length_t

Parity control - uart_set_parity()selected out of uart_parity_t

Number of stop bits - uart_set_stop_bits()selected out of uart_stop_bits_t

Hardware flow control mode - uart_set_hw_flow_ctrl()selected out of uart_hw_flowcontrol_t

Communication mode - uart_set_mode()selected out of uart_mode_t

 

 

 

 

Expand  

Configuration example:

 

    const int uart_num = UART_NUM_2;
    uart_config_t uart_config = {
        .baud_rate = 115200,
        .data_bits = UART_DATA_8_BITS,
        .parity = UART_PARITY_DISABLE,
        .stop_bits = UART_STOP_BITS_1,
        .flow_ctrl = UART_HW_FLOWCTRL_CTS_RTS,
        .rx_flow_ctrl_thresh = 122,
    };
    // Configure UART parameters
    ESP_ERROR_CHECK(uart_param_config(uart_num, &uart_config));


any idea why this is so.

 

any idea why this is so...

1 answer to this question

Recommended Posts

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Yeah, I've looked at all of these. Dante is a pro and expensive program, of course. I'm just looking for simple audio/music sharing from one PC/device to another. Voicemeeter is a lovely bit of kit, but the interface is NOT user friendly to set up initially, unless you are an audio engineer who thinks the way the program does. It works though. I just didn't feel the juice was worth the squeeze on that one. The other ones you mention have problems, like no longer maintained/updated, etc. Spotify does this, but only for music played by Spotify. Multiplicity does this (but isn't free) for all audio on one PC (like you'd want) but hiccups the audio on the source PC if too much CPU is used (so you really can't use a very old PC as a music/video/youtube player). If the two machines are side by side, you can use analog line out to analog line in, but then you are getting analog noise/problems. It's the simplest and most solution, of course.
    • Well, one right off the top of my head is if you're playing music on one computer but you want it coming through another computer, which is hooked up to speakers, a TV with built-in audio, etc. If the two machines are side-by-side, then you can even just use an old analog line jack out to line jack in but that comes with analog problems, of course. But if the two computers aren't in the same room and you're using something like Multiplicity (not the best example because Multiplicity actually has this audio network feature built in) to control the other, then sending the audio across ethernet would be highest quality. Note that Spotify also already does this. If you have the app installed on multiple devices you can control not only the song playback but also which device the audio is outputting from. Like your phone telling your PC to play the audio on the PC out to speakers. Etc. So, there are solutions. But when I saw it called "Shared Audio" I hoped it was a MS standard built into the OS for just this usage case, and not just a badly named new feature being tested.
    • Apple is giving the upcoming iPad Pro a second front-facing camera by Taras Buria The M4-based iPad Pro brought a few significant changes to Apple's high-end tablet, such as tandem OLED displays, a much-thinner chassis, camera changes, and a much more powerful processor. Its successor, the M5-based iPad Pro, is rumored to retain the current form factor without major changes. However, there is one rather odd hardware update that is coming with the next iPad Pro. A new report says that a successor to the current iPad Pro lineup will offer a more powerful Apple M5 processor and more cameras on the front. While Apple experimented with a dual-camera setup on the back of the recent iPad Pros (this was killed in the M4 generation), the front of every iPad has always had a single camera, minus the original one, of course, which had none. With the M5 iPad Pro, Apple is rumored to double the number of front-facing cameras for a rather odd reason. No, Apple is not using a dual-camera setup for depth of field effects or a wider angle. According to Bloomberg's Mark Gurman, the logic is much simpler: satisfy fans of the portrait orientation. The problem is that in the 2024 iPad Pro, Apple moved the front-facing camera to the longer side of the tablet, where it makes much more sense for FaceTime calls, selfies, and everything else. However, that makes the iPad a bit awkward to use when in portrait mode, especially when it comes to FaceID. Now, it appears that Apple wants to make both camps happy by adding another front-facing camera to the shorter side of the screen. There is no information on whether we will see just one more front-facing camera or the entire FaceID module. Given Apple's nature of blaming users for some of its device shortcomings (the infamous "you are holding it wrong" line), it is quite interesting to see Apple addressing a seemingly minor concern with such an overkill solution.
    • Hello! It's default behavior. I assume that F:\ and E:\ are external drives? My local drives are under This PC. So File Explorer is showing storage from different locations: This PC (under which are local drives) Mapped Network drives External USB drives The Network (under which, my NAS) You could drag the drive to Quick access to see it all the time, but in my case when I expand This PC, the local drives remain in view even when I close and reopen the window.
    • It also lost Window Share support, so can no longer share websites from Edge to it or files from Explorer using the Share button or photos from Photos app. Mind you, not that this is impossible from a webappp since the new Outlook does support Share and that's a web app.
  • Recent Achievements

    • Rookie
      Snake Doc went up a rank
      Rookie
    • First Post
      nobody9 earned a badge
      First Post
    • One Month Later
      Ricky Chan earned a badge
      One Month Later
    • First Post
      leoniDAM earned a badge
      First Post
    • Reacting Well
      Ian_ earned a badge
      Reacting Well
  • Popular Contributors

    1. 1
      +primortal
      496
    2. 2
      Michael Scrip
      206
    3. 3
      ATLien_0
      201
    4. 4
      Xenon
      136
    5. 5
      +FloatingFatMan
      117
  • Tell a friend

    Love Neowin? Tell a friend!