This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

tms320vc5505

Other Parts Discussed in Thread: TMS320VC5505

myself using tms320vc5505  ezdsp usb stick processor to communicate sensor fpc1011f3 in spi to get data .. first i tried if i write in a register i cant read a data from that..if sensor is connected i get 4040 as read data.. if i disconnected sensor i get data as ffff.

               Hardware Platform :

                                PROCESSOR  :    TMS320VC5505

                                KIT                    :    TMS320VC5505 eZDSP Stick         

                                SENSOR          :    fingerprint sensor FPC1011F3





                Software Platform :

                                CODE COMPOSER STUDIO Version 4.0



And I also  attached the documents of the TMS320VC5505.



Our Connection details :

                  PROCESSOR                                        SENSOR  

                1 . SPI_TX            -------->                AREA_SI

                2 . SPI_RX            -------->                AREA_SO

                3 . SPI_CLK           -------->               AREA_SCLK

                4 . SPI_CS1          -------->               AREA_SCN

                5 . GND                 -------->                GND

                6.  3.3V                 -------->                VDD to Sensor

                7 .  GPIO22           -------->               SENSOR_RST_N  in FPC1011F3  Area Sensor .











CODING :



#define SPI_SPICC1         *(volatile ioport Uint16*)(0x3000)

#define SPI_SPICC2         *(volatile ioport Uint16*)(0x3001)

#define SPI_SPIDC1         *(volatile ioport Uint16*)(0x3002)

#define SPI_SPIDC2         *(volatile ioport Uint16*)(0x3003)

#define SPI_SPICR1         *(volatile ioport Uint16*)(0x3004)

#define SPI_SPICR2         *(volatile ioport Uint16*)(0x3005)

#define SPI_SPISR1         *(volatile ioport Uint16*)(0x3006)

#define SPI_SPISR2         *(volatile ioport Uint16*)(0x3007)

#define SPI_SPIDR1         *(volatile ioport Uint16*)(0x3008)

#define SPI_SPIDR2         *(volatile ioport Uint16*)(0x3009)



#define rd_sensor       0x11

#define rd_spidata      0x20

#define rd_spistat      0x21

#define rd_regs         0x50

#define rd_drivc       0x75

#define rd_adcref       0x76

#define rd_sensem       0x77

#define wr_fifo_th      0x7C

#define wr_xsense       0x7F

#define wr_ysense       0x81

#define wr_xshift       0x82

#define wr_yshift       0x83

#define wr_xreads       0x84





void spisensor_init( )

{

      /* Enable SPI */

SYS_EXBUSSEL = (SYS_EXBUSSEL & 0x0fff) | 0x1000;

      SYS_PRCNTR = 0x04;

      SYS_PRCNTRLR = 0x0080;



    /* SPI Clock Control */

      SPI_SPICC2 = 0x0000; // SPI clock disabled

      SPI_SPICC1 = 0x00b0; // 12MHz input clock divided by 120



SPI_SPIDC1 = 0x0000; // SPI0 low idle clock, active low CS, shift out on rising clock, no clock delay

      SPI_SPIDC2 = 0x0000;  //device config

    

      SPI_SPICC2 = 0x8000; // SPI clock enabled

      SPI_SPICC2 = 0xC000;

      USBSTK5505_waitusec(10000);

      SPI_SPICC2 = 0x8000;

    

}

void setDrivec()

{

      Uint16 buf,buf1,buf2,buf3;

      

SPI_SPICR1 = 0x0001;

      SPI_SPIDR2 = 0x7500;

      SPI_SPIDR1 = 0x0000;

      SPI_SPICR2 = 0x103A;   

      while((SPI_SPISR1 & 0x0002) == 0);

      buf = SPI_SPIDR2;

      buf1 = SPI_SPIDR1;

      SPI_SPIDR2 = 0x7F00;

      SPI_SPIDR1 = 0x0000;

      SPI_SPICR2 = 0x103A;  

      while((SPI_SPISR1 & 0x0002) == 0);

      buf2 = SPI_SPIDR2;

      buf3 = SPI_SPIDR1;

printf("\n dummyByte of Drivec=0x%x",buf);

      printf("\n dummyByte of Drivec=0x%x",buf1);

      printf("\n dummyByte of Drivec=0x%x",buf2);

      printf("\n dummyByte of Drivec=0x%x",buf3);

      

      USBSTK5505_waitusec(10000);

}



