Amit Kumar

How to read sensor's registers using SPI and Processor Expert ?

Discussion created by Amit Kumar on Apr 20, 2014
Latest reply on Apr 25, 2014 by Amit Kumar
Branched from an earlier discussion

Hi

attached Image shows the timing diagram for SPI sensor

SPI diagram.jpg

And the register values for read/write operation is given below

 

Timing registers.jpg

Right now I wanted to extract values from 0x20 for that I am writing the following code, Aslo I have tried with 0x2000(i.e from the above register values 100000 00000000) instead of 0xE000 (11100000 00000000)  in the following code but it didn't work

/* User includes (#include below this line is not maintained by Processor Expert) */

 

char rbuff[5];

LDD_TDeviceData *Sensor;

int x;

 

/*lint -save -e970 Disable MISRA rule (6.3) checking. */

int main(void)

/*lint -restore Enable MISRA rule (6.3) checking. */

{

/* Write your local variable definition here */

 

/*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/

PE_low_level_init();

Sensor = SM1_Init(NULL);

 

/*** End of Processor Expert internal initialization. ***/

 

/* Write your code here */

 

 

for(;;)

{

SM1_SendBlock(Sensor, 0xE000, 2);

SM1_ReceiveBlock(Sensor, rbuff, sizeof(rbuff));

printf("%s\n", rbuff);

WAIT1_Waitms(100);

}

 

/*** Don't write any code pass this line, or it will be deleted during code generation. ***/

/*** RTOS startup code. Macro PEX_RTOS_START is defined by the RTOS component. DON'T MODIFY THIS CODE!!! ***/

#ifdef PEX_RTOS_START

PEX_RTOS_START(); /* Startup of the selected RTOS. Macro is defined by the RTOS component. */

#endif

/*** End of RTOS startup code. ***/

/*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/

for(;;){}

/*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/

} /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/


But I am not receiving any thing right now, Can anyone help me out in this?

 

Thanks & Regards

Amit Kumar

Outcomes