0
\$\begingroup\$

I come back wih a new questions, I tried to communicate with my sensor(slave) but he is not responding at all.

My first question is : Do I need to do the Power-Up Sequence explained in the datasheet or not?

Second there is a part called SROM Download and they said that there is a Firmware supplied but I didn't receive anything with the sensor except the complete datasheet

My code work because I succeeded to send a data and generate a clock but no response from the sensor.

enter image description here

enter image description here

Hello guys, I come back with a good news, we received the firmware, here is my updated code, but I have a problem it's that when I verified the communication in the oscilloscope I noticed the sensor did not respond. Please help And thank you in advance.

Here is my code :

void Init(void)

{

// Master initialisation

OSCCON   =  0b00111000;                 // 1MHz : default value also    

TRISB    =  0b01000100;                

ANSELB   =  0b00000001;

SSP2STAT =  0b10000000;                 

SSP2ADD =   0b11111111;                 // 

SSP2CON1 =  0b00101010;                 / 

IPR3bits.SSP2IP=1;                      // MSSP interrupt high priority

PIR3bits.SSP2IF=0;                      // MSSP interrupt flag cleared

PIE3bits.SSP2IE=0;                      // MSSP interrupt enable

}

void SROM_Download(void)      

{   

unsigned char c;

int i;

SPI_WritetoRegister(Config2, 0x00);                //2 : bit5 = 0, others 


SPI_WritetoRegister(SROM_Enable, 0x1D);            //3

delayms(10);                                       //4  

SPI_WritetoRegister(SROM_Enable, 0x18);            //5

// 6 : write the SROM file (=firmware data)     

SPI_CS = 0; 

SSP2BUF = SROM_Load_Burst | 0x80;                  // write burst ion a

while(!SSP2STATbits.BF);                           

delay10microsec(2);                                

// 6 : send all bytes of the firmware     

for( i = 0; i < firmware_length; i++)

    { 

      c = firmware_data[i];

      SSP2BUF = c;                            

      while(!SSP2STATbits.BF);

      delay10microsec(2);

    }

SPI_CS = 1;

}

void PowerUpSequence(void) 

{    

SPI_CS = 1;                                               // 2

SPI_CS = 0;                                               // 2

SPI_CS = 1;                                               // 2

SPI_WritetoRegister(Power_Up_Reset, 0x5A);                // 3 : force 

delayms(50);                                              // 4

SPI_ReadfromRegister(Motion);                             // 5

SPI_ReadfromRegister(Dx_L);

SPI_ReadfromRegister(Dx_H);

SPI_ReadfromRegister(Dy_L);

SPI_ReadfromRegister(Dy_H);                               // 5   

SROM_Download();                                          //6    

delayms(10);

SPI_ReadfromRegister(Motion);                             // 7 : Read 

delay100microsec(10);

}

unsigned char SPI_ReadfromRegister(unsigned char addr)  //Verified

{        

SPI_CS = 0;                         // Set CS low  

// send adress of the register, with MSBit = 0 to indicate it's a read

SSP2BUF = addr & 0x7f;                

while(!SSP2STATbits.BF);                // wait until the all bits sended 

delay100microsec(2);                    // wait tsrad (160us)

// read data

SSP2BUF = 0x00;                

while(!SSP2STATbits.BF);                // wait until the all bits sended  

delaymicrosec(1);                       // tSCLK-NCS for read operation    

SPI_CS = 1;                            // Set CS High 

delay10microsec(2);                    //  tSRW&tSRR (=20us) 

return(SSP2BUF);

}


void SPI_WritetoRegister(unsigned char addr, unsigned char data)     

{      

SPI_CS = 0;                                 // Set CS low      

//send adress of the register, with MSBit = 1 to indicate it's a write    

SSP2BUF = addr | 0x80;                      

while(!SSP2STATbits.BF);                    // wait until the all bits 

SSP2BUF = data;                             // put the data in the SSPBUF 

while(!SSP2STATbits.BF);                    // wait until the all bits

delay10microsec(4);                         // wait tSCLK-NCS for writeop

SPI_CS = 1;                                 // Set CS High  

delay100microsec(2);                        // tSWW&tSWR (= 180us)

}

void main (void)

{  

unsigned char value;  

Init();    

PowerUpSequence();

while(1)

{     

   //SPI_ReadfromRegister(Product_ID);                    // Read            

   //SPI_ReadfromRegister(inv_Product_ID);                    // Read

   SPI_ReadfromRegister(SROM_ID);                    // Read

}      

}***
\$\endgroup\$
3
  • \$\begingroup\$ Where did you find the extended data sheet? I also experiment with the PMT9101 sensors, but have only the short data sheet without chapters 5 to 9. I already have to run the ADNS-9800. This Chip required a firmware upload with every start. \$\endgroup\$
    – LarsE
    Apr 3, 2017 at 17:08
  • \$\begingroup\$ Hello, I'm in an internship and the datasheet was supplied when my tutor bought the product, but the firmware was not supplied. \$\endgroup\$ Apr 5, 2017 at 6:53
  • \$\begingroup\$ I look to the datasheet of adns-9800 and I noticed that is the same principle of PMT9101 here is the link : datasheet.octopart.com/ADNS-9800-Avago-datasheet-10666463.pdf \$\endgroup\$ Apr 5, 2017 at 9:07

1 Answer 1

1
\$\begingroup\$

Yes, you do. I would not expect this chip to function without doing these things in the proper sequence.

So you will need the NCS, NRESET and SPI pins controllable from your microprocessor. Write the code to preform the proper timing (you will need to use wait functions in your code) and then check it with a logic analyzer (you can get cheap 8 bit ones nowadays)

If the chip still doesn't work, check the logic levels and power and make sure they are the right values from those listed in the datasheet.

As far as the SROM goes, the datasheet isn't clear. This is what I think it is: The SROM enable register (0x13) needs to be enabled before writing to R/W registers, and then the value will stay in the register even after a power down event. Either that or it might overwrite all the RO registers that are not accessible since you would probably want to write those values at some time. Contact the company to see what they mean.

\$\endgroup\$
1
  • \$\begingroup\$ Hello, first thanks for your help, I contacted the company and tell them to send us the Firmware file because it's said that is supplied but we don't have it, when I will get the Firmware I will go step by step and come back to share with you the news. \$\endgroup\$ Mar 29, 2017 at 7:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.