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

📄 can.lst

📁 Keil 下编译的基于mcs51单片机的PCA82C250CAN收发器控制的程序源代码。
💻 LST
📖 第 1 页 / 共 4 页
字号:
 738   3                     CAN_OBJ[ObjNr-1].MCR0=0xfe;
 739   3                  }     
 740   2                  else
 741   2                  {
 742   3                     CAN_OBJ[ObjNr-1].MCR0=0xfd;   
 743   3                  }
 744   2                  break;
 745   2               case RMTPND:
 746   2                  if(BIT_VALUE)
 747   2                  {
 748   3                     CAN_OBJ[ObjNr-1].MCR1=0xbf;
 749   3                  }     
 750   2                  else
 751   2                  {
 752   3                     CAN_OBJ[ObjNr-1].MCR1=0x7f;   
 753   3                  }
 754   2                  break;
 755   2              case TXRQ:
 756   2                  if(BIT_VALUE)
 757   2                  {
 758   3                     CAN_OBJ[ObjNr-1].MCR1=0xef;
 759   3                  }     
 760   2                  else
 761   2                  {
 762   3                     CAN_OBJ[ObjNr-1].MCR1=0xdf;   
 763   3                  }
 764   2                   break;
 765   2              case CPUUPD:
 766   2                  if(BIT_VALUE)
 767   2                  {
 768   3                     CAN_OBJ[ObjNr-1].MCR1=0xfb;
 769   3                  }     
 770   2                  else
 771   2                  {
 772   3                     CAN_OBJ[ObjNr-1].MCR1=0xf7;   
 773   3                  }
 774   2                  break;
 775   2              case NEWDAT:
 776   2                  if(BIT_VALUE)
 777   2                  {
 778   3                     CAN_OBJ[ObjNr-1].MCR1=0xfe;
 779   3                  }     
 780   2                  else
 781   2                  {
 782   3                     CAN_OBJ[ObjNr-1].MCR1=0xfd;   
 783   3                  }
 784   2                  break;
 785   2              default:
 786   2                  break;
 787   2              
 788   2          }
 789   1      }
 790          //未使用函数
 791          //****************************************************************************
 792          // @Function      void CAN_vConfigMsgObj(unsigned char ObjNr, TCAN_Obj *pstObj)
 793          //
 794          //----------------------------------------------------------------------------
 795          // @Description   This function sets up the message objects. This includes
 796          //                the 8 data bytes, the identifier (11- or 29-bit), the data 
 797          //                number (0-7 bytes) and the XTD-bit.
 798          //                The message is not sent; for this the function
