打印
[DSP编程]

dsp28335无法读写NAT9914寄存器

[复制链接]
1163|4
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
最近准备用DSP28335NAT9914制作GPIB接口,利用zone7与nat9914连接,但是一直无法正确读写NAT9914寄存器,怀疑是读写时序问题,求高手指点。

部分代码
InitPll(DSP28_PLLCR,DSP28_DIVSEL); //设置时钟频率150MHZ
void InitPeripheralClocks(void)
{
   EALLOW;
// HISPCP/LOSPCP prescale register settings, normally it will be set to default values
   SysCtrlRegs.HISPCP.all = 0x0001;
   SysCtrlRegs.LOSPCP.all = 0x0002;
// XCLKOUT to SYSCLKOUT ratio.  By default XCLKOUT = 1/4 SYSCLKOUT
   // XTIMCLK = SYSCLKOUT/2
   XintfRegs.XINTCNF2.bit.XTIMCLK = 1;
   // XCLKOUT = XTIMCLK/2
   XintfRegs.XINTCNF2.bit.CLKMODE = 1;
   // Enable XCLKOUT
   XintfRegs.XINTCNF2.bit.CLKOFF = 0;
// Peripheral clock enables set for the selected peripherals.
// If you are not using a peripheral leave the clock off
// to save on power.
//
// Note: not all peripherals are available on all 2833x derivates.
// Refer to the datasheet for your particular device.
//
// This function is not written to be an example of efficient code.
   SysCtrlRegs.PCLKCR0.bit.ADCENCLK = 1;    // ADC
   // *IMPORTANT*
   // The ADC_cal function, which  copies the ADC calibration values from TI reserved
   // OTP into the ADCREFSEL and ADCOFFTRIM registers, occurs automatically in the
   // Boot ROM. If the boot ROM code is bypassed during the debug process, the
   // following function MUST be called for the ADC to function according
   // to specification. The clocks to the ADC MUST be enabled before calling this
   // function.
   // See the device data manual and/or the ADC Reference
   // Manual for more information.
   ADC_cal();
   SysCtrlRegs.PCLKCR0.bit.I2CAENCLK = 1;   // I2C
   SysCtrlRegs.PCLKCR0.bit.SCIAENCLK = 1;   // SCI-A
   SysCtrlRegs.PCLKCR0.bit.SCIBENCLK = 1;   // SCI-B
   SysCtrlRegs.PCLKCR0.bit.SCICENCLK = 1;   // SCI-C
   SysCtrlRegs.PCLKCR0.bit.SPIAENCLK = 1;   // SPI-A
   SysCtrlRegs.PCLKCR0.bit.MCBSPAENCLK = 1; // McBSP-A
   SysCtrlRegs.PCLKCR0.bit.MCBSPBENCLK = 1; // McBSP-B
   SysCtrlRegs.PCLKCR0.bit.ECANAENCLK=1;    // eCAN-A
   SysCtrlRegs.PCLKCR0.bit.ECANBENCLK=1;    // eCAN-B
   SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 0;   // Disable TBCLK within the ePWM
   SysCtrlRegs.PCLKCR1.bit.EPWM1ENCLK = 1;  // ePWM1
   SysCtrlRegs.PCLKCR1.bit.EPWM2ENCLK = 1;  // ePWM2
   SysCtrlRegs.PCLKCR1.bit.EPWM3ENCLK = 1;  // ePWM3
   SysCtrlRegs.PCLKCR1.bit.EPWM4ENCLK = 1;  // ePWM4
   SysCtrlRegs.PCLKCR1.bit.EPWM5ENCLK = 1;  // ePWM5
   SysCtrlRegs.PCLKCR1.bit.EPWM6ENCLK = 1;  // ePWM6
   SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 1;   // Enable TBCLK within the ePWM
   SysCtrlRegs.PCLKCR1.bit.ECAP3ENCLK = 1;  // eCAP3
   SysCtrlRegs.PCLKCR1.bit.ECAP4ENCLK = 1;  // eCAP4
   SysCtrlRegs.PCLKCR1.bit.ECAP5ENCLK = 1;  // eCAP5
   SysCtrlRegs.PCLKCR1.bit.ECAP6ENCLK = 1;  // eCAP6
   SysCtrlRegs.PCLKCR1.bit.ECAP1ENCLK = 1;  // eCAP1
   SysCtrlRegs.PCLKCR1.bit.ECAP2ENCLK = 1;  // eCAP2
   SysCtrlRegs.PCLKCR1.bit.EQEP1ENCLK = 1;  // eQEP1
   SysCtrlRegs.PCLKCR1.bit.EQEP2ENCLK = 1;  // eQEP2
   SysCtrlRegs.PCLKCR3.bit.CPUTIMER0ENCLK = 1; // CPU Timer 0
   SysCtrlRegs.PCLKCR3.bit.CPUTIMER1ENCLK = 1; // CPU Timer 1
   SysCtrlRegs.PCLKCR3.bit.CPUTIMER2ENCLK = 1; // CPU Timer 2
   SysCtrlRegs.PCLKCR3.bit.DMAENCLK = 1;       // DMA Clock
   SysCtrlRegs.PCLKCR3.bit.XINTFENCLK = 1;     // XTIMCLK
   SysCtrlRegs.PCLKCR3.bit.GPIOINENCLK = 1;    // GPIO input clock
   EDIS;
}
void InitGpio(void)
{
        EALLOW;
        //数据线
        GpioCtrlRegs.GPCMUX1.bit.GPIO64=2;
        GpioCtrlRegs.GPCMUX1.bit.GPIO65=2;
        GpioCtrlRegs.GPCMUX1.bit.GPIO66=2;
        GpioCtrlRegs.GPCMUX1.bit.GPIO67=2;
        GpioCtrlRegs.GPCMUX1.bit.GPIO68=2;
        GpioCtrlRegs.GPCMUX1.bit.GPIO69=2;
        GpioCtrlRegs.GPCMUX1.bit.GPIO70=2;
        GpioCtrlRegs.GPCMUX1.bit.GPIO71=2;
        GpioCtrlRegs.GPCMUX1.bit.GPIO72=2;
        GpioCtrlRegs.GPCMUX1.bit.GPIO73=2;
        GpioCtrlRegs.GPCMUX1.bit.GPIO74=2;
        GpioCtrlRegs.GPCMUX1.bit.GPIO75=2;
        GpioCtrlRegs.GPCMUX1.bit.GPIO76=2;
        GpioCtrlRegs.GPCMUX1.bit.GPIO77=2;
        GpioCtrlRegs.GPCMUX1.bit.GPIO78=2;
        GpioCtrlRegs.GPCMUX1.bit.GPIO79=2;
       
        //地址线
        GpioCtrlRegs.GPBMUX1.bit.GPIO40=2;
        GpioCtrlRegs.GPBMUX1.bit.GPIO41=2;
        GpioCtrlRegs.GPBMUX1.bit.GPIO42=2;
        GpioCtrlRegs.GPBMUX1.bit.GPIO43=2;
        GpioCtrlRegs.GPBMUX1.bit.GPIO44=2;
        GpioCtrlRegs.GPBMUX1.bit.GPIO45=2;
        GpioCtrlRegs.GPBMUX1.bit.GPIO46=2;
        GpioCtrlRegs.GPBMUX1.bit.GPIO47=2;
        GpioCtrlRegs.GPCMUX2.bit.GPIO80=2;
        GpioCtrlRegs.GPCMUX2.bit.GPIO81=2;
        GpioCtrlRegs.GPCMUX2.bit.GPIO82=2;
        GpioCtrlRegs.GPCMUX2.bit.GPIO83=2;
        GpioCtrlRegs.GPCMUX2.bit.GPIO84=2;
        GpioCtrlRegs.GPCMUX2.bit.GPIO85=2;
        GpioCtrlRegs.GPCMUX2.bit.GPIO86=2;
        GpioCtrlRegs.GPCMUX2.bit.GPIO87=2;
        GpioCtrlRegs.GPBMUX1.bit.GPIO39=2;
        GpioCtrlRegs.GPAMUX2.bit.GPIO31=2;
        GpioCtrlRegs.GPAMUX2.bit.GPIO30=2;
        GpioCtrlRegs.GPAMUX2.bit.GPIO29=2;
        //GPIO0:通用IO,输入,配置成中断XINT1,用于相应NAT9914的中断请求
        GpioCtrlRegs.GPAMUX1.bit.GPIO0=0;
        GpioCtrlRegs.GPADIR.bit.GPIO0=0;
        //GPIO1:通用IO,输出,初始值设为0,高电平有效,用于RESET NAT9914
        //GpioCtrlRegs.GPAMUX1.bit.GPIO1=0;
        //GpioCtrlRegs.GPADIR.bit.GPIO1=1;
        //GpioDataRegs.GPADAT.bit.GPIO1=0;
       
        //GPIO2:通用IO,输出,初始值设为1,用于使能芯片xx 1OE
        GpioCtrlRegs.GPAMUX1.bit.GPIO2=0;
        GpioCtrlRegs.GPADIR.bit.GPIO2=1;
        GpioDataRegs.GPADAT.bit.GPIO2=0;
        //GPIO3:通用IO,输出,初始值设为1,用于使能芯片xx 2OE
        GpioCtrlRegs.GPAMUX1.bit.GPIO3=0;
        GpioCtrlRegs.GPADIR.bit.GPIO3=1;
        GpioDataRegs.GPADAT.bit.GPIO3=0;
        //GPIO4:通用IO,输出,用于控制芯片xx 1传输方向  高电平写入NAT9914 低电平从NAT9914读取,初始值设为0(低电平)
        GpioCtrlRegs.GPAMUX1.bit.GPIO4=0;
        GpioCtrlRegs.GPADIR.bit.GPIO4=1;
        GpioDataRegs.GPADAT.bit.GPIO4=0;
        //GPIO37:XZCS7
        GpioCtrlRegs.GPBMUX1.bit.GPIO37=2;
       
        //GPIO38:XWE0
        GpioCtrlRegs.GPBMUX1.bit.GPIO38=2;
        EDIS;
}
int inp(long io_address)     //nat9914读取数据
{
    int value;
    GpioDataRegs.GPADAT.bit.GPIO4 = 0;
    value=*(int *)io_address;
    return value;
}
void outp(long io_address,u_8 o_data)   //nat9914写入数据
{
    GpioDataRegs.GPADAT.bit.GPIO4 = 1;
    *(int *)io_address = o_data;
}

图片3.png (319.74 KB )

图片3.png

图片2.png (94.52 KB )

图片2.png

图片1.png (68.16 KB )

图片1.png

使用特权

评论回复

相关帖子

沙发
zhangmangui| | 2019-8-11 00:11 | 只看该作者
我觉得只能对比两者的时序了   看是否有差异  

使用特权

评论回复
板凳
airwill| | 2019-8-27 21:29 | 只看该作者
直接用示波器捕捉一下时序波形, 看看有没有满足手册要求再说

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

1

主题

2

帖子

0

粉丝