void setAdcref()

{

      Uint16 buf,buf1,buf2,buf3;

      

      SPI_SPICR1 = 0x0001;

      SPI_SPIDR2 = 0x7600;

      SPI_SPIDR1 = 0x0000;

      SPI_SPICR2 = 0x103A;   

      while((SPI_SPISR1 & 0x0002) == 0);

      buf = SPI_SPIDR2;

      buf1 = SPI_SPIDR1;

      SPI_SPIDR2 = 0x0200;

      SPI_SPIDR1 = 0x0000;

      SPI_SPICR2 = 0x103A;  

      while((SPI_SPISR1 & 0x0002) == 0);

      buf2 = SPI_SPIDR2;

      buf3 = SPI_SPIDR1;

      printf("\n dummyByte of setadcref=0x%x",buf);

      printf("\n dummyByte of setadcref=0x%x",buf1);

      printf("\n dummyByte of setadcref=0x%x",buf2);

      printf("\n dummyByte of setadcref=0x%x",buf3);

      

      USBSTK5505_waitusec(10000);

}



void setSensem()

{

      Uint16 buf,buf1,buf2,buf3;

      

      SPI_SPICR1 = 0x0001;

      SPI_SPIDR2 = 0x7700;

      SPI_SPIDR1 = 0x0000;

      SPI_SPICR2 = 0x103A;   

      while((SPI_SPISR1 & 0x0002) == 0);

      buf = SPI_SPIDR2;

      buf1 = SPI_SPIDR1;

      SPI_SPIDR2 = 0x0000;

      SPI_SPIDR1 = 0x0000;

      SPI_SPICR2 = 0x103A;  

      while((SPI_SPISR1 & 0x0002) == 0);

      buf2 = SPI_SPIDR2;

      buf3 = SPI_SPIDR1;

     printf("\n dummyByte of mems=0x%x",buf);

      printf("\n dummyByte of mems=0x%x",buf1);

      printf("\n dummyByte of mems=0x%x",buf2);

      printf("\n dummyByte of mems=0x%x",buf3);

USBSTK5505_waitusec(10000);

}



void readSensor()

{

      Uint16 buf,buf1,buf2,buf3;

  

      SPI_SPICR1 = 0x0001;

      

      SPI_SPIDR2 = 0x1100;

      SPI_SPIDR1 = 0x0000;

      SPI_SPICR2 = 0x1039;   

      while((SPI_SPISR1 & 0x0002) == 0);

      buf = SPI_SPIDR2;

      buf1 = SPI_SPIDR1;

      SPI_SPIDR2 = 0x0000;

      SPI_SPIDR1 = 0x0000;

      SPI_SPICR2 = 0x1039;  

      while((SPI_SPISR1 & 0x0002) == 0);

      buf2 = SPI_SPIDR2;

      buf3 = SPI_SPIDR1;

      

      printf("\n dummyByte of readsen=0x%x",buf);

      printf("\n dummyByte of readsen=0x%x",buf1);

      printf("\n dummyByte of readsen=0x%x",buf2);

      printf("\n dummyByte of readsen=0x%x",buf3);

      USBSTK5505_waitusec(10000);

}



void readStatus()

{

      Uint16 buf,buf1,buf2,buf3,buf4,buf5;

      int i;

      Uint16 dummy,dummy1;

      char dummy3;

        

      SPI_SPICR1 = 0x0002;

      

      SPI_SPIDR2 = 0x2100;

      SPI_SPIDR1 = 0x0000;

      SPI_SPICR2 = 0x1039;   

      while((SPI_SPISR1 & 0x0002) == 0);

      buf = SPI_SPIDR2;

      buf1 = SPI_SPIDR1;

      SPI_SPIDR2 = 0x0000;

      SPI_SPIDR1 = 0x0000;

      SPI_SPICR2 = 0x1039;  

      while((SPI_SPISR1 & 0x0002) == 0);

      buf2 = SPI_SPIDR2;

      buf3 = SPI_SPIDR1;

      SPI_SPIDR2 = 0x0000;

      SPI_SPIDR1 = 0x0000;

      SPI_SPICR2 = 0x1039;

      while((SPI_SPISR1 & 0x0002) == 0);

      buf4 = SPI_SPIDR2;

      buf5 = SPI_SPIDR1;

printf("\n dummyByte of readStatus=0x%x",buf);

      printf("\n dummyByte of readStatus=0x%x",buf1);

      printf("\n dummyByte of readStatus=0x%x",buf2);

      printf("\n dummyByte of readStatus=0x%x",buf3);

      printf("\n dummyByte of readStatus=0x%x",buf4);

      printf("\n dummyByte of readStatus=0x%x",buf5);

    /*

    do 

    {

      SPI_SPICR1 = 0x0000;

      

            SPI_SPIDR2 = 0x0000;

            SPI_SPIDR1 = 0x0000;

            SPI_SPICR2 = 0x1039;   

            while((SPI_SPISR1 & 0x0002) == 0);

      dummy = SPI_SPIDR2;

      dummy1 = SPI_SPIDR1;

      dummy3=dummy >> 8;

       printf("\n dummy=0x%x",dummy);

        printf("\n dummy1=0x%x",dummy1);

       printf("\n dummy3=0x%x",dummy3);

    }while (!(dummy3&0x01));

    

    */

}





