Due to size constraints I'm designing a custom PCB with audio codec to use with Bela software. My design requirements are 8 balanced output channels and at least 2 input channels.

I was thinking of using a Cirrus Logic CS42448 as it is readily available at Mouser (2000+ in stock), I have a few already here at home, it has differential DAC outputs and I've used this part before paired with a STM32 (in TDM follower/slave mode, clock generated by STM32 PLL). The CS42448 has no PLL clock generator so I would need to include a crystal on the PCB myself right? I noticed that both the Bela itself and the CTAG cape use a codec with built-in PLL? Why? Can the Beaglebone not generate a quality clock?

The thought crossed my mind to use the AD1938 instead as that codec is already implemented in the Bela core. I found that it only has single ended outputs and found then the AD1939 which looks like it's exactly the same but has differential outputs and thus a larger package. Both the AD1939 and AD1939 are out of stock at Mouser and I can't find application notes on recommended buffers for balanced I/O (which I was able to find for Cirrus Logic codecs..).

Anything I should keep in mind if I'm going to design a board around the CS42448?
- include a 12.288 MHz crystal (Fs * 256) on the board.
- write an I2C (or SPI) startup routine to configure the codec before audio starts.
- configure the codec to use a bit depth of 16 bit

I was also wondering. The audio I/O being 16 bit on the Bela, does that have to do with PRU <--> application communication or hardware limitations?

    Ward which I was able to find for Cirrus Logic codecs.

    those should work just fine for the AD1938 (which is in stock as AD1938WBSTZ-RL from DigiKey).

    Ward he CS42448 has no PLL clock generator so I would need to include a crystal on the PCB myself right?

    yes, unless you are happy with the non-standard-audio clocks you'd get dividing down the 24MHz clock from the BBB.

    Ward Can the Beaglebone not generate a quality clock?

    It generates several, but they normally don't make good master clocks for audio purposes (i.e.: they don't divide down nicely to 44.1k or 48k). I can't speak for their jitter/accuracy qualities.

    Ward I noticed that both the Bela itself and the CTAG cape use a codec with built-in PLL?

    I think the CTAG has a crystal and no PLL.

    Ward The audio I/O being 16 bit on the Bela, does that have to do with PRU <--> application communication or hardware limitations?

    The McASP can do basically any word length, shift and rotation. 16 bit is because it needs less space in RAM (i.e.: faster transfers between PRU RAM and ARM RAM) and especially on the Bela cape there is very little to gain going to 20 or 24 bit.

    Ward Anything I should keep in mind if I'm going to design a board around the CS42448?

    If the purpose is to use it with the Bela software, it's way easier to use an AD1938 and use the CTAG software without modifications, if you can abide by their Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License (https://github.com/ctag-fh-kiel/ctag-face-2-4), you even have schematics to start from. Just starting to navigate the giant mess that the PRU code is may take you weeks of intense work and desperation. It surely happens to me every time I have to go back to it!

    Ward - include a 12.288 MHz crystal (Fs * 256) on the board.
    - write an I2C (or SPI) startup routine to configure the codec before audio starts.
    - configure the codec to use a bit depth of 16 bit

    Seems about right. Matching the codec's settings to that of the McASP is a bit of a dark art and you are much better off with a decent scope with several digital inputs > 24MHz.

    • Ward replied to this.
      3 months later

      giuliomoro If the purpose is to use it with the Bela software, it's way easier to use an AD1938 and use the CTAG software without modifications

      So I designed a PCB with a AD1939 referencing the datasheet and evaluation board. As far as I can tell the only difference between the AD1938 (CTAG) and AD1939 (used here) is the balanced output directly on the converter. The PCB was designed according to the

      alt text

      I got the AD1939 to turn on and the control port working (the PCB is detected as CTAG FACE). Because I used a 12.228MHz crystal (while the CTAG uses a 24.576MHz OSC) I had to change Spi_Codec.cpp line 95, 186 and 191. After doing this the crystal started resonating and hitting run would cause the bitclock to run:

      alt text

      Now I sorta hoped that would be it but once the application is running it halts almost instantly:

      Using McASP IRQ embedded PRU firmware
      _________________Audio Thread!
      PRU interrupt timeout, -1 110 Connection timed out
      PRU interrupt timeout, -1 110 Connection timed out
      PRU interrupt timeout, -1 110 Connection timed out
      PRU interrupt timeout, -1 110 Connection timed out
      McASP error, abort
      PRU interrupt timeout, -1 110 Connection timed out
      Makefile:606: recipe for target 'runide' failed
      make: *** [runide] Error 1
      Bela stopped

      I guess now we arrive here:

      giuliomoro Matching the codec's settings to that of the McASP is a bit of a dark art and you are much better off with a decent scope with several digital inputs > 24MHz.

      So the only thing I can think of that needs to change is that McASP needs to now it'll receive all data on a 12.228MHz clock instead of 24.576MHz. Could you point to the right file?

      • Ward replied to this.

        Can you check with a scope that the bitclock actually generated? If the bit clock is generated at 256 cycles per frame, then you shouldn't need to change anything and it should run (may get some distortion due to some of the clock polarity / frame clock settings, but otherwise it should run).

        Currently the CTAG should be setting its McASP values in Spi_Codec::getMcaspConfig(). Not 100% sure they all get obeyed.

        • Ward replied to this.

          giuliomoro Can you check with a scope that the bitclock actually generated?

          This is the bitclock as output from the AD1939:

          12.288MHz / 256 = 48KHz so that looks as expected.

          Here is the bitclock together with the frame clock / LRCLOCK. This measures 48kHz so that also looks ok.

          alt text

          Both are running for about 40 milliseconds

          alt text

          Could it be that the LR clock behavior is different than expected by McASP? In the daisychain mode (which I assume is used by CTAG as they can stack two capes) it seems like the LR clock is toggling once for each channel (so each 32 bitclock cycles?) but what I see on my scope is it toggling halfway each frame.

          edit: this is probably not it. I checked all register settings in Spi_Codec against the datasheet and the frame / LR clock as generated by the codec is correct..

          edit 2: I also checked with a multimeter if all traces actually reach the beaglebone header and they do.

          You can compare the scope graphs between this and a stock CTAG to uncover any differences

          These are graphs from the CTAG cape:

          alt text

          alt text

          They look the same to me as my PCB. Both have a bitclock of 12.288MHz and a frameclock of 48kHz..

          I checked the pin wiring again on the schematics of my PCB and they should match the CTAG cape.

          data DAC	P9_28
          frameclock	P9_29
          data ADC	P9_30
          bitclock	P9_31

            Ward I checked the pin wiring again on the schematics of my PCB and they should match the CTAG cape.

            To avoid any doubts about wiring, check that the signals at the BBB pins are indeed exactly the same between the two (I am not sure where your probes are in the above graphs).

            This is scoped directly at the BBB pins P9_29 and P9_31

            As you can see below the frequencies seem correct and the signal reaches high and low enough to be registered as logic 0 and 1.

            alt text

            Honestly, that Min(C2) 400mV and Max(C2) 2.667V and the shape of the analog signal don't look too good. Unless that's an artifact of your scope (compare it with what you get from the CTAG cape?), then that may well be the source of your issue.

            The CTAG bitclock has a similar shape.

            alt text

            The AM335x datasheet mentions the signals to be LVCMOS which means the min and max range should be ok (if I am to believe my scope..)

            So I discovered oscilloscope probes can be calibrated and apparently the waveform is less triangly when the probes are set to 10x. So I measured both again.

            CTAG:
            alt text

            my PCB:
            alt text

            Not sure if this is relevant. Depending on what buffer size I select I get a different sequence of errors.

            Buffer size = 64:

            Using McASP IRQ embedded PRU firmware
            _________________Audio Thread!
            PRU interrupt timeout, -1 110 Connection timed out
            PRU interrupt timeout, -1 110 Connection timed out
            PRU interrupt timeout, -1 110 Connection timed out
            PRU interrupt timeout, -1 110 Connection timed out
            McASP error, abort
            PRU interrupt timeout, -1 110 Connection timed out
            Makefile:606: recipe for target 'runide' failed
            make: *** [runide] Error 1
            Bela stopped

            Buffer size = 32:

            Using McASP IRQ embedded PRU firmware
            _________________Audio Thread!
            PRU interrupt timeout, -1 110 Connection timed out
            PRU interrupt timeout, -1 9 Bad file descriptor
            PRU interrupt timeout, -1 9 Bad file descriptor
            PRU interrupt timeout, -1 9 Bad file descriptor
            PRU interrupt timeout, -1 9 Bad file descriptor
            PRU interrupt timeout, -1 110 Connection timed out
            PRU interrupt timeout, -1 110 Connection timed out
            PRU interrupt timeout, -1 110 Connection timed out
            McASP error, abort
            PRU interrupt timeout, -1 110 Connection timed out
            Makefile:606: recipe for target 'runide' failed
            make: *** [runide] Error 1
            Bela stopped

            Buffer size = 16 or lower:

            Using McASP IRQ embedded PRU firmware
            _________________Audio Thread!
            PRU interrupt timeout, -1 110 Connection timed out
            PRU interrupt timeout, -1 9 Bad file descriptor
            PRU interrupt timeout, -1 9 Bad file descriptor
            PRU interrupt timeout, -1 9 Bad file descriptor
            PRU interrupt timeout, -1 9 Bad file descriptor
            McASP error, abort
            PRU interrupt timeout, -1 9 Bad file descriptor
            *** Error in `/root/Bela/projects/polymetric-box/polymetric-box': free(): invalid pointer: 0x01f2edb0 ***
            Aborted
            Makefile:606: recipe for target 'runide' failed
            make: *** [runide] Error 134
            Bela stopped

              Ward PRU interrupt timeout, -1 9 Bad file descriptor

              what do you see in dmesg when that happens?

              Ward Error in `/root/Bela/projects/polymetric-box/polymetric-box': free(): invalid pointer: 0x01f2edb0

              this, combined with the above could mean something wrong with your code - either in the project or in the changes you made to the core. Try running a piece of simple example code (e.g.: Fundamentals/minimal).

              I doubt however that any of that has to do with the errors you are getting. By the way, do you see the USER3 LED on the board flash repeatedly when the program starts ?

              • Ward replied to this.

                giuliomoro what do you see in dmesg when that happens?

                [   64.543063] rtdm_pruss_irq_open
                [   64.548586] rtdm_pruss_irq_open
                [   65.869417] rtdm_pruss_irq_close
                [   65.869448] rtdm_pruss_irq_close
                [  158.445146] rtdm_pruss_irq_open
                [  158.449778] rtdm_pruss_irq_open
                [  159.765235] rtdm_pruss_irq_close
                [  159.765265] rtdm_pruss_irq_close

                dmesg prints a way longer list but not sure how far back you are looking?

                giuliomoro this, combined with the above could mean something wrong with your code - either in the project or in the changes you made to the core. Try running a piece of simple example code (e.g.: Fundamentals/minimal).

                So with Fundamentals/minimal buffer size does not affect the errors anymore:

                PRU interrupt timeout, -1 110 Connection timed out
                PRU interrupt timeout, -1 110 Connection timed out
                PRU interrupt timeout, -1 110 Connection timed out
                PRU interrupt timeout, -1 110 Connection timed out
                McASP error, abort
                PRU interrupt timeout, -1 110 Connection timed out
                Makefile:606: recipe for target 'runide' failed
                make: *** [runide] Error 1
                Bela stopped

                giuliomoro By the way, do you see the USER3 LED on the board flash repeatedly when the program starts ?

                I only see the heartbeat LED flashing.

                edit:

                I also found this in dmesg

                [    0.724091] ALSA device list:
                [    0.724102]   No soundcards found.

                and this

                [    1.861603] rtdm_pruss_irq: loading out-of-tree module taints kernel.
                [    1.862400] rtdm_pruss_irq version 2 loaded

                  Here's the whole thing:

                  [    0.415259] [] (__warn) from [] (warn_slowpath_fmt+0x58/0x74)
                  [    0.415274] [] (warn_slowpath_fmt) from [] (irq_set_chip+0xcc/0xdc)
                  [    0.415292] [] (irq_set_chip) from [] (irq_set_chip_and_handler_name+0x24/0x3c)
                  [    0.415315] [] (irq_set_chip_and_handler_name) from [] (gpiochip_irq_map+0x50/0xc8)
                  [    0.415332] [] (gpiochip_irq_map) from [] (irq_domain_associate+0x84/0x1f8)
                  [    0.415346] [] (irq_domain_associate) from [] (irq_create_mapping+0x144/0x1fc)
                  [    0.415360] [] (irq_create_mapping) from [] (gpiochip_to_irq+0x28/0x58)
                  [    0.415373] [] (gpiochip_to_irq) from [] (gpiod_to_irq+0x58/0x70)
                  [    0.415392] [] (gpiod_to_irq) from [] (gpio_is_visible+0x8c/0xac)
                  [    0.415415] [] (gpio_is_visible) from [] (internal_create_group+0xdc/0x30c)
                  [    0.415432] [] (internal_create_group) from [] (sysfs_create_groups+0x54/0x90)
                  [    0.415490] [] (sysfs_create_groups) from [] (device_add+0x4d0/0x618)
                  [    0.415507] [] (device_add) from [] (device_create_groups_vargs+0xc4/0xd0)
                  [    0.415522] [] (device_create_groups_vargs) from [] (device_create_with_groups+0x44/0x60)
                  [    0.415536] [] (device_create_with_groups) from [] (gpiod_export+0x178/0x398)
                  [    0.415551] [] (gpiod_export) from [] (gpio_request_one+0x114/0x12c)
                  [    0.415566] [] (gpio_request_one) from [] (devm_gpio_request_one+0x58/0x90)
                  [    0.415581] [] (devm_gpio_request_one) from [] (gpio_of_helper_probe+0x19c/0x64c)
                  [    0.415600] [] (gpio_of_helper_probe) from [] (platform_drv_probe+0x60/0xbc)
                  [    0.415615] [] (platform_drv_probe) from [] (driver_probe_device+0x298/0x478)
                  [    0.415628] [] (driver_probe_device) from [] (__driver_attach+0x110/0x12c)
                  [    0.415642] [] (__driver_attach) from [] (bus_for_each_dev+0x70/0xd0)
                  [    0.415656] [] (bus_for_each_dev) from [] (driver_attach+0x2c/0x30)
                  [    0.415668] [] (driver_attach) from [] (bus_add_driver+0x1d0/0x274)
                  [    0.415681] [] (bus_add_driver) from [] (driver_register+0x88/0x104)
                  [    0.415694] [] (driver_register) from [] (__platform_driver_register+0x50/0x58)
                  [    0.415719] [] (__platform_driver_register) from [] (gpio_of_helper_driver_init+0x20/0x28)
                  [    0.415738] [] (gpio_of_helper_driver_init) from [] (do_one_initcall+0x64/0x19c)
                  [    0.415757] [] (do_one_initcall) from [] (kernel_init_freeable+0x154/0x1f4)
                  [    0.415775] [] (kernel_init_freeable) from [] (kernel_init+0x18/0x11c)
                  [    0.415795] [] (kernel_init) from [] (ret_from_fork+0x18/0x24)
                  [    0.415814] ---[ end trace e7d829bd5b316d31 ]---
                  [    0.416834] gpio-of-helper ocp:cape-universal: ready
                  [    0.420180] wkup_m3_ipc 44e11324.wkup_m3_ipc: could not get rproc handle
                  [    0.421655] Serial: 8250/16550 driver, 6 ports, IRQ sharing disabled
                  [    0.425177] console [ttyS0] disabled
                  [    0.425275] 44e09000.serial: ttyS0 at MMIO 0x44e09000 (irq = 38, base_baud = 3000000) is a 8250
                  [    0.437097] console [ttyS0] enabled
                  [    0.440197] omap_hsmmc 48060000.mmc: Got CD GPIO
                  [    0.527353] libphy: Fixed MDIO Bus: probed
                  [    0.583511] davinci_mdio 4a101000.mdio: davinci mdio revision 1.6, bus freq 1000000
                  [    0.583529] davinci_mdio 4a101000.mdio: detected phy mask fffffffe
                  [    0.584188] MDIO: davinci_mdio: dt: updated phy_id[0] from phy_mask[fffffffe]
                  [    0.585973] libphy: 4a101000.mdio: probed
                  [    0.585998] davinci_mdio 4a101000.mdio: phy[0]: device 4a101000.mdio:00, driver SMSC LAN8710/LAN8720
                  [    0.587015] cpsw 4a100000.ethernet: Detected MACID = 00:35:ff:91:a3:37
                  [    0.587144] cpsw 4a100000.ethernet: initialized cpsw ale version 1.4
                  [    0.587154] cpsw 4a100000.ethernet: ALE Table size 1024
                  [    0.587201] cpsw 4a100000.ethernet: cpts: overflow check period 1250 (jiffies)
                  [    0.588512] mmc1: new high speed MMC card at address 0001
                  [    0.591846] mmcblk1: mmc1:0001 M62704 3.53 GiB 
                  [    0.595165] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
                  [    0.595213] ehci-platform: EHCI generic platform driver
                  [    0.595770] mmcblk1boot0: mmc1:0001 M62704 partition 1 2.00 MiB
                  [    0.596155] mmcblk1boot1: mmc1:0001 M62704 partition 2 2.00 MiB
                  [    0.596484] ehci-omap: OMAP-EHCI Host Controller driver
                  [    0.597318] usbcore: registered new interface driver usb-storage
                  [    0.598915] mmcblk1rpmb: mmc1:0001 M62704 partition 3 512 KiB
                  [    0.600727]  mmcblk1: p1 p2
                  [    0.605126] am335x-phy-driver 47401300.usb-phy: 47401300.usb-phy supply vcc not found, using dummy regulator
                  [    0.608365] am335x-phy-driver 47401b00.usb-phy: 47401b00.usb-phy supply vcc not found, using dummy regulator
                  [    0.612725] musb-hdrc musb-hdrc.1: MUSB HDRC host driver
                  [    0.612774] musb-hdrc musb-hdrc.1: new USB bus registered, assigned bus number 1
                  [    0.613134] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
                  [    0.613145] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
                  [    0.613155] usb usb1: Product: MUSB HDRC host driver
                  [    0.613163] usb usb1: Manufacturer: Linux 4.14.108-ti-xenomai-r135 musb-hcd
                  [    0.613172] usb usb1: SerialNumber: musb-hdrc.1
                  [    0.614053] hub 1-0:1.0: USB hub found
                  [    0.614131] hub 1-0:1.0: 1 port detected
                  [    0.623191] mousedev: PS/2 mouse device common for all mice
                  [    0.626045] omap_rtc 44e3e000.rtc: registered as rtc0
                  [    0.626892] i2c /dev entries driver
                  [    0.628763] omap_wdt: OMAP Watchdog Timer Rev 0x01: initial timeout 60 sec
                  [    0.632075] hidraw: raw HID events driver (C) Jiri Kosina
                  [    0.632832] ashmem: initialized
                  [    0.633246] remoteproc remoteproc0: wkup_m3 is available
                  [    0.640080] NET: Registered protocol family 10
                  [    0.641611] Segment Routing with IPv6
                  [    0.641694] mip6: Mobile IPv6
                  [    0.641714] NET: Registered protocol family 17
                  [    0.641835] Key type dns_resolver registered
                  [    0.641844] mpls_gso: MPLS GSO support
                  [    0.642106] omap_voltage_late_init: Voltage driver support not added
                  [    0.649063] PM: Cannot get wkup_m3_ipc handle
                  [    0.653717] ThumbEE CPU extension supported.
                  [    0.654734] registered taskstats version 1
                  [    0.654862] zswap: loaded using pool lzo/zbud
                  [    0.657543] Btrfs loaded, crc32c=crc32c-generic
                  [    0.658835] Key type encrypted registered
                  [    0.695524] random: fast init done
                  [    0.705756] input: tps65217_pwr_but as /devices/platform/ocp/44e0b000.i2c/i2c-0/0-0024/tps65217-pwrbutton/input/input0
                  [    0.706345] tps65217 0-0024: TPS65217 ID 0xe version 1.2
                  [    0.706858] at24 0-0050: 32768 byte 24c256 EEPROM, writable, 1 bytes/write
                  [    0.706936] omap_i2c 44e0b000.i2c: bus 0 rev0.11 at 400 kHz
                  [    0.708658] omap_i2c 4802a000.i2c: bus 1 rev0.11 at 400 kHz
                  [    0.710484] at24 2-0054: 32768 byte 24c256 EEPROM, writable, 1 bytes/write
                  [    0.710881] at24 2-0055: 32768 byte 24c256 EEPROM, writable,
                  [    0.711248] at24 2-0056: 32768 byte 24c256 EEPROM, writable, 1 bytes/write
                  [    0.711787] at24 2-0057: 32768 byte 24c256 EEPROM, writable, 1 bytes/write
                  [    0.711858] omap_i2c 4819c000.i2c: bus 2 rev0.11 at 400 kHz
                  [    0.713628] remoteproc remoteproc0: powering up wkup_m3
                  [    0.713760] remoteproc remoteproc0: Booting fw image am335x-pm-firmware.elf, size 217168
                  [    0.717227] PM: Cannot get wkup_m3_ipc handle
                  [    0.721966] remoteproc remoteproc0: remote processor wkup_m3 is now up
                  [    0.721985] wkup_m3_ipc 44e11324.wkup_m3_ipc: CM3 Firmware Version = 0x193
                  [    0.722782] omap_rtc 44e3e000.rtc: setting system clock to 2000-01-01 00:00:00 UTC (946684800)
                  [    0.722797] of_cfs_init
                  [    0.722934] of_cfs_init: OK
                  [    0.723928] ALSA device list:
                  [    0.723939]   No soundcards found.
                  [    0.733946] EXT4-fs (mmcblk1p2): mounted filesystem with ordered data mode. Opts: (null)
                  [    0.734056] VFS: Mounted root (ext4 filesystem) readonly on device 179:2.
                  [    0.734960] devtmpfs: mounted
                  [    0.736623] Freeing unused kernel memory: 1024K
                  [    1.010722] systemd[1]: System time before build time, advancing clock.
                  [    1.061135] ip_tables: (C) 2000-2006 Netfilter Core Team
                  [    1.086670] random: systemd: uninitialized urandom read (16 bytes read)
                  [    1.090038] random: systemd: uninitialized urandom read (16 bytes read)
                  [    1.102903] systemd[1]: systemd 232 running in system mode. (+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD +IDN)
                  [    1.104009] systemd[1]: Detected architecture arm.
                  [    1.105201] systemd[1]: Set hostname to .
                  [    1.332139] random: systemd-cryptse: uninitialized urandom read (16 bytes read)
                  [    1.706605] systemd[1]: Reached target Remote File Systems.
                  [    1.708037] systemd[1]: Listening on udev Kernel Socket.
                  [    1.708601] systemd[1]: Listening on Syslog Socket.
                  [    1.709264] systemd[1]: Started Dispatch Password Requests to Console Directory Watch.
                  [    1.709788] systemd[1]: Listening on Journal Socket.
                  [    1.710362] systemd[1]: Started Forward Password Requests to Wall Directory Watch.
                  [    1.710538] systemd[1]: Reached target Encrypted Volumes.
                  [    1.885245] rtdm_pruss_irq: loading out-of-tree module taints kernel.
                  [    1.886046] rtdm_pruss_irq version 2 loaded
                  [    2.544445] EXT4-fs (mmcblk1p2): re-mounted. Opts: (null)
                  [    3.112934] systemd-journald[95]: Received request to flush runtime journal from PID 1
                  [    5.284428] PM: bootloader does not support rtc-only!
                  [    5.573627] omap_rng 48310000.rng: Random Number Generator ver. 20
                  [    7.993872] using random self ethernet address
                  [    7.993885] using random host ethernet address
                  [    8.062516] using random self ethernet address
                  [    8.062536] using random host ethernet address
                  [    8.109532] Mass Storage Function, version: 2009/09/11
                  [    8.109557] LUN: removable file: (no medium)
                  [    9.169870] usb0: HOST MAC be:1a:ff:91:a3:38
                  [    9.170324] usb0: MAC be:1a:ff:91:a3:39
                  [    9.173603] usb1: HOST MAC be:1a:ff:91:a3:3b
                  [    9.173939] usb1: MAC be:1a:ff:91:a3:3c
                  [    9.800519] net eth0: initializing cpsw version 1.12 (0)
                  [    9.880925] SMSC LAN8710/LAN8720 4a101000.mdio:00: attached PHY driver [SMSC LAN8710/LAN8720] (mii_bus:phy_addr=4a101000.mdio:00, irq=POLL)
                  [    9.893174] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
                  [   10.397310] IPv6: ADDRCONF(NETDEV_UP): usb0: link is not ready
                  [   10.714446] IPv6: ADDRCONF(NETDEV_UP): usb1: link is not ready
                  [   11.937072] cpsw 4a100000.ethernet eth0: Link is Up - 100Mbps/Full - flow control off
                  [   11.937196] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
                  [   15.877033] random: crng init done
                  [   15.877058] random: 7 urandom warning(s) missed due to ratelimiting
                  [   63.352673] rtdm_pruss_irq_open
                  [   63.358105] rtdm_pruss_irq_open
                  [   64.683623] rtdm_pruss_irq_close
                  [   64.683652] rtdm_pruss_irq_close
                  [   77.384953] rtdm_pruss_irq_open
                  [   77.387744] rtdm_pruss_irq_open
                  [   78.302902] rtdm_pruss_irq_close
                  [   78.302935] rtdm_pruss_irq_close
                  [  491.138175] rtdm_pruss_irq_open
                  [  491.142513] rtdm_pruss_irq_open
                  [  492.056691] rtdm_pruss_irq_close
                  [  492.056721] rtdm_pruss_irq_close
                  [  732.251127] rtdm_pruss_irq_open
                  [  732.255349] rtdm_pruss_irq_open
                  [  733.169533] rtdm_pruss_irq_close
                  [  733.169564] rtdm_pruss_irq_close
                  [  749.676978] rtdm_pruss_irq_open
                  [  749.681430] rtdm_pruss_irq_open
                  [  750.595776] rtdm_pruss_irq_close
                  [  750.595807] rtdm_pruss_irq_close
                  [  755.626677] rtdm_pruss_irq_open
                  [  755.627790] rtdm_pruss_irq_open
                  [  756.546909] rtdm_pruss_irq_close
                  [  756.546942] rtdm_pruss_irq_close
                  [  977.967411] rtdm_pruss_irq_open
                  [  977.971607] rtdm_pruss_irq_open
                  [  978.885615] rtdm_pruss_irq_close
                  [  978.885648] rtdm_pruss_irq_close
                  [ 1008.338272] rtdm_pruss_irq_open
                  [ 1008.342473] rtdm_pruss_irq_open
                  [ 1009.256854] rtdm_pruss_irq_close
                  [ 1009.256886] rtdm_pruss_irq_close
                  [ 1628.883088] rtdm_pruss_irq_open
                  [ 1628.887274] rtdm_pruss_irq_open
                  [ 1629.801732] rtdm_pruss_irq_close
                  [ 1629.801763] rtdm_pruss_irq_close
                  [ 1769.655419] rtdm_pruss_irq_open
                  [ 1769.659635] rtdm_pruss_irq_open
                  [ 1770.573843] rtdm_pruss_irq_close
                  [ 1770.573873] rtdm_pruss_irq_close
                  [ 1802.331926] rtdm_pruss_irq_open
                  [ 1802.334475] rtdm_pruss_irq_open
                  [ 1803.249964] rtdm_pruss_irq_close
                  [ 1803.249997] rtdm_pruss_irq_close

                  For each time I hit run it adds another:

                  rtdm_pruss_irq_open
                  rtdm_pruss_irq_open
                  rtdm_pruss_irq_close
                  rtdm_pruss_irq_close

                  dmesg looks good. Can't explain why you'd get that Bad file descriptor error.

                  Ward So with Fundamentals/minimal buffer size does not affect the errors anymore:

                  this may indicate that there is something wrong in your project code, but it's not really guaranteed. Now make your render function like this and run again: if this still works fine (i.e.: It doesn't affect the error printout), then it's even more likely that the error was with your project code. Again, this is probably unrelated to the clock error issues you are getting anyhow.

                  void render(BelaContext* context, void*)
                  {
                  for(unsigned int n =0; n < context->audioFrames; ++n)
                  {
                    for(unsigned int c = 0; c < context->audioOutChannels; ++c)
                      audioWrite(context, n, c, 0);
                  } 
                  for(unsigned int n =0; n < context->analogFrames; ++n)
                  {
                    for(unsigned int c = 0; c < context->analogOutChannels; ++c)
                      analogWriteOnce(context, n, c, 0);
                  } 
                  for(unsigned int n =0; n < context->digitalFrames; ++n)
                  {
                    for(unsigned int c = 0; c < context->digitalChannels; ++c)
                      digitalWriteOnce(context, n, c, 0);
                  } 
                  }
                  • Ward replied to this.

                    giuliomoro So doing this eliminated the bad file descriptors and free() pointer errors, however these errors did not exist with the CTAG cape (probably because the project doesn't quit within 25ms)

                    How would I go about reading McASP error registers? The McASP technical reference manual mentions all sorts of error types that can occur, I guess there might be something in there that might give a hint what to look for?