⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 libtblbyteread.c

📁 G711在dsPIC33FJ256GP506下的应用
💻 C
字号:
/*********************************************************************
*                                                                    *
*                       Software License Agreement                   *
*                                                                    *
*   The software supplied herewith by Microchip Technology           *
*   Incorporated (the "Company") for its dsPIC controller            *
*   is intended and supplied to you, the Company's customer,         *
*   for use solely and exclusively on Microchip dsPIC                *
*   products. The software is owned by the Company and/or its        *
*   supplier, and is protected under applicable copyright laws. All  *
*   rights are reserved. Any use in violation of the foregoing       *
*   restrictions may subject the user to criminal sanctions under    *
*   applicable laws, as well as to civil liability for the breach of *
*   the terms and conditions of this license.                        *
*                                                                    *
*   THIS SOFTWARE IS PROVIDED IN AN "AS IS" CONDITION.  NO           *
*   WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING,    *
*   BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND    *
*   FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE     *
*   COMPANY SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL,  *
*   INCIDENTAL OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.  *
*                                                                    *
*********************************************************************/

/******************************************************************************
**
**  Filename:     libTblByteRead.c
**
**  System:       RISC
**
**  Platform:     dsPIC33F
**
**  Description:  This function reads the next byte to decode from PM
*                 and returns it.
**
******************************************************************************/

#include <p33Fxxxx.h>

/* external data */
extern int pTblpag, pTblOff, byteCount;

/******************************************************************************
*
*  Function:  libTblByteRead ( )
*  Arguments: none
*  Returns:   WREG7, the next byte in the decode stream
*  Purpose:   This function reads the next byte to decode from PM
*             and returns it.
*  Warnings:  This function uses W6 and W7 inline - they are not
*             used by the compiler in this function, so it is safe
*             to hand-modify them with inline assembly.
******************************************************************************/
char libTblByteRead (void)
{
  char temp;

  temp   = TBLPAG;                    //Saving the TBLPAG.
  TBLPAG = pTblpag;                   //Setting the TBLPAG for playback.
  __asm__ volatile ( "mov %0, w6" : : "g" (pTblOff) );

  if (byteCount == 0)                 //Reading the next byte to play back.
  {
    __asm__ volatile ( "tblrdl.b [w6], w7" );        //Reading the low byte.
    byteCount = 1;
  }
  else if (byteCount == 1)
  {
    __asm__ volatile ( "tblrdl.b [++w6], w7" );      //Reading the middle byte.
    byteCount = 2;
  }
  else
  {
    __asm__ volatile ( "tblrdh.b [w6], w7" );        //Reading the high byte.
    __asm__ volatile ( "inc2 w6, w6" );
    __asm__ volatile ( "mov w6, %0" : "=g" (pTblOff) );
    if (!pTblOff)
    {
      pTblpag += 1;                   //New TBLPAG.
    }
    byteCount = 0;                    //Reset counter.
  }

  TBLPAG = temp;                      //Restore the TBLPAG.

  __asm__ volatile ( "mov w7, w0" );
}

/*-----------------------------------------------------------------------------
                  END OF FILE : libTblByteRead.c
-----------------------------------------------------------------------------*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -