2016-02-16 05:14 AM
No answer from the register who I am.
The most interesting is that this code worked for a while, but now does not work.I have
attached a file
that previously
all worked.
/* USER CODE BEGIN 0 */ uint8_t SPI_read(uint8_t address) { uint8_t reciveData; address = 0x80 | address; CS_ON HAL_SPI_TransmitReceive(&hspi1,&address,&reciveData,1,100); uint8_t data=0x00; HAL_SPI_TransmitReceive(&hspi1,&data,&reciveData,1,100); CS_OFF return reciveData; } /* USER CODE END 0 */ /* USER CODE BEGIN 2 */ RED_LED_ON GREEN_LED_ON if (SPI_read(0x0F)==0x3B){ RED_LED_OFF }else if(SPI_read(0x0F)==0x3F)//LIS3DSH GREEN_LED_OFF /* USER CODE END 2 */ /* SPI1 init function */ void MX_SPI1_Init(void) { hspi1.Instance = SPI1; hspi1.Init.Mode = SPI_MODE_MASTER; hspi1.Init.Direction = SPI_DIRECTION_2LINES; hspi1.Init.DataSize = SPI_DATASIZE_8BIT; hspi1.Init.CLKPolarity = SPI_POLARITY_HIGH; hspi1.Init.CLKPhase = SPI_PHASE_2EDGE; hspi1.Init.NSS = SPI_NSS_SOFT; hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_256; hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB; hspi1.Init.TIMode = SPI_TIMODE_DISABLED; hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLED; hspi1.Init.CRCPolynomial = 10; HAL_SPI_Init(&hspi1); }2016-02-17 10:50 PM
Hi britwa.boris,
Could you please precise the updates you made so that we can deduce the cause of the problem you are facing? You said that previously it was working as expected.-Mayla-To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2016-02-20 04:35 AM
Thanks for the reply
!!!
I wrote some
code
at the top of
that
I have used.
Sensor
replied
0x3F
(see
attached file
).Then
I turned off
the board and
turned on
later
and the answer
of who I am
-
0xff
.I
noticed
early
that the code
at the top
does not work
if
I disable
the logic analyzer
(
I do not knowwhy it
happened
)
.Now the code
is not working
,
so I
did
.Now,
if you connect a
logic analyzer
and ask
SPI_read (0x0F)
all
look the same
but
in response
I see
0xFF
.See
has attached
file!!!!
I
think it is not necessary
any
initialization
before you read
the register
who I am
?
I am very
upset .
Initially,
perhaps
in my actions
there is an error
.
I will be glad
to your opinion .
Had to dig
in smartphones
and
unsolder
the accelerometer
another brand
(
bma150
)
Under him have to make a Board
,
because
it is very small
.
________________ Attachments : NOT_OK.jpg : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I0ml&d=%2Fa%2F0X0000000bdd%2F3jwxa8ON69dV8nN3pyhXNoGV3roeleIMKSWKH1I4IJM&asPdf=falseSam_file.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I0mg&d=%2Fa%2F0X0000000bdb%2FuIUh19Wa2UjtpvuInQ778mTJTyycibMF9t2x09DuIHE&asPdf=false