Skip to content

STM32L4 - using TICKLESS and serial (UART - AT cellular) losing characters #8714

Closed
@mfatiga

Description

@mfatiga

Description

I seem to be experiencing loss of characters sent/received through UART when communicating with the BG96 modem and when I have TICKLESS mode enabled. I have noticed this by viewing traces when connecting to a network. When I disable TICKLESS mode, the modem connects and works perfectly.

I am using a custom target based on STM32L476VG and I'm using the GCC_ARM toolchain. I have copied the DISCO_L476VG system_clock.c and am using mostly the same peripheral pins and pin names files. I am using the QUECTEL BG96 modem and I'm using the integrated mbed driver. I have connected the modem to uart pins and I have also defined and connected flow control pins. The baud rate is set to default at 115200. Modem pins:

MDMRTS = PA_12,
MDMCTS = PA_11,
MDMTXD = PA_9, 
MDMRXD = PA_10,

custom_targets.json

{
    "MY_TARGET": {
        "inherits": ["FAMILY_STM32"],
        "core": "Cortex-M4F",
        "extra_labels_add": ["STM32L4", "STM32L476xG", "STM32L476VG"],
        "config": {
            "clock_source": {
                "help": "Mask value : USE_PLL_HSE_EXTC (need HW patch) | USE_PLL_HSE_XTAL | USE_PLL_HSI | USE_PLL_MSI",
                "value": "USE_PLL_MSI",
                "macro_name": "CLOCK_SOURCE"
            },
            "lpticker_lptim": {
                "help": "This target supports LPTIM. Set value 1 to use LPTIM for LPTICKER, or 0 to use RTC wakeup timer",
                "value": 1
            }
        },
        "OUTPUT_EXT": "hex",
        "detect_code": ["0820"],
        "macros_add": [
            "USBHOST_OTHER", 
            "TWO_RAM_REGIONS",
            "MBED_TICKLESS"
        ],
        "device_has_add": [
            "ANALOGOUT", 
            "CAN", 
            "LPTICKER",
            "SERIAL_FC",
            "SERIAL_ASYNCH",
            "TRNG",
            "FLASH"
        ],
        "release_versions": ["2", "5"],
        "device_name": "STM32L476VG",
        "bootloader_supported": true
    }
}

mbed_app.json

{
    "target_overrides": {
        "*": {
            "events.use-lowpower-timer-ticker": 1,
            "platform.default-serial-baud-rate": 115200,
            
            "platform.stdio-baud-rate": 115200,
            "platform.stdio-convert-newlines": true,
            "platform.stdio-buffered-serial": true,
            "drivers.uart-serial-rxbuf-size": 256,
            "drivers.uart-serial-txbuf-size": 256,

            "rtos.idle-thread-stack-size": 1024,

            "platform.cpu-stats-enabled": 1,
            "platform.thread-stats-enabled": 1,
            "platform.error-filename-capture-enabled": true,
            
            "cellular.use-apn-lookup": 0,
            "ppp-cell-iface.apn-lookup": 0,

            "mbed-trace.enable": true
        }
    },
    "macros": [
        "DEFAULT_APN=\"internet\"",
        "CELLULAR_DEVICE=QUECTEL_BG96"
    ],
    "config": {
        "trace-level": {
            "help": "Options are TRACE_LEVEL_ERROR,TRACE_LEVEL_WARN,TRACE_LEVEL_INFO,TRACE_LEVEL_DEBUG",
            "macro_name": "MBED_TRACE_MAX_LEVEL",
            "value": "TRACE_LEVEL_INFO"
        }
    }
}

I have tried:

  • changing clock sources
  • setting lpticker_lptim to 0
  • overriding lpticker_delay_ticks from and testing with values from 0 to 4
  • changing uart rx/tx buffer sizes
  • disabling trace
  • testing with different versions of mbed-os with every combination of the above

I even tried setting a custom idle callback function, nothing changed. Nothing seems to work except disabling TICKLESS mode, which is not an option for my project. This is a blocker for my project because it requires low-power mode and is rarely turning on the modem and sending data to the backend.

Issue request type

[ ] Question
[ ] Enhancement
[x] Bug

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions