This is the multi-page printable view of this section. Click here to print...

Return to the regular view of this page

As of 2025-07-24

Firmware Development

Questions regarding firmware development
    This page summarizes questions related to firmware development using MWSDK (C) and MWX (C++).

    Techniques

    How to receive UART data continuously instead of one byte at a time?

    Reading multiple bytes can be done using Serial >>, but reading one byte at a time is recommended.

    The UART standard targets the physical layer and does not define data boundaries. For example, sensor ICs usually add boundaries to the output data, such as headers at the start or footers at the end.

    To properly handle data boundaries, you need to read one byte at a time and perform state transitions as follows:

    void loop() {
      uint8_t c;
      while(Serial.available()) {
        Serial >> c;
        // or c = Serial.read();
    
        switch(c) { ... }  // Branch processing based on the value of c
      }
    }

    General

    What is the interval of the built-in watchdog timer? How to change it?

    The built-in WDT is controlled directly via the low-level interface provided by the semiconductor manufacturer.

    For details, please refer to the semiconductor manufacturer’s documentation (JN516x Integrated Peripherals API User Guide), page 95.

    • The interval is set via the argument of vAHI_WatchdogStart() (see page 308 of the same document)
    • To stop it, call vAHI_WatchdogStop() (page 309)
    • To restart, call vAHI_WatchdogRestart() (page 310)

    Note that the initial TWELITE system uses 10 as the value of the argument u8Prescale passed to vAHI_WatchdogStart() (this is from non-public code). Therefore, if user code does not call vAHI_WatchdogStart(), the set time interval is considered to be (2^(10-1)+1)*8 = 4104 ms = approximately 4.1 seconds.

    MWX

    General

    How to relay packets?

    Packet relay in MWX is performed implicitly.

    How to relay TWELITE APPS packets?

    To relay packets from TWELITE APPS such as Aria App, you need to explicitly prepare code that resends the received data, for example using Rcv_Univsl.

    For relaying packets regardless of type, please use the Parent and Repeater app (App_Wings) in repeater mode.

    Analogue

    How to prevent the ADC frequency from reverting to 1kHz after waking up from sleep?

    If you specify a timer device such as E_AHI_DEVICE_TIMER0 for the ADC timer device, call Analogue.setup() again after waking up from sleep to reinitialize it. The default state after waking up specifies E_AHI_DEVICE_TICK_TIMER, fixing the frequency at 1kHz.