void readSpidata()

{

      Uint16 buf,buf1,buf2,buf3,buf4,buf5;

  

      SPI_SPICR1 = 0x0002;    

      SPI_SPIDR2 = 0x2000;

      SPI_SPIDR1 = 0x0000;

      SPI_SPICR2 = 0x1039;   

      while((SPI_SPISR1 & 0x0002) == 0);

      buf = SPI_SPIDR2;

      buf1 = SPI_SPIDR1;

      SPI_SPIDR2 = 0x0000;

      SPI_SPIDR1 = 0x0000;

      SPI_SPICR2 = 0x1039;  

      while((SPI_SPISR1 & 0x0002) == 0);

      buf2 = SPI_SPIDR2;

      buf3 = SPI_SPIDR1;

      SPI_SPIDR2 = 0x0000;

      SPI_SPIDR1 = 0x0000;

      SPI_SPICR2 = 0x1039;

      while((SPI_SPISR1 & 0x0002) == 0);

      buf4 = SPI_SPIDR2;

      buf5 = SPI_SPIDR1;

      

      printf("\n dummyByte of readSpi=0x%x",buf);

      printf("\n dummyByte of readSpi=0x%x",buf1);

      printf("\n dummyByte of readSpi=0x%x",buf2);

      printf("\n dummyByte of readSpi=0x%x",buf3);

      printf("\n dummyByte of readSpi=0x%x",buf4);

      printf("\n dummyByte of readSpi=0x%x",buf5);

      USBSTK5505_waitusec(10000);

}



void readData()

{     

      Uint16 data[1000];

      int i;

      

      for (i=0;i<1000;i=i+2)

      {

      SPI_SPICR1 = 0;

      SPI_SPIDR2 = 0;

      SPI_SPIDR1 = 0;

      SPI_SPICR2 = 0x1039;  

      while((SPI_SPISR1 & 0x0002) == 0);

data[i] = SPI_SPIDR2;

     data[i+1] = SPI_SPIDR1;

      }

      

      for(i=0;i<1000;i=i+2)

      {

      printf("\n Datas=0x%x",data[i]);          //always Data comes  like Datas=0x4040

      printf("\n Datas=0x%x",data[i+1]);        //always Data comes  like Datas=0x4040

      }

      }



void readtouch()            //function for reading the sensor 

{

            

      int a;

      Uint16 ab[100],bc[100];

    

      spisensor_init( );



      USBSTK5505_SensorResetHigh();

      USBSTK5505_waitusec( 500000 );

      USBSTK5505_SensorResetLow();  

      USBSTK5505_waitusec( 500000 );

      

      setDrivec();

      setAdcref();

      setSensem();

        

      readSensor();

      

      for(a = 0; a <50; a++) {

      SPI_SPICR1 = 0;

      SPI_SPIDR2 = 0;

      SPI_SPIDR1 = 0;

      SPI_SPICR2 = 0x1039;  

      while((SPI_SPISR1 & 0x0002) == 0);

      ab[a] = SPI_SPIDR2;

     //bc[a+1] = SPI_SPIDR1;

      }

      for(a = 0; a <50; a++) {

      printf("dummy bytes=0x%x",ab[a]); 

      }

            

      // readStatus();



      USBSTK5505_waitusec(500000);

      readSpidata();

      readData();

            

}