Using DMA to implement multiple SPI ports

  Рет қаралды 31,408

mikeselectricstuff

mikeselectricstuff

Күн бұрын

Пікірлер: 86
@cliveramsbotty6077
@cliveramsbotty6077 8 жыл бұрын
You have this incredible talent for speaking really clearly, providing all the information with no chatter or wasted words, explaining it all in a concise manner. Attributes pretty much unheard of on KZbin. I doff my cap sir.
@magdalenajirova5745
@magdalenajirova5745 8 жыл бұрын
As a non-native-English-speaker, I must agree that Mike's fast speech and somewhat lispy pronounciation makes it difficult to comprehend.
@jam99
@jam99 7 жыл бұрын
Mike is a very intelligent guy. He speaks too fast for me to follow a lot of the time but that is my problem, not his. I just have to frequently replay certain bits.
@tomlomax9909
@tomlomax9909 7 жыл бұрын
Evidently the haters don't speak English. Feel free to watch at 0.5x speed.
@Tadesan
@Tadesan 2 жыл бұрын
You are so amazingly fortunate to have found a niche. I would give my talent to learn how to find a niche and grow in it…
@AlexHitchins
@AlexHitchins 8 жыл бұрын
Mike, you are a very clever chap. I always learn loads from your videos, when it sinks in!
@flipschwipp6572
@flipschwipp6572 8 жыл бұрын
nice explanation and very clever to also stop the clock via dma!
@pnjunction5689
@pnjunction5689 8 жыл бұрын
Pure gold! That's a very nice idea to use DMA to stop the timer. Thanks for the video.
@haakonness
@haakonness 7 жыл бұрын
I really liked your idea of using a second dma to write to the t3con register. I thought of the external gate too while you were explaining the problem. But I would have stopped there. Nice thinking!
@richsmith46
@richsmith46 8 жыл бұрын
Nice idea and I'm going to try out something similar, now I know it stands a good chance of working without needing 6 × SPI channels and a 144 pin micro. Many thanks.
@AlexanderBrevig
@AlexanderBrevig 8 жыл бұрын
very very nice, cool trick using a DMA to transfer the 0 constant
@robbyxp1
@robbyxp1 7 жыл бұрын
Great video. I love playing down with the bits and DMA. Reminds me of setting up a Texas C64 with multiple chained DMAs to split apart incoming I*Q data steams from a complex QUAD down converter chip.
@andrewpowell3723
@andrewpowell3723 8 жыл бұрын
Very interesting stuff. Glad I discovered your channel.
@A_S_M_R
@A_S_M_R 8 жыл бұрын
I love you teardown videos Mike but this has melted my brain! Nevertheless, keep up the great work.
@SatyajitRoy2048
@SatyajitRoy2048 5 жыл бұрын
You are a genius. Will have to try if I can do the same thing on low end STM32. STM32F030 is very cheap in price.
@willplu6483
@willplu6483 8 жыл бұрын
I'm starting to understand your videos more and more so I guess college is worth it.
@edlakota
@edlakota 8 жыл бұрын
@Mike - Nice work.. If you enjoy exploiting the peripheral set to emulate other functions, you would love playing with the xmos chips. You essentially write your own peripherals using a bunch of resources such as timed ports (with shift registers), user clocks under software control and all without worrying about interrupt latency because you dedicate a core to doing just that task (so it's always read to react without context switch). No need for significant buffering. Great for doing high channel count bridging (ethernet/serial to serial/pwm etc.)..
@mikeselectricstuff
@mikeselectricstuff 8 жыл бұрын
Not looked in too much detail at XMOS - too much new stuff to learn for occasional use. The 72 channel board is actually to replace an XMOS board that a customer uses, which went obsolete.
@edlakota
@edlakota 8 жыл бұрын
Interesting! Keep up the good work - really enjoy the videos. One day I'll own a scope that good...
@HennerZeller
@HennerZeller 8 жыл бұрын
I do a similar thing with the Spixels project (that we were using in FlaschenTaschen) on the Raspberry Pi (well, writing out per DMA that is, but not using the DMA controller to trigger on an interrupt).
@djmips
@djmips 8 жыл бұрын
well done sir. Much respect.
@jjoster
@jjoster 8 жыл бұрын
cool. I do love these types of videos
@DMStern
@DMStern 8 жыл бұрын
If you have the RAM, you could instead embed the clock signal with the data, writing the same data twice to the I/O port, but toggling the clock pin. It costs twice the RAM, and the max transfer speed is halved, but you don't need the additional timers and there's no overruns.
@Kilohercas
@Kilohercas 8 жыл бұрын
question: in ARM, you can set and clear each pin bits with single word, but it will only effect pins that are 1 in that register, so in theory, you can use 16b, toggle odd ones, and use as inputs or outputs even ones with no head smashing. Maybe where are same things in PIC?
@rationalactor
@rationalactor 8 жыл бұрын
Great video, Mike. Thanks! Also nice idea to use DMA to stop the clock. Was wondering if it would be possible - albeit a bit brain-frying - to shuffle the input data using DMA gather 'n' scatter. Dunno if this part has it... Cheers
@EcProjects
@EcProjects 8 жыл бұрын
Great stuff! Thanks :)
@drojf
@drojf 8 жыл бұрын
some Freescale (now nxp) arm microcontrollers have a "flexio" peripheral which can be configured for many different types of serial output. unfortunately only the high end parts (I think) have enough channels (more than 4) for this kind of task. but you may be able to combine them with the existing spi peripheral to get enough spis (4 flexio outputs + 2 spi...maybe).
@keesnuyt8365
@keesnuyt8365 8 жыл бұрын
Brilliant !
@ejphendriks
@ejphendriks 7 жыл бұрын
Did you try to use the PMP? Seems like the first obvious choice. You mention the clock pulse of the PMP would be very short. Too short? I want to try this with those 32by16 display panels. Thnx for sharing your quite brilliant and out of the box insights ;)
@matthewprestine1974
@matthewprestine1974 8 жыл бұрын
dont recall you mentioning but if you can setup the dma in a circular mode you should use that.
@Fake0Name
@Fake0Name 8 жыл бұрын
Can you not enter the interrupts faster by managing what you touch, and using a naked interrupt call? That makes the compiler not automatically save the stack context (so you have to be careful to not clobber the stack, or fix what you clobbered), but it can considerably speed up an interrupt.
@mikeselectricstuff
@mikeselectricstuff 8 жыл бұрын
Quite possibly, but this way will always be faster. Also I'd have to learn more about the MIPS architecture and assembler than I can be bothered to,
@proluxelectronics7419
@proluxelectronics7419 8 жыл бұрын
You beat me to it, I was going to ask if bit banging in assembler was a option.
@DMStern
@DMStern 8 жыл бұрын
The point is you need to save the CPU registers. If you want to avoid that, you could allocate a number of them for ISR use, and make sure you never touch them outside of the interrupt, but that would mean writing everything in assembler yourself.
@Fake0Name
@Fake0Name 8 жыл бұрын
I'm pretty sure you can tell most C compilers to not touch specific registers, so it shouldn't have to *all* be in assembly.
@DMStern
@DMStern 8 жыл бұрын
Even if you can, it means you have to be able to compile all code involved in the project from source (so no prebuilt part-support libraries etc.)
@b3l14l
@b3l14l 8 жыл бұрын
I see the NSL stamp what day where you there ?
@hpux735
@hpux735 8 жыл бұрын
It may not be a bad idea to disable the serial rx interrupt once you get your packet (based on address) and re-enable once the DMA memory is loaded.
@mikeselectricstuff
@mikeselectricstuff 8 жыл бұрын
That won't work as you need to maintain framing of the packets - if you suddenly re-enable after doing whatever you're doing, you could be in the middle of a packet destined for another node, and not know when your one starts. (There is a way to avoid that issue, by using 0xff as a start-of-packet marker that;s never used within packets, but it's then hard to implement variable-length packets, and you need to not use 0xff within data. )
@hpux735
@hpux735 8 жыл бұрын
Ah, good point. Coming up with out-of-band markers is a PITA.
@CrazyMonkeyCM32
@CrazyMonkeyCM32 8 жыл бұрын
I don't know if you have the memory, but why not double buffer? You can do your bit twiddling, then swap array pointers to output it with DMA. Then you can do both parts simultaneously. There could be memory bandwidth contention, but I would hope the DMA would have priority.
@mikeselectricstuff
@mikeselectricstuff 8 жыл бұрын
That would improve total throughput, but that isn't really a problem hare as there are multiple devices on the bus, so there is plenty of time to send.
@djmips
@djmips 8 жыл бұрын
The running start idea is neat and would see this all over the place in video game console programming, Like on PS2 you could start DMA to start consuming a buffer before you have finished filling that buffer. Or the C64 scrolling routines that were still moving memory at the bottom of the screen while the raster was drawing the top and the raster caught up just as you were finished. But as you say, it's working fine without these optimizations.
@mikeselectricstuff
@mikeselectricstuff 8 жыл бұрын
The problem with starting the DMA while filling the buffer is you have to account for the load that an incoming serial packet may create. I did look at it but by the time you assume the fill will be slowed by the serial handler the benefit was negligible. Double-buffering would give more overall throughput if needed, but would add latency.
@mikeselectricstuff
@mikeselectricstuff 8 жыл бұрын
Of course you could have the fill process periodically check where the DMA had got to before proceeding, but that would only potentially improve avarage time, not peak which is what matters.
@BersekViking
@BersekViking 8 жыл бұрын
Thanks for sharing
@frankbuss
@frankbuss 8 жыл бұрын
Neat, but all I was thinking the whole video was how much easier this would be with a few lines of VHDL in a FPGA.
@mikeselectricstuff
@mikeselectricstuff 8 жыл бұрын
Yes you could, but you'd end up with a bigger package, more expensive part, and doing stuff like firmware upload over the bus get somewhat more complex.
@lsdave
@lsdave 8 жыл бұрын
How long did it take you to come up with this implementation? I can only imagine how long it would have taken me to develop something like this and your design is VERY clever. I love watching your videos Mike.
@mikeselectricstuff
@mikeselectricstuff 8 жыл бұрын
Took a few attempts in different directions after I realised I couldn't use interrupts - couple of days maybe.
@AureliusR
@AureliusR 6 жыл бұрын
I just realized something -- why isn't the foreground task (green trace - pin switching on and off) active after the bit-fiddling is done? Shouldn't the foreground task be active during the DMA transfers as they are asynchronous?
@DonkeyLearningIT
@DonkeyLearningIT 8 жыл бұрын
At 15:01 is that a Not So Loud disco stamp on your hand? Nowadays the young generation no longer knows the good old Disco...
@godfreypoon5148
@godfreypoon5148 8 жыл бұрын
SPI (and similar) without DMA sucks in any case. You can either busy-wait between each Tx/Rx buffer load, or you can use an interrupt driven approach (or explicitly task switch) but by the time you have the task switching overhead out of the way you will be due for another buffer load. (Depending on your timing particulars, of course, but I mind this is virtually always the case.) ... not that this is necessarily relevant to your video, which I am only part way through watching ...
@JennyEverywhere
@JennyEverywhere 8 жыл бұрын
Got a link to the source for the strips? They look interesting.
@mikeselectricstuff
@mikeselectricstuff 8 жыл бұрын
custom made for this installation.
@JennyEverywhere
@JennyEverywhere 8 жыл бұрын
Aw.
@adilmalik7066
@adilmalik7066 8 жыл бұрын
i like that you use pics! what is your opinion on the STM32s?
@mikeselectricstuff
@mikeselectricstuff 8 жыл бұрын
Never used them. Used to use NXP ARMs but started hitting code size limit of IAR free version and full version was crazy expensive. One reason for using PICs as lots of RAM in small pin-count packages, also flexible pin mapping on PIC24F. For bigger jobs, ability to buy from MicrochipDirect ready-programmed is a big time saver. Architecture doesn't really matter much.
@adilmalik7066
@adilmalik7066 8 жыл бұрын
PIC have become my goto MCU for projects too! Specifically the DSPIC33e's; i quite like the PPS capability too. Do you know any good dev boards for the PIC32s? Ive noticed Microchip have no sane devboards for sale for any chip! Had to roll my own for the DSPICs...
@Fake0Name
@Fake0Name 8 жыл бұрын
Can you not target the ARM with GCC?
@mikeselectricstuff
@mikeselectricstuff 8 жыл бұрын
Yes but from what I hear it requires some fiddling about to get debugger etc. working. Nice thing about IAR and MPLAB it's well integrated, and just works, most of the time at least. I regularly also use PIC10,12,16 and 24 , so having the same IDE, programmer and very similar peripherals is a big advantage.
@Fake0Name
@Fake0Name 8 жыл бұрын
Point taken. If you do want a zero-fiddling ARM env, atmel studio is quite nice. It's based on visual studio, which is either nice or horrible depending on your opinions on visual studio. I like it, but then I like nice GUIs. Hopefully now that Microchip bought atmel, the atmel toolchain people will go and kick the microchip toolchain people in the ass a bit, and things will get better.
@DonkeyLearningIT
@DonkeyLearningIT 8 жыл бұрын
Do you have some more upcoming teardown vids? Btw, why did you turn off the ads from your channel? It could at least re-scoop you some money which you could invest to buy cool stuff for teardowns.
@mikeselectricstuff
@mikeselectricstuff 8 жыл бұрын
Yes - some really interesting stuff coming up but needs a lot of time to do justice & rather busy atm. I enable minimal ads on new vids & turn more on for older ones, so subscribers don't see too many.
@DonkeyLearningIT
@DonkeyLearningIT 8 жыл бұрын
You should turn on the adds on all vids. Those people who want to see them, they will wait 5 seconds anyway. It is nerving that informative channels barely make money, and channels which present useless nonsense are having millions of subscribers and they SHAMELESSLY ask for more money and support...
@diffmull
@diffmull 8 жыл бұрын
Note, for an advert to count towards monetization, the viewer must let it play for at least 30 seconds, or, obviously, entirely if shorter than 30 seconds.
@NivagSwerdna
@NivagSwerdna 8 жыл бұрын
Is this with the internal PIC32 oscillator?
@mitropoulosilias
@mitropoulosilias 8 жыл бұрын
i have no idea what you do and why in that video... Maybe because i have no idea on PIC controllers
@afroninjadeluxe
@afroninjadeluxe 8 жыл бұрын
Wont the DMA overwrite the 7 other bits?
@djmips
@djmips 8 жыл бұрын
Yes, but if you make sure that the other 7 bits are the ones you want, then your settings won't be changed.
@優さん-n7m
@優さん-n7m 7 жыл бұрын
Use FPGA and you can have any number of any type of ports :)
@Sixta16
@Sixta16 8 жыл бұрын
Bloody PIC32s... blyat! What type of PIC have you used there? (Want to compare and find a match in the ARM family). Thanks
@mikeselectricstuff
@mikeselectricstuff 8 жыл бұрын
pic32mx150f128b
@AlexTaradov
@AlexTaradov 8 жыл бұрын
Now all of this works for TX only, of course.
@mdesm2005
@mdesm2005 8 жыл бұрын
what language is he speaking?
@shomonercy
@shomonercy 8 жыл бұрын
2x sped up future speak
@cmuller1441
@cmuller1441 8 жыл бұрын
It's a 40 minutes English video with half the syllables skipped to make a shorter video 😆
@mdesm2005
@mdesm2005 8 жыл бұрын
ahh, that could be it
@horle
@horle 8 жыл бұрын
I think Mike's a girl. How else could anyone speak that quickly while barely breathing.
@hoodaly
@hoodaly 8 жыл бұрын
Listening to your videos makes me become aggressive. You talk/murmur nonstop and I instantly lose focus, 5 seconds later BOOM I have forgotten everything you have said. I trust you that it's interesting stuff you talk about, but still watching feels pointless for me. Pls slow down a little and talk more clearly. Thanks :)
Shoving a LOT of data out of multiple USB-serial ports
12:55
mikeselectricstuff
Рет қаралды 31 М.
SPI: The serial peripheral interface
33:00
Ben Eater
Рет қаралды 695 М.
Human vs Jet Engine
00:19
MrBeast
Рет қаралды 208 МЛН
What type of pedestrian are you?😄 #tiktok #elsarca
00:28
Elsa Arca
Рет қаралды 20 МЛН
Человек паук уже не тот
00:32
Miracle
Рет қаралды 4,2 МЛН
Finnigan LCQ Mass spectrometer Part 1
58:53
mikeselectricstuff
Рет қаралды 40 М.
Huge lighting installation at London Heathrow Airport, 2014
47:58
mikeselectricstuff
Рет қаралды 57 М.
Interfacing a cheap phone camera module to a PIC32 microcontroller.
26:08
mikeselectricstuff
Рет қаралды 172 М.
The RS-232 protocol
26:10
Ben Eater
Рет қаралды 855 М.
Hacking a weird TV censoring device
20:59
Ben Eater
Рет қаралды 3,2 МЛН
How to use DMA on 8 bit PIC® MCUs
11:09
Microchip Technology, Inc.
Рет қаралды 10 М.
Driving LED matrix displays with an FPGA
47:50
mikeselectricstuff
Рет қаралды 81 М.
KiCad 7 STM32 Bluetooth Hardware Design (2/2 PCB) - Phil's Lab #128
2:56:53
How To Write An STM32 SPI Driver (Full-Duplex Master Mode)
27:32
Z-The-Programmer
Рет қаралды 35 М.
Hackaday Supercon 2017 Badge.
38:22
mikeselectricstuff
Рет қаралды 35 М.
Human vs Jet Engine
00:19
MrBeast
Рет қаралды 208 МЛН