Тёмный

SPI (Serial Peripheral Interface) Part 2: Programming with Zephyr, nRF52840-DK and Bosch BME280 

Подписаться
Просмотров 5 тыс.
% 63

SPI (Serial Peripheral Interface) is a serial transmission protocol used for communication between microcontrollers and peripheral devices such as sensors, memories or displays. It is easy to implement and offers high transmission speed, making it a common choice for many embedded systems. In diesem Video programmieren wir SPI mit Zephyr. Wir benutzen als Hardware das Nordic nRF52840-DK und den Sensor Bosch BME280.
You can support me at Patreon:
www.patreon.com/WSNandIoT
---Hardware--------
nRF52840 DK:
www.nordicsemi.com/Products/Development-hardware/nrf52840-dk
Adafruit BME280:
www.adafruit.com/product/2652
Sparkfun Logic Analyzer:
www.sparkfun.com/products/18627
---Software--------
nRF Connect SDK:
www.nordicsemi.com/Products/Development-software/nrf-connect-sdk
Logic Anlayzer PulseView:
sigrok.org/wiki/PulseView
00:00 Introduction
01:50 Connect BME280 with nRF52840-DK
06:00 Read out CHIP-ID
15:44 Read out calibration register
21:00 Set configuration register
25:00 Read uncompensated sensor values
27:40 Calculate compensated sensor values
32:40 Using chip select from Zephyr device tree
36:00 Outro
#zephyr #bme280 #spi

Наука

Опубликовано:

 

20 фев 2023

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 27   
@xThirdOpsx
@xThirdOpsx 7 месяцев назад
Thanks for putting this together.
@winstonalf
@winstonalf Год назад
This was really helpful. Thank you very much !!!!
@wsniot
@wsniot Год назад
Thx for the positive feedback.
@TzeChienChu
@TzeChienChu Месяц назад
Thanks for your sharing. When do you plan to write a book ?
@wsniot
@wsniot Месяц назад
You are welcome. Book is already available: WSN and IoT: Basics, protocols and applications a.co/d/iHExiPG
@TzeChienChu
@TzeChienChu Месяц назад
@wsniot We need more detail how to use zephyr
@mathicalee
@mathicalee Год назад
Thanks a lot!! Going very deep, it's just what I always wanted!! 😆😆 I have some questions though. - The dummy address 0xff at the end, you had to use one which doesn't exist, right? Or doesn't it play a role because you don't read after 0xFF?. - You set once that you want to oversample 8x. Does the sensor measure the whole time even if you read the values only once per second? Or every minute? Or does the sensor sample data only every time you read? And if that so, does the sensor have enough time to measure things and sends back to the controller? - And I think the correction what you made with 0x7f was right what you said. Because the bitwise OR with 0x7f is setting the first bit to 0 and keeps every other bits.
@wsniot
@wsniot Год назад
1. Actually you can use any dummy value you want. But of course if it is a command what the peripheral understands like a register it will react. But since the CS line will be high again the communication ends. Mostly it is better sending just 0xFF or 0x00. 2. In normal mode the sensor measures the hole time. It has a measurement cycle and the a standby time which can be maximum 1s, but if i see it right the default standby time is at 0.5ms (t_sb[2:0]). The maximmum measure with 8x oversampling is t_measure,max=58.175ms. So we get every 58,675ms a new measurement in the registers. For weather data 1x oversampling is actually enough. The measure time will be significantly smaller. 3. Normaly you count a word in most significant bit order here (b_7 b_6 ... b_0). And then it is b_7 what you have to set to 0 and not b_0. Its always a question what is meant with the first bit.
@vigneshs6232
@vigneshs6232 Год назад
Thankyou for your video....Really useful..do More Videos like these....
@jwalkerbg60
@jwalkerbg60 Год назад
Hello, I did not realize, why did you not use spi_cfg.cs field? I saw that you toggle CS "manually". But why so, and not using the field .cs?
@wsniot
@wsniot Год назад
The explanation follows at about minute 31. This did not work with the BME280. After each command, the CS-Line was automatically set to disable again and the BME280 was deactivated before it could send the already prepared data.
@lukaspetrikas6320
@lukaspetrikas6320 10 месяцев назад
@@wsniot I also have the same question. I have issues with the chip select when I am trying to use .cs Do I need to change anything in the device tree or project configuration if I want to use automatic chip select toggling instead of manual as it does not seem to work "out of the box" ?
@elrickmanchester407
@elrickmanchester407 2 месяца назад
Hi, sir, I have a question. Have you tried the zephyr SPI comm with an NRF52832? I seem to have a trouble trying to communicating with a DWM1000 qorvo devboard. I manage to send 0x00, but failed to receive the chip ID, I always get 0xFFFFFFFF
@verbandderrusslanddeutsche7180
@verbandderrusslanddeutsche7180 21 день назад
Hey, did you find a solution to your Problem? I'm currently trying to communicate with the DWM1000 via the DWM1001-dev board
@MartinMurphy-w3y
@MartinMurphy-w3y 11 месяцев назад
Hi, thanks for this. One question, you don't set the read bit MSB of the register address. Is there a reason for this?
@wsniot
@wsniot 11 месяцев назад
For a read instruction it is automatically set by the register macros. For write instructions I set the MSB of the register to zero with adding 0x7F(see 23:26).
@zedzhang2766
@zedzhang2766 Месяц назад
Kindly ask if this code is opened on github?
@thanuha5059
@thanuha5059 Год назад
We are trying to connect with lsm6dsl in our custom board which has nrf52840 through SPI. Can you point us to the right tutorial or video help resources since we are unable to communicate with the IC through the example code(is using i2c) and also unable to configure it to use SPI.
@wsniot
@wsniot Год назад
I would recomment you using for testing an Developerkit first. Try SPI with the BME280 like here and then try to implement the SPI-communication with your IMU. If this is working you adapt it with your custom board.
@dalangalit378
@dalangalit378 Год назад
❤️❤️
@mayureshpitale2810
@mayureshpitale2810 Год назад
we are trying to write and read data on EEPROM 93C46B using nrf52832 via SPI can you help me out with how I can send commands and data using the transrecieve function.
@wsniot
@wsniot Год назад
The spi_write and spi_read functions only call the spi_transceive function. With spi_write the rx_buffer is set to NULL and with spi_read the tx_buffer. With SPI, sending and receiving always take place simultaneously. If I want to receive and send at the same time, both buffers simply have to be defined.
@mayureshpitale2810
@mayureshpitale2810 Год назад
@@wsniot which part of your video I should refer to so better understand this?
@wsniot
@wsniot Год назад
@@mayureshpitale2810 I dont get the point of your question? Do you have trouble understanding SPI or how to control the 93C46B ? You have to take a look in the datasheet from the 93C46B for the specific commands. SPI is not a 100% uniformly implemented standard. Always a good idea is also to test it with an arduino library first and using a logic analyzer for making the commands visible and then send the same commands with Zephyr.
@mayureshpitale2810
@mayureshpitale2810 Год назад
@@wsniot I want to understand the part where we set the buffers for the spi_transceive function as I have trouble using that function. because I'm not able to set the values of the buffers as I want.
@arthurchow-h8t
@arthurchow-h8t 6 месяцев назад
能不能配上中文字幕?
@arthurchow-h8t
@arthurchow-h8t 3 месяца назад
没有中文字幕,看起来,太费劲了.