Board logo

标题: TMS320VC5509A 读写AT24C256的问题 [打印本页]

作者: yjb_bj    时间: 2005-11-24 14:06     标题: TMS320VC5509A 读写AT24C256的问题

Help Me!
  用的芯片是TMS320VC5509A,开发环境是CCS3.1,仿真器是合众达的SEED XDS510USB2.0,用C语言编写。在开发过程中遇到几个问题,希望大虾不吝赐教。
1. 在CCS3.1 SETUP下,选择C5509A XDS510 Emulator,启动CCS3.1,连接仿真器和目标板时,Messages窗口出现“GEL: Error while executing OnTargetConnect(): memory map prevented write to target memory at 0x0007FE@I/O.”。是什么原因?而在在CCS3.1 SETUP下,选择C5509 XDS510 Emulator,则没出现上述问题。
2. I2C外接AT24C256。DSP工作在MASTER MODE。利用CSL的API函数,初始化I2C模块时,程序如下:

#include <csl.h>
#include <csl_chip.h>
#include <csl_i2c.h>
#include <csl_pll.h>

//---------Global data definition---------
int x=1,y=1,z=1;
Uint16 databyte1[7] = {0,0x10,0x11,0x12,0x13,0x14,0x15};
Uint16 datareceive1[6]={0,0,0,0,0,0};
Uint16 databyte2[7] = {0,0x15,0x20,0x21,0x22,0x23,0x24};
Uint16 datareceive2[10]={0,0,0,0,0,0,0,0,0,0};
Uint16 slaveaddressreceive[2]={0,0x10};

// Create and initialize an PLL initialization structure
// DSP CLK = 12X24/2 = 144MHz
PLL_Config  ConfigPLL = {
    1,        
    1,
    24,
    1
};

// Create and initialize an I2C initialization structure
I2C_Setup Init_I2C = {

        0,              // 7 bit address mode
        0x0000,         // own address - don't care if master
        144,            // clkout value (Mhz)
        200,            // a number between 10 and 400
        0,              // 8 bits/byte to be received or transmitted
        0,              // DLB mode on
        1               // FREE mode of operation on
};



//---------Function prototypes---------

void taskFunc(void);

void delay(void);

//---------main routine---------

void main(void)
{
    CSL_init();

    LL_config(&ConfigPLL);
    I2C_setup(&Init_I2C);

    taskFunc();
    while(1);
}

void taskFunc(void)
{
    x=I2C_write(databyte1,7,1,0x50,1,30000);
    y=I2C_write(slaveaddressreceive,2,1,0x50,2,30000);
    z=I2C_read(datareceive1,5,1,0x50,3,30000,0);
    I2C_sendStop();

    x=I2C_write(databyte2,7,1,0x50,1,30000);
    y=I2C_write(slaveaddressreceive,2,1,0x50,2,30000);
    z=I2C_read(datareceive2,10,1,0x50,3,30000,0);
    I2C_sendStop();

    x=1;
}

以上程序在调试过程中遇到了2个问题:
1. 当注释掉PLL_config(&ConfigPLL)语句,或将其置于taskFunc()后,则程序能读写AT24C256,反之则不能正确读写;
2. 在能读写AT24C256的情况下,即注释掉PLL_config(&ConfigPLL),第一次写I2C_write(databyte1,7,1,0x50,1,30000)能正确执行,因为I2C_read(datareceive1,5,1,0x50,3,30000,0)能正确读出写进的数据,但第二次写I2C_write(databyte2,7,1,0x50,1,30000)不能正确执行,因为z=I2C_read(datareceive2,10,1,0x50,3,30000,0)不能正确读出写进的数据。当注释掉    y=I2C_write(slaveaddressreceive,2,1,0x50,2,30000);
    z=I2C_read(datareceive1,5,1,0x50,3,30000,0);
    I2C_sendStop();
三条语句时,I2C_read(datareceive2,10,1,0x50,3,30000,0)能正确读出两次写入的数据。似乎I2C_read(datareceive2,10,1,0x50,3,30000,0)有问题,AT24C256输出数据完毕,最后要求MASTER发送NACK信号,I2C_read()没有发。怎样解决该问题?帮帮忙,多谢了!





欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) Powered by Discuz! 7.0.0