RL78/G14のDTCのアプリケーションノートR01AN2867JJ0100のサンプルコードは間違っているのではないでしょうか、、、

こんにちは。NoMaYです。

RL78/G14でUART+DTCのサンプルコードを探していたのですが、見付かりませんでしたので、変わりに3線シリアルI/O+DTCのサンプルコードを見ていて気付いたのですが、通信割り込みルーチンのソースが間違っているのではないでしょうか、、、(ひょっとして、コード生成機能が生成したソースの通信割り込みルーチンを全面的に変更していて、ドキュメントでもサンプルコードのソースをコード生成されたソースで上書きしないよう注意していながら、アプリケーションノート作成者自身がうっかり上書きしてしまって、でも、それに気付かず公開してしまった、とかいうことはないでしょうか、、、)

RL78/G14 DTCを使用したクロック同期式シリアルI/O 連続送受信 CC-RL
www.renesas.com/jp/ja/search/keyword-search.html#q=r01an2867

ドキュメント
www.renesas.com/jp/ja/doc/products/mpumcu/apn/rl78/002/r01an2867jj0100_rl78.pdf

サンプルコード
www.renesas.com/jp/ja/software/D3017442.html

以下、ドキュメントの画面コピーです。(4枚目の画面コピーに赤枠を書き込んでいます。)






以下、サンプルコードの抜粋です。(上記と対応する箇所で変だと感じている箇所を赤文字にしています。)

an_r01an2867jj0100_rl78_serial\Workspace\CS+\r01an2867_serial\r_cg_serial.c

MD_STATUS R_CSI00_Send_Receive(uint8_t * const tx_buf, uint16_t tx_num, uint8_t * const rx_buf)
{
    MD_STATUS status = MD_OK;

    if (tx_num < 1U)
    {
        status = MD_ARGERROR;
    }
    else
    {
        g_csi00_tx_count = tx_num;        /* send data count */
        gp_csi00_tx_address = tx_buf;     /* send buffer pointer */
        gp_csi00_rx_address = rx_buf;     /* receive buffer pointer */
        CSIMK00 = 1U;                     /* disable INTCSI00 interrupt */

        if (0U != gp_csi00_tx_address)
        {
            SIO00 = *gp_csi00_tx_address;    /* started by writing data to SDR[7:0] */
            gp_csi00_tx_address++;
        }
        else
        {
            SIO00 = 0xFFU;
        }

        g_csi00_tx_count--;
        CSIMK00 = 0U;                     /* enable INTCSI00 interrupt */
    }

    return (status);
}

an_r01an2867jj0100_rl78_serial\Workspace\CS+\r01an2867_serial\r_cg_serial_user.c

static void __near r_csi00_interrupt(void)
{
    uint8_t err_type;
    volatile uint8_t sio_dummy;

    err_type = (uint8_t)(SSR00 & _0001_SAU_OVERRUN_ERROR);
    SIR00 = (uint16_t)err_type;

    if (1U == err_type)
    {
        r_csi00_callback_error(err_type);    /* overrun error occurs */
    }
    else
    {
        if (g_csi00_tx_count > 0U)
        {
            if (0U != gp_csi00_rx_address)
            {
                *gp_csi00_rx_address = SIO00;
                gp_csi00_rx_address++;
            }
            else
            {
                sio_dummy = SIO00;
            }

            if (0U != gp_csi00_tx_address)
            {
                SIO00 = *gp_csi00_tx_address;
                gp_csi00_tx_address++;
            }
            else
            {
                SIO00 = 0xFFU;
            }

            g_csi00_tx_count--;
        }
        else
        {
            if (0U == g_csi00_tx_count)
            {
                if (0U != gp_csi00_rx_address)
                {
                    *gp_csi00_rx_address = SIO00;
                }
                else
                {
                    sio_dummy = SIO00;
                }
            }

            r_csi00_callback_receiveend();    /* complete receive */
        }
    }
}

[参考]