C51 COMPILER V7.06   CAN                                                                   10/23/2004 16:55:18 PAGE 14  

 799          //                CAN_vTransmit must be called.
 800          //                
 801          //                The structure of the "software" message object is defined in the 
 802          //                header file CAN.H (see TCAN_Obj).
 803          //
 804          //----------------------------------------------------------------------------
 805          // @Returnvalue   none
 806          //
 807          //----------------------------------------------------------------------------
 808          // @Parameters    Number of the message object to be configured (1-15)
 809          // @Parameters    Pointer on a message object
 810          //
 811          //----------------------------------------------------------------------------
 812          // @Date          01-2-24 12:51:13
 813          //
 814          //****************************************************************************
 815          //LAC:configure a "hardware "object which in CAN controller with a "software"
 816          //message object which maybe in MCU
 817          /*void CAN_vConfigMsgObj(unsigned char ObjNr, TCAN_Obj *pstObj)
 818          {
 819            unsigned char i;
 820            unsigned long v;
 821          
 822            CAN_OBJ[ObjNr-1].MCR1 = 0xfb;   // set CPUUPD, reset MSGVAL
 823            CAN_OBJ[ObjNr-1].MCR0 = 0x7f;  
 824          
 825            if(pstObj->MsgCfg & 0x04)     // extended identifier
 826            {
 827              v = 0x00000000;
 828              v = (pstObj->Identifier & 0x0000001f);         // ID  4.. 0
 829              CAN_OBJ[ObjNr-1].LAR1  = v << 3;
 830              v = 0x00000000;
 831              v = (pstObj->Identifier & 0x00001fe0) >>  5;   // ID 12.. 5
 832              CAN_OBJ[ObjNr-1].LAR0  = (v & 0x00000ff);
 833          
 834              v = 0x00000000;
 835              v = (pstObj->Identifier & 0x001fe000) >>  13;  // ID 13..20
 836              CAN_OBJ[ObjNr-1].UAR1  = (v & 0x00000ff);
 837              v = 0x00000000;
 838              v = (pstObj->Identifier & 0x1fe00000) >> 21;   // ID 21..28
 839              CAN_OBJ[ObjNr-1].UAR0  = (v & 0x00000ff);
 840            }
 841            else                               // standard identifier
 842            {
 843              CAN_OBJ[ObjNr-1].LAR1  = 0x00;
 844              CAN_OBJ[ObjNr-1].LAR0  = 0x00;
 845          
 846              v = 0x00000000;
 847              v = (pstObj->Identifier & 0x00000007) << 5;    // ID 18..20
 848              CAN_OBJ[ObjNr-1].UAR1  = v;
 849              v = 0x00000000;
 850              v = (pstObj->Identifier & 0x000007f8) >> 3;    // ID 21..28
 851              CAN_OBJ[ObjNr-1].UAR0  = v;
 852            }
 853          
 854            if(CAN_OBJ[ObjNr-1].MCFG & 0x08)   // if transmit direction
 855            {
 856              CAN_OBJ[ObjNr-1].MCFG = pstObj->MsgCfg | 0x08;
 857          
 858              for(i = 0; i < (pstObj->MsgCfg & 0xf0) >> 4;i++)
 859              {
 860                CAN_OBJ[ObjNr-1].Data[i] = pstObj->ObjectData[i];
C51 COMPILER V7.06   CAN                                                                   10/23/2004 16:55:18 PAGE 15  

 861              }
 862              CAN_OBJ[ObjNr-1].MCR1  = 0xf6;  // set NEWDAT, reset CPUUPD, set MSGVAL
 863              CAN_OBJ[ObjNr-1].MCR0  = 0xbf;  
 864            }
 865            else                              // if receive direction
 866            {
 867              CAN_OBJ[ObjNr-1].MCFG = pstObj->MsgCfg & 0xf7;
 868          
 869              CAN_OBJ[ObjNr-1].MCR1  = 0xf7;  // reset CPUUPD, set MSGVAL
 870              CAN_OBJ[ObjNr-1].MCR0  = 0xbf; 
 871            }
 872          
 873            CAN_OBJ[ObjNr-1].Customer = pstObj->ubUser;
 874          }
 875          //****************************************************************************
 876          // @Function      bit CAN_bMsgLost(unsigned char ObjNr)
 877          //
 878          //----------------------------------------------------------------------------
 879          // @Description   If a RECEIVE OBJECT receives new data before the old object
 880          //                has been read, the old object is lost. The CAN controller
 881          //                indicates this by setting the message lost bit (MSGLST).
 882          //                This function returns the status of this bit.
 883          //                
 884          //                Note:
 885          //                This function resets the message lost bit (MSGLST).
 886          //
 887          //----------------------------------------------------------------------------
 888          // @Returnvalue   1 the message object has lost a message, else 0
 889          //
 890          //----------------------------------------------------------------------------
 891          // @Parameters    Number of the message object (1-15)
 892          //
 893          //----------------------------------------------------------------------------
 894          // @Date          01-2-24 12:51:13
 895          //
 896          //****************************************************************************
 897          
 898          bit CAN_bMsgLost(unsigned char ObjNr)
 899          {
 900            bit bReturn;
 901          
 902            bReturn = 0;
 903            if((CAN_OBJ[ObjNr-1].MCR1 & 0x0c) == 0x08)  // if set MSGLST 
 904            {
 905              bReturn = 1;
 906              CAN_OBJ[ObjNr-1].MCR1 = 0xF7;
 907            }
 908            return(bReturn);
 909          }
 910          
 911          //****************************************************************************
 912          // @Function      bit CAN_bDelMsgObj(unsigned char ObjNr)
 913          //
 914          //----------------------------------------------------------------------------
 915          // @Description   This function marks the selected message object as not valid.
 916          //                This means that this object cannot be sent or received.
 917          //                If the selected object is busy (meaning the object is
 918          //                transmitting a message or has received a new message) this
 919          //                function returns the value "0" and the object is not deleted.
 920          //
 921          //----------------------------------------------------------------------------
 922          // @Returnvalue   1 the message object was deleted, else 0
C51 COMPILER V7.06   CAN                                                                   10/23/2004 16:55:18 PAGE 16  

 923          //
 924          //----------------------------------------------------------------------------
 925          // @Parameters    Number of the message object (1-15)
 926          //
 927          //----------------------------------------------------------------------------
 928          // @Date          01-2-24 12:51:13
 929          //
 930          //****************************************************************************
 931          
 932          bit CAN_bDelMsgObj(unsigned char ObjNr)
 933          {
 934            bit bReturn;
 935          
 936            bReturn = 0;
 937            if(!(CAN_OBJ[ObjNr-1].MCR1 & 0xa2))  // if set RMTPND, TXRQ or NEWDAT
 938            {
 939              CAN_OBJ[ObjNr-1].MCR0 = 0x7f;      // reset MSGVAL
 940              bReturn = 1;
 941            }
 942            return(bReturn);
 943          }
 944          
 945          
 946          //****************************************************************************
 947          // @Function      void CAN_vReleaseObj(unsigned char ObjNr)
 948          //
 949          //----------------------------------------------------------------------------
 950          // @Description   This function resets the NEWDAT flag of the selected RECEIVE
 951          //                OBJECT, so that the CAN controller have access to it.
 952          //                This function must be called if the function CAN_bNewData
 953          //                detects, that new data are present in the message object and
 954          //                the actual data have been read by calling the function
 955          //                CAN_vGetMsgObj. 
 956          //
 957          //----------------------------------------------------------------------------
 958          // @Returnvalue   none
 959          //
 960          //----------------------------------------------------------------------------
 961          // @Parameters    Number of the message object (1-15)
 962          //
 963          //----------------------------------------------------------------------------
 964          // @Date          01-2-24 12:51:13
 965          //
 966          //****************************************************************************
 967          
 968          void CAN_vReleaseObj(unsigned char ObjNr)
 969          {
 970            CAN_OBJ[ObjNr-1].MCR1 = 0xFD;               // reset NEWDAT
 971          }*/
 972          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =   1362    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----      11
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----       2
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

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