Join us on Discord: discord.gg/jmf6M3z7XS Follow me on Twitter: twitter.com/WeirdBoyJim Support the channel on Patreon: www.patreon.com/JamesSharman
@dusterthefirst9 ай бұрын
I’m fairly certain that you must have already thought of this, but for loop unrolling it may be useful to have a macro/preprocessor step that is able to generate the unrolled loop.
@weirdboyjim9 ай бұрын
I have been thinking about adding some features to the assembler for that. I have a few other places where that would make things more maintainable.
@СергейСмирнов-ф9к5л8 ай бұрын
That is why people created compilers ))) I would actually like to see C or Basic or something else running on this
@Zer0ji8 ай бұрын
That's what I thought as well. Fancy macros allow using `i` inside the unrolled code, but a basic `repeat(8)` block would do wonders here
@drivers998 ай бұрын
@@СергейСмирнов-ф9к5лForth is super space efficient and easy to implement while being powerful and fast
@randomfish428 ай бұрын
This could be done without need to implement it in the assembler, just use a C compiler and tell it to to pre-process only (-E for gcc IIRC). If you're using Makefiles this should be an easy step to add.
@khatharrmalkavian33068 ай бұрын
I don't know why, but fiddling with SPI is one of my favorite things in electronics. Looking forward to the next video!
@weirdboyjim8 ай бұрын
It's been rewarding! Hope the next video(s) don't disappoint!
@khatharrmalkavian33068 ай бұрын
@@weirdboyjim You're always great, brother.
@lewa_j8 ай бұрын
Consider enabling line numbers display in your IDE. It may help viewers to keep up, especially with a lot of fast scrolling.
@weirdboyjim8 ай бұрын
Hmm, I'll look into that. The next video in this series is already recorded though.
@johanfr6 ай бұрын
Cool side project idea: Add a scripting language to your assembler. See Kick Assembler for 6510/65C02 processors for inspiration. I find it extremely useful to be able to use for-loops for loop unrolling, but also to generate sine tables, convert image data etc. in assembly time. Edit: I noticed someone else already had commented about this.
@weirdboyjim6 ай бұрын
Yeah, it's a solid idea. I have a long list of things I'd like to add to the tools but a sadly finite amount of time.
@TheEmbeddedHobbyist8 ай бұрын
I was going to comment on you changing some defines to a 0, which removes the readability of the code by adding magic numbers. And then just as i was going to type this comment you went back and replaced the zero's with some defined constants. well done. 🙂
@weirdboyjim7 ай бұрын
Glad I didn't disappoint (this time).
@TheEmbeddedHobbyist7 ай бұрын
@@weirdboyjim Never known you disappoint, provide talking points yes but disappoint no. 🙂
@teknifix8 ай бұрын
The 595 is an interesting solution. I chose the 74ALS299. It can input and output through either parallel or serial in both directions. I'm using it with a 6522, with one port being the 8 data lines and the other controlling SCLK and CS. It also supports shifting in both directions, if necessary. The only issue is switching between SPI modes. I'm sure I can solve it but I haven't had time recently to work on it. I also use it to interface to an arduino with a small screen for debugging. 3 chips lets me read both of the address bus bytes and the data bus byte quite easily.
@weirdboyjim8 ай бұрын
You'll be interested in how I do some of that in the next video. Being able to shift in both directions is not something you need for this though although a shift register with that can do both parallel in and parallel out would save a chip.
@khatharrmalkavian33068 ай бұрын
Whoa, that's a nice register. Adding some of those to my shopping list!
@Elixz898 ай бұрын
James you should look into the 74ls95. Its a parallel in/out serial in/out shift register. If you connect 2 of these together you basically got SPI done except for the clock generation. I saw that LCSC has these in DIP package. Might want to have a look into these
@weirdboyjim8 ай бұрын
That's a nice part but it doesn't have tri-state outputs so you would need another chip to interface it to the main bus.
@Elixz898 ай бұрын
@@weirdboyjim You could add a latch and a 245
@alexloktionoff68338 ай бұрын
I'm afraid 7495 is discontinued, there is no CMOS version. I remember in previous century it was a Swiss army knife like a 7400.
@chrisdickens48628 ай бұрын
Great video as always!
@weirdboyjim8 ай бұрын
Glad you enjoyed!
@Schwuuuuup8 ай бұрын
Great video! I am very interested in constructing an hardware SPI module for my own project. Unfortunately I have to admit that the way the functionality was presented here (as a conversion from bitbanging) I was left a bit confused. My mind is not really built for cross-referencing two videos. But I totally understand that this is not a how-to-guide. Nevertheless I look forward for an future video where the circuit schematic is built for sending it to an PCB manufacturer. Maybe you can go over it once again, how the new circuit ties in with the rest of the system.
@weirdboyjim8 ай бұрын
Sorry to hear you found it harder to follow. I try to show building things up step by step rather than showing a finished circuit and explaining it. I guess different people prefer different ways to work and learn.
@Schwuuuuup8 ай бұрын
@@weirdboyjim no problem at all! that was in no way a complaint. Quite the opposite, normally I love to follow the real world progress of the project. Only now when I try to pick one single aspect of it out of context it is a bit harder.
@lawrencemanning8 ай бұрын
FWIW not all SPI devices will tristate their MISO pins when not selected.
@weirdboyjim8 ай бұрын
All the devices I've looked at so far seem to, but I know that SPI is not a defined standard so there are many variations that all claim to be SPI.
@thisnthat35308 ай бұрын
If you buy them on those little modules, that issue is usually fixed by the incorporation of a 74HC125
@Zer0ji8 ай бұрын
Very interesting :) I was wondering why you didn't write `out GPIO, b` but obviously if there's no instruction for it that won't work. Would it be possible to use a counter chip that's somehow clocked 8 times per CPU clock to do one byte's worth of SPI clock in a single CPU cycle?
@ffsireallydontcare8 ай бұрын
I was thinking something similar, but you wouldn't want to multiply the CPU clock. Instead you'd have a second oscillator or use the master clock for an 8 cycle counter which is then triggered using a single instruction from the CPU. So Read_SPI triggers the SPI circuit to read 8 bits independently of the CPU into the 8 bit SPI latch, and you'd have a similar circuit for writing. The timing of the independent circuit will be determined by the clock speed capability of the SPI spec. If the system clock falls within the spec then everything's great, otherwise you'll need a second clock source.
@ffsireallydontcare8 ай бұрын
Sorry I should clarify, not a single CPU instruction - that would involve adding to the instruction set. I mean an instruction from the CPU to the SPI circuit. There may be a number of CPU instructions and interactions across the bus to achieve it, but you're saving the time the CPU currently generates the bit shifting clock.
@weirdboyjim8 ай бұрын
I actually discuss that very thing in the next video. Running the clock at system*8 = 32mhz would be really cool, but not all SPI devices can run that fast which would introduce a another level of complexity to the circuit.
@ffsireallydontcare8 ай бұрын
@@weirdboyjim This is what you get for delaying your releases! ;-P
@jensschroder82148 ай бұрын
When the read command comes, the clock could count 8 pulses independently.
@weirdboyjim8 ай бұрын
The next video in this series deals with clock generation. I had hoped to put all 4 bits in one video but it would have been very long.
@protonjinx8 ай бұрын
I guess it would have been handy to make each unrolled bit codeblock into a macro, so you only need to edit one
@weirdboyjim8 ай бұрын
I'd like to add some extra macro support but it's not always easy to balance time spent on tools verses building etc..
@BrainSlugs838 ай бұрын
Unrolling loops doesn't have to be unmaintainable! I know you wrote this assembler yourself, but look at what ca65 does for "macro assembly". There are things like a repeat directive. And even user definable macros which can feel a lot like calling functions, but without any jumps, because you're just inserting code into your ROM imagine and all the repeating and/or parameter swapping is done at assembly time. You should consider improving your custom assembler with similar macro-based functionality.
@weirdboyjim8 ай бұрын
I have a hope to add a number of new features to the assembler but balancing the time spent on various parts of the build is not easy.
@bzuidgeest8 ай бұрын
I'm confused, why keep controlling the clock from code directly? Hardware spi in my mind means giving a byte to the hardware and be safe in the knowledge it will be transmitted. What clock you have will just be a "setting" in the hardware, a register. Same for reading. You only do that when the hardware signals it has a complete byte to read. Maybe i missed something in the video, but at the moment what you are going for, looks more like hardware assisted spi then actual hardware spi
@weirdboyjim8 ай бұрын
The thing you missed is that I've broken the build into 4 steps and only covered the first two here. The second video will deal with the clock.
@bzuidgeest8 ай бұрын
@@weirdboyjim ah yes, I got the impression from your explanation that even in the other parts the clock would stay directly software controlled. Though assisted by that control line and such for inversion. I'll just wait for the next videos then.