搜索
bottom↓
回复: 3

dsp2812 eCan自检好用但是设置成 nomal mode时就收不到了

[复制链接]

出0入8汤圆

发表于 2011-3-29 13:50:37 | 显示全部楼层 |阅读模式
我在一块dsp板中如果发送完了点亮一个led灯
在另一板中受到数据也点亮一个led灯

问题是自测模式能行,分开就不行;请大侠帮忙看看
程序:

// TI File $Revision: /main/4 $
// Checkin $Date: July 2, 2007   11:33:00 $
//###########################################################################
//
// FILE:    Example_281xECanBack2Back.c
//
// TITLE:   DSP281x eCAN Back-to-back transmission and reception in
//          SELF-TEST mode
//
// ASSUMPTIONS:
//
//          This program requires the DSP281x V1.00 header files.
//          As supplied, this project is configured for "boot to H0" operation.
//
//          Other then boot mode configuration, no other hardware configuration
//          is required.
//
// DESCRIPTION:
//
//          This test transmits data back-to-back at high speed without
//          stopping.
//          The received data is verified. Any error is flagged.
//          MBX0 transmits to MBX16, MBX1 transmits to MBX17 and so on....
//          This program illustrates the use of self-test mode
//
//###########################################################################
// $TI Release: DSP281x C/C++ Header Files V1.20 $
// $Release Date: July 27, 2009 $
//###########################################################################

#include "DSP281x_Device.h"     // DSP281x Headerfile Include File
#include "DSP281x_Examples.h"   // DSP281x Examples Include File

// Prototype statements for functions found within this file.
void mailbox_check(int32 T1, int32 T2, int32 T3);
void mailbox_read(int16 i);
void Gpio_select(void);

// Global variable for this example
Uint32  ErrorCount;
Uint32  MessageReceivedCount;

Uint32  TestMbox1 = 0;
Uint32  TestMbox2 = 0;
Uint32  TestMbox3 = 0;

void main(void)
{

    Uint16  j;



// Step 1. Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
// This example function is found in the DSP281x_SysCtrl.c file.
   InitSysCtrl();

// Step 2. Initalize GPIO:
// This example function is found in the DSP281x_Gpio.c file and
// illustrates how to set the GPIO to it's default state.
// InitGpio();  // Skipped for this example

// Step 3. Clear all interrupts and initialize PIE vector table:
// Disable CPU interrupts
   DINT;

// Initialize PIE control registers to their default state.
// The default state is all PIE interrupts disabled and flags
// are cleared.
// This function is found in the DSP281x_PieCtrl.c file.
//   InitPieCtrl();        // Skipped for this example

// Disable CPU interrupts and clear all CPU interrupt flags:
   IER = 0x0000;
   IFR = 0x0000;

// Initialize the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
// This will populate the entire table, even if the interrupt
// is not used in this example.  This is useful for debug purposes.
// The shell ISR routines are found in DSP281x_DefaultIsr.c.
// This function is found in DSP281x_PieVect.c.
//   InitPieVectTable();         // Skipped for this example

// Step 4. Initialize all the Device Peripherals:
// This function is found in DSP281x_InitPeripherals.c
// InitPeripherals(); // Not required for this example
///Gpio_select();
// Step 5. User specific code
   Gpio_select();
    MessageReceivedCount = 0;
    ErrorCount = 0;
        InitECan();     // Initialize the eCAN module
    ConfigureECan();//Osea Add:configrue eCan mailbox ID、data etc..
   
    // Begin transmitting
        GpioDataRegs.GPADAT.bit.GPIOA0=1;
    while(1)
    {

    ECanaRegs.CANTRS.all = 0x0000FFFF;  // Set TRS for all transmit mailboxes发送请求置位寄存器
       while(ECanaRegs.CANTA.all != 0x0000FFFF ) {}  // Wait for all TAn bits to be set..当对应mailbox发送了相应位置位
       ECanaRegs.CANTA.all = 0x0000FFFF;   // Clear all TAn
      
    GpioDataRegs.GPADAT.bit.GPIOA0=0;
         MessageReceivedCount++;
         DSP28x_usDelay(50000000);
         GpioDataRegs.GPADAT.bit.GPIOA0=1;
     DSP28x_usDelay(50000000);                         
       //Read from Receive mailboxes and begin checking for data */
     /*           while(ECanaRegs.CANRMP.all != 0xFFFF0000){}  //接收消息待决寄存器
       for(j=0; j<16; j++)         // Read & check 16 mailboxes
       {
          mailbox_read(j);         // This func reads the indicated mailbox data
          mailbox_check(TestMbox1,TestMbox2,TestMbox3); // Checks the received data
       }                                                            */
    }
}                                                                          

