Other Parts Discussed in Thread: TMS320VC5505
Hello,
This is my second time posting about the TMS320C5505 eZDSP, right now I am trying to use the CSL version 3.01 to use I2C to communicate between the eZ DSP stick (master device) and a PCF8591 YL-40 ADC board (slave device). I am really struggling to understand what is going wrong, I have connected the two devices via a breadboard and used an oscilloscope to view the SCL and SDA waveforms, however they are always 0V. I am using 4.7kohm pull up resistors for SCL and SDA, I also tried 10k and a few lower values with no results. Here is my code so far:
#include "data_types.h" #include "hwafft.h" #include "stdio.h" #include "csl_i2c.h" #define CSL_I2C_SYS_CLK (12) //MHZ //Set CLK_SEL =1, use Pioneer Board to CLKIN or RTC,and bypass PLL #define CSL_I2C_BUS_FREQ (10) //KHz #define CSL_I2C_DATA_SIZE (16) //#define CSL_I2C_EEPROM_ADDR (0X50) //Replace this with slave address 1 #define PCF8591_ADDR (0x48) //Replace this with slave address 2 //#define adcAddr3 (0X50) //Replace this with slave address 3 //#define adcAddr4 (0X50) //Replace this with slave address 4 //#define adcAddr5 (0X50) //Replace this with slave address 5 //#define CSL_I2C_EEPROM_ADDR_SIZE (2) //" " #define PCF8591_ADDR_SIZE (7) #define CSL_I2C_OWN_ADDR (0x2F) void readinputs(); CSL_init(); //Variables for I2C Uint16 i2cDataBuf[CSL_I2C_DATA_SIZE]; Uint16 subaddr[CSL_I2C_DATA_SIZE + PCF8591_ADDR_SIZE]; CSL_Status status; CSL_I2cSetup i2cSetup; CSL_I2cIsrAddr i2cIsrAddr; //variables for FFT //data[8] = {1,2,3,4,5,6,7,8}; *uncomment when ready to read in Int32 *data; Int32 *data_br; Uint16 fft_flag; Uint16 scale_flag; Int32 *scratch; Uint16 out_sel; Int32 *result; void main() { readinputs(); fft_flag=FFT_FLAG; scale_flag = SCALE_FLAG; //Need to enable Clock //BCLR CLKOFF--> Clear CLKOFF //BSET CLKOFF--> Set CLKOFF, CLKOFF Disables the CLKOUT pin and resets it //Bit-reverse 1024-point data, store into data_br, data_br aligned to //12-least significant binary zeros hwafft_br(data,data_br,DATA_LEN_1024); //bit revese input data, Dstination buffer aligned data = data_br; //Compute 1024-point FFT, scaling enabled out_sel = hwafft_1024pts(data, scratch, fft_flag, scale_flag); if (out_sel == OUT_SEL_DATA) { result = data; } else { result = scratch; } } void readinputs() { //I2C setup i2cSetup.addrMode = CSL_I2C_ADDR_7BIT; i2cSetup.bitCount = CSL_I2C_BC_8BITS; i2cSetup.loopBack = CSL_I2C_LOOPBACK_DISABLE; i2cSetup.freeMode = CSL_I2C_FREEMODE_DISABLE; i2cSetup.repeatMode = CSL_I2C_REPEATMODE_DISABLE; i2cSetup.ownAddr = CSL_I2C_OWN_ADDR; i2cSetup.sysInputClk = CSL_I2C_SYS_CLK; i2cSetup.i2cBusFreq = CSL_I2C_BUS_FREQ; // initialize I2C status = I2C_init(CSL_I2C0); if(status != CSL_SOK) { printf("initialize failed\n"); } printf("Initialized\n"); // set up I2C status = I2C_setup(&i2cSetup); if(status != CSL_SOK) { printf("setup failed\n"); } printf("Setup\n"); status = I2C_start(); // I2C Read status = I2C_read(i2cDataBuf, CSL_I2C_DATA_SIZE, PCF8591_ADDR, subaddr, PCF8591_ADDR_SIZE, TRUE, 1, CSL_I2C_MAX_TIMEOUT, FALSE); //the 0's are put in the place of subADDR and subADDR length, which the example CPI code doesn't include! if(status == CSL_I2C_TIMEOUT_ERROR) { printf("Timing Out\n"); } if(status == CSL_SOK) { printf("hell yeah batman\n"); } }
The I2C portion is in a void function called readinputs, the code in main is meant to perform an FFT on the data read in to the DSP from the ADC board. Right now when I run the code it prints out that the initialize function and setup function are both successful, but there is a time out error when it gets to the read function. I am fairly certain that x48 is the correct address for the ADC board model, but maybe it is not acknowledging the DSP at all? I am very confused as to why there is no signal visible on SCL or SDA, and just not sure how to proceed. Any thoughts would be appreciated.
Thank you,
Jacob