RL78/G14のDTCのアプリケーションノート一覧



UART+DTCのアプリケーションノートはありましたが概説のみでサンプルコードはありませんでした
www.renesas.com/jp/ja/search/keyword-search.html#q=r01an0861
r01an0861jj0100_rl78.pdf
初めての RL78/G14 DTC アプリケーションノート

 

Parents
  • NoMaYさん、
    かふぇルネ管理人です。
    本件、製品担当者に確認しました。
    アプリケーションノートに付属のサンプルコードに誤りがありました。当該アプリケーションノートは修正予定ですので、少々お待ちください。
    以下に、担当者からの説明を記載します。


    当該アプリケーションノートの内容について、アプリケーションノートに付属のサンプルコードの内容に誤りがございました。この度は、ご迷惑をおかけいたしまして大変申し訳ございませんでした。
    ご指摘いただきました通り、本来のプログラムがコード生成ツールによって出力された内容で上書きされた状態となっていることが原因と考えられます。
    なお、当該アプリケーションノートPage34の図4. 13に記載の内容は、問題ございません。

    修正内容を下記致します。
    赤字個所が修正前後の差分となります。

    ---------------------------------------------------------------------------------------------------------------------

    修正前:
    static void __near r_csi00_interrupt(void)
    {
       uint8_t err_type;
       volatile uint8_t sio_dummy;
     
       err_type = (uint8_t)(SSR00 & _0001_SAU_OVERRUN_ERROR);
       SIR00 = (uint16_t)err_type;
     
       if (1U == err_type)
       {
          r_csi00_callback_error(err_type); /* overrun error occurs */
       }
       else
       {
          if (g_csi00_tx_count > 0U)
          {
             if (0U != gp_csi00_rx_address)
             {
                *gp_csi00_rx_address = SIO00;
                gp_csi00_rx_address++;
             }
             else
             {
                sio_dummy = SIO00;
             }
     
             if (0U != gp_csi00_tx_address)
             {
                SIO00 = *gp_csi00_tx_address;
                gp_csi00_tx_address++;
            }
            else
            {
                SIO00 = 0xFFU;
             }
     
             g_csi00_tx_count--;
          }
          else
          {
             if (0U == g_csi00_tx_count)
             {
                if (0U != gp_csi00_rx_address)
                {
                   *gp_csi00_rx_address = SIO00;
                }
                else
                {
                   sio_dummy = SIO00;
                }
             }
     
             r_csi00_callback_receiveend(); /* complete receive */
          }
       }
    }

    修正後:
    static void __near r_csi00_interrupt(void)
    {
       uint8_t err_type;
       volatile uint8_t sio_dummy;
     
       err_type = (uint8_t)(SSR00 & _0001_SAU_OVERRUN_ERROR);
       SIR00 = (uint16_t)err_type;
     
       if (1U == err_type)
       {
          r_csi00_callback_error(err_type); /* overrun error occurs */
       }
       else
       {
          if (g_csi00_tx_count > 0U)
          {
             g_csi00_tx_count = 0;
          }
          else
          {
             if (0U == g_csi00_tx_count)
             {
                if (0U != gp_csi00_rx_address)
                {
                   *(gp_csi00_rx_address+TX_RX_DATA_SIZE-1) = SIO00;
                }
                else
                {
                   sio_dummy = SIO00;
                }
             }
     
             r_csi00_callback_receiveend(); /* complete receive */
          }
       }
    }

    ---------------------------------------------------------------------------------------------------------------------

     

  • rsvさん、こんにちは。NoMaYです。

    確認どうも有難う御座いました。また、修正後のソースの添付とアプリケーションノートは修正予定であるとの連絡も、どうも有難う御座いました。

Reply
  • rsvさん、こんにちは。NoMaYです。

    確認どうも有難う御座いました。また、修正後のソースの添付とアプリケーションノートは修正予定であるとの連絡も、どうも有難う御座いました。

Children
No Data