Hi
attached Image shows the timing diagram for SPI sensor
And the register values for read/write operation is given below
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
Hi,
I find your attached SPI timing is so strange, the correct one should same with below picture:
Wish it helps.
Best regards,
Ma Hui
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi
I am using Synchromaster SPI component for SPI and following is the settings, When I probed the CS pin I found it is at one steady state of logic high. It is not changing its logic level. I somehow managed to get the o/p from slave's WHO_AM_I register but when I am leaving cs pin floating then only I am getting the values that too with uncertainty. Sometimes the values come but some times 0x00. the occurrence is not proper,I tried with external bit_io pin as cs pin but that also didn't worked.
the waveform of SCLK-MOSI is following, here I am sending 0xA0FF value . Starting A0--> r/w + other register's address as discussed above. FF--> these are don't care bits.
the waveform of sclk-MISO is following. In this as per the diagram mentioned earlier the data bits are acquired in the last 8 bits. The response as expected was 0xB1 which I am getting some times.
When the value dosen't come then waveform for sclk-MISO is following. Here I am getting 0x00
the combined waveform of MOSI-MISO is following
As I mentioned the CS pin (here PTD0) is not working it is by default in disable state so its waveform is below.
My Current code which is using the SPI_PDD . thanks to BlackNightfor his link for PDD driver is below
/* User includes (#include below this line is not maintained by Processor Expert) */
int32_t i;
/*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();
/*** End of Processor Expert internal initialization. ***/
/* Write your code here */
for(;;)
{
SPI_PDD_WriteSlaveData16Bits(SPI0_BASE_PTR, 0xA0FF);
i = SPI_PDD_ReadData8bits(SPI0_BASE_PTR);
printf("0x%0X\n",i);
WAIT1_Waitms(400);
}
/*** 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!!! ***/
the o/p in terminal window (when CS pin is floating)
When CS pin connected to 0 or 3.3V I am getting the following o/p
Regards
Amit Kumar
Hi Amit,
FXOS8700CQ datasheet shows FXOS8700CQ only supports a point-to-point SPI protocol, with only one master (MCU) and one slave device (FXOS8700CQ) present on the bus. The CS_B pin is driven low at the start of a SPI transaction, held low for the duration of the transaction, and driven high after the transaction is complete.
From your description, it should use SPI CS pin during the communication.
More detailed info, please check below link chapter 5.2.1 General SPI operation:
http://cache.freescale.com/files/sensors/doc/data_sheet/FXOS8700CQ.pdf
Wish it helps.
Best regards,
Ma Hui
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Hui Ma
Thanks for the important notice that FXOS8700CQ supports only 1 master and 1 slave in both SPI as well as I2C mode So I will connect this with a dedicated SPI. For the rest of the sensors I will connect to another SPI bus. Here I am facing another issue , my CS pin is not going low. I have configured it through internal SPI's chip select pin. The above waveforms shown is when nothing is connected to that pin. i.e no sensor is connected to PTDO. I tried using both Synchromaster and SPIMaster_LDD I don't know what I am doing wrong. May be because I Have configured it and I am not using any of its function in the above program, instead I am using functions from SPI_PDD. Can that be the reason ? If so How to do chip select using SPI_PDD component ? I also tried the same using the following code
SPI_PDD_SetChipSelectInactiveStateMask(SPI0_BASE_PTR, SPI_PDD_CHIP_SELECT_0, SPI_PDD_CHIP_SELECT_0);
But this also didn't work. One last question In the above waveforms when the MISO is sending data , initially there is a small fluctuation for the first 8 bits with very low amplitude then the data signal is send. So is there any way to suppress that? I tried adding 10K pull up it didn't work then also tried it with 10k pull down but not much effective.
Kind Regards
Amit Kumar