No video

SPI peripheral with STM32 and PCM1792 audio DAC | VIDEO27

  Рет қаралды 12,040

Matej Blagšič

Matej Blagšič

Күн бұрын

Timestamps:
Hardware init = 17:25
SPI functions = 25:10
In this video I explain how SPI works and how to use it with STM32 with hal. As an example I use PCM1792 audio DAC as a peripheral device. With it we can demonstrate reading and writing into peripheral registers with SPI.
All resources are down below.
Code example used in the video:
github.com/prt...
My previous video on I2C:
• Using I2C for any devi...
Analog devices page on SPI:
www.analog.com...
Analog devices page on I2C:
www.analog.com...
Wikipedia SPI image author:
By SPI_timing_diagram.svg: en:User:Cburnettderivative work: Jordsan (talk) - SPI_timing_diagram.svg, CC BY-SA 3.0, commons.wikime...

Пікірлер: 25
@maksberlec4832
@maksberlec4832 4 жыл бұрын
Odlično! Zelo lepo, da tudi v Sloveniji nekdo počne dobre stvari.
4 жыл бұрын
Hvala hvala :)
@aljosaklajderic5580
@aljosaklajderic5580 2 жыл бұрын
Morem pohvaliti, ful dobra vsebina. Kljub temu, da sem imel kar nekaj predmetov v "embedded systems", se vedno nekaj novega naucim. Le tak naprej. 👍
2 жыл бұрын
Hvala lepa, me veseli da sem lahko predstavil se kaj novega.
@Mr0neShotAway
@Mr0neShotAway 4 жыл бұрын
Great video! Please continue!
4 жыл бұрын
Thank you. Doing now research for new videos :)
@kiausiniukova2842
@kiausiniukova2842 3 жыл бұрын
Love your videos. Helps me a lot with my uni, keep it up 👍
@night_gryphon
@night_gryphon 9 ай бұрын
How did you get audio from PC ?
@dineshdange5883
@dineshdange5883 3 жыл бұрын
Just Great !!!
@kitkat224
@kitkat224 2 жыл бұрын
At 33:20 mention the HAL transmit function handles waiting What I discovered is you need to read the DR register in order for it to flush data I don't understand why this is necessary and why it doesn't work without it
2 жыл бұрын
That's interesting. I have used only the transmit function at my last project for a dac ic with no read - master tx only. I have a feeling that I have heard of this before but I'm unable to recall.
@woldecosgrove
@woldecosgrove 9 ай бұрын
Great job! I like to watch your video, just a question how can I make the SPI send 2 bytes of data instead of one byte like 0x0480 and without sending the address too? and how can i receive it in 1 byte? I have just your code and it working on STMH7 SPI transmit 1 byte address and data... pls advise... thx.
@47lokeshkumar74
@47lokeshkumar74 3 жыл бұрын
HI bro, nIce video, I have using the wolfson audio card with stm32 f407vg,. Is there any code for checking my wolfson is working with stm32f407 board or not. Thanks
3 жыл бұрын
I'm not familiar with this card, so it might be a raspberry pi hat type of card? If so, then I can see that it has an expansion header that has a couple of gpio line connected as well as 5V and 3v3 along with i2s and i2c. With that you can check what signals would be of interest. I would suggest leaving i2c and i2s alone because they are master-slave type of interface where raspberry pi is alredy connected as master.
@mejoe444
@mejoe444 2 жыл бұрын
Hello! Thanks for the video. I have a question regarding 30:55. In your function spi_write, why do you pass the address of dataOut but not the dataOut itself. What would be bad if your function would be spi_write(regAddr, dataOut) instead of yours spi_write(regAddr, &dataOut)? I'm not expert in C and just was curious about the reason behind this.
2 жыл бұрын
By passing the pointer to the data instead of just data allows the function to modify data at that address and possible others as well by incrementing the address. Passing just the value of variable would not allow this.
@mejoe444
@mejoe444 2 жыл бұрын
@ But inside your spi_write function you dont modify the data. You pass pointer and dereference it again inside the function without modifying it. Am I missing something there? Thanks
@isaacclark9825
@isaacclark9825 2 жыл бұрын
@ Even if you don't plan to modify the structure, passing it requires making a copy of the entire structure, while passing the pointer only copies the address. It is more efficient in time and memory to pass the pointer.
2 жыл бұрын
That's also another reason. If you want to pass in the struct as a read only variable, you can use pointer to a const struct `struct MyStruct const* myStruct`. Might as well make the pointer const as well if you're not incrementing it: `struct MyStruct const* const myStruct`. This is "safer" so you don't modify something that shouldn't be, but it can give you problems with HAL functions, which don't use const at all - then you need to cast away const: `MyStruct* myStruct2 = (MyStruct*)myStruct`.
@isaacclark9825
@isaacclark9825 2 жыл бұрын
If you are anticipating that HAL is going to change the pointer, then you would not want to use const.
@babotvoj
@babotvoj 3 жыл бұрын
hello, have you ever connected raspberry pi with the stm32 over the SPI interface?
3 жыл бұрын
I have never used Pi for projects, just as a low power computer. If there is a library for pi that supports spi, than it should work. Just make sure that one is master and other is slave. For general communication between modules that you program yourself I like uart much more, modules can transmit and receive at any time, much more convenient.
@fatihe.1338
@fatihe.1338 3 жыл бұрын
Can you explain how you can send dummy data and get garbage data via "Hal Function " ?
3 жыл бұрын
You can use 'HAL_SPI_TransmitReceive' to send equal amount of data and receive. Just use empty array of appropriate size to send and another one to receive.
@fatihe.1338
@fatihe.1338 3 жыл бұрын
@ ​@
Using I2C for any device on STM32 with HAL | VIDEO 26
37:51
Matej Blagšič
Рет қаралды 76 М.
Understanding SPI
11:50
Rohde Schwarz
Рет қаралды 80 М.
黑天使遇到什么了?#short #angel #clown
00:34
Super Beauty team
Рет қаралды 39 МЛН
小丑和奶奶被吓到了#小丑#家庭#搞笑
00:15
家庭搞笑日记
Рет қаралды 8 МЛН
路飞太过分了,自己游泳。#海贼王#路飞
00:28
路飞与唐舞桐
Рет қаралды 43 МЛН
STM32 Guide #3: PWM + Timers
20:24
Mitch Davis
Рет қаралды 139 М.
I2C and SPI on a PCB Explained!
15:34
Altium Academy
Рет қаралды 144 М.
DAC in STM32 || Sine wave || HAL || CubeIDE
16:07
ControllersTech
Рет қаралды 65 М.
Interrupts on Cortex M - NVIC (demonstrated on STM32) | VIDEO 34
34:24
Matej Blagšič
Рет қаралды 16 М.
rust runs on EVERYTHING (no operating system, just Rust)
18:10
Low Level Learning
Рет қаралды 353 М.
The Greenwich Meridian is in the wrong place
25:07
Stand-up Maths
Рет қаралды 751 М.
SPI: The serial peripheral interface
33:00
Ben Eater
Рет қаралды 676 М.
How To Write An STM32 SPI Driver (Full-Duplex Master Mode)
27:32
Z-The-Programmer
Рет қаралды 31 М.
[stream] Writing a SPI SD-Card driver in TypeScript
2:16:20
Low Byte Productions
Рет қаралды 8 М.
stm32 timed multichannel ADC DMA conversions on STM32F030k6
12:06
黑天使遇到什么了?#short #angel #clown
00:34
Super Beauty team
Рет қаралды 39 МЛН