// This function reads out the contents of the indicated
// by the Mailbox number (MBXnbr).
void mailbox_read(int16 MBXnbr)
{
   volatile struct MBOX *Mailbox;
   Mailbox = &ECanaMboxes.MBOX0 + MBXnbr;
   TestMbox1 = Mailbox->MDL.all; // = 0x9555AAAn (n is the MBX number)
   TestMbox2 = Mailbox->MDH.all; // = 0x89ABCDEF (a constant)
   TestMbox3 = Mailbox->MSGID.all;// = 0x9555AAAn (n is the MBX number)

} // MSGID of a rcv MBX is transmitted as the MDL data.


void mailbox_check(int32 T1, int32 T2, int32 T3)
{
    if((T1 != T3) || ( T2 != 0x89ABCDEF))
    {
       ErrorCount++;
    }
}

void Gpio_select(void)
{
    EALLOW;
    GpioMuxRegs.GPAMUX.bit.PWM1_GPIOA0=0;
    GpioMuxRegs.GPAMUX.bit.PWM2_GPIOA1=0;
        GpioMuxRegs.GPAMUX.bit.PWM3_GPIOA2=0;
        GpioMuxRegs.GPAMUX.bit.PWM4_GPIOA3=0;
        GpioMuxRegs.GPAMUX.bit.PWM5_GPIOA4=0;
        GpioMuxRegs.GPAMUX.bit.PWM6_GPIOA5=0;

    GpioMuxRegs.GPADIR.bit.GPIOA0=1;
    GpioMuxRegs.GPADIR.bit.GPIOA1=1;
        GpioMuxRegs.GPADIR.bit.GPIOA2=1;
        GpioMuxRegs.GPADIR.bit.GPIOA3=0;
        GpioMuxRegs.GPADIR.bit.GPIOA4=0;
        GpioMuxRegs.GPADIR.bit.GPIOA5=0;
    EDIS;
     
}


//===========================================================================
// No more.
//===========================================================================

/* Note:
As indicated in the 281x device errata (SPRZ193), double-reads/double writes should be
employed for accesses to the mailbox RAM & LAM/MOTO/MOTS areas. Note, however, that the
errata is applicable only if the mailbox RAM & LAM/MOTO/MOTS areas are accessed at the
same time. The header file example operates in self-test mode, with no possibility of
a contention. Hence, the workaround is not implemented. When eCAN is communicating with
another node in non self-test mode), the workaround must be incorporated.
*/

点击此处下载 ourdev_626452UIMJJ5.rar(文件大小:236K) (原文件名:ecan_back2back.rar)

出0入8汤圆

 楼主| 发表于 2011-3-29 15:03:21 | 显示全部楼层
这么快就不见了

出0入8汤圆

 楼主| 发表于 2011-3-30 20:14:37 | 显示全部楼层
不会吧,都没有高手指点啊

出0入0汤圆

发表于 2013-11-22 15:40:27 | 显示全部楼层
dsp2802 eCan自检好用但是设置成 nomal mode时就收不到了,
楼主当年怎么解决的啊
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|Archiver|amobbs.com 阿莫电子技术论坛 ( 粤ICP备2022115958号, 版权所有:东莞阿莫电子贸易商行 创办于2004年 (公安交互式论坛备案:44190002001997 ) )

GMT+8, 2024-4-19 14:35

© Since 2004 www.amobbs.com, 原www.ourdev.cn, 原www.ouravr.com

快速回复 返回顶部 返回列表