Understanding Support ICs for MCU  - Page 1
Forum section: electronics / beginners

author: wayfarer.technologies
author_rank: Contributor
timestamp: April 16, 2023, 05:33:31 pm
content: hello, I am working on a few microcontroller projects using the WDC 65c02s and the 65c816s.I am waiting on parts and just have a breadboard and some wires.I am trying to get used to the memory mapped I/O, device switching and things like that.Much of what I need to do uses things like serial registers and flip-flops and latches, basic CMOS logic stuff.I did some tinkering a few years ago with some audio circuits, 555s and potentiometers. I did PC repair work for several years.I can program a little, I took a lot of matrix maths in college, and I took Diff EQ but never Calculus 1, 2 or 3... I got in because of the linear maths.So what I am trying to do, is maybe get like an 8-pin dip switch, and a pushbutton (and maybe debounce it?) and an OR gate, so I can set the dip, and push a button and send that switch bank to a latch (I think thats it) and then it should stay there after I let go of the button, right?ok, I want that to light up 8 LEDs.basically, I want to later be able to send 8 bits from 8 data lines, to LEDs that stay lit. So I can read my status or accumulator registers (really it will be a memory location to this 'display') by copying it to this uh, 'latch register'?later I want to do a few other things like, have two of these and do some boolean logic on them. I am not trying to make a cpu from ICs, Im trying to expose a 6502 through LEDs or segment displays and use a few controls to operate that 6502 'directly'. Basically, I am trying to start with some of the simplest practical circuits I can to get that part working. So a 65816 needs a chip to demultiplex 8 of the address and data pins, and lots of things like a reset button need to be debounced. Serial shift register, latches, flip-flops, timing circuits, lots of that stuff I need to brush up on and get working too.so, I guess first question, its easy to make a button that lights up an LED, its a "Latch" to make it stay lit?I will try to draw up the circuit in KiCad I am talking about.

author: Benta
author_rank: Super Contributor
timestamp: April 16, 2023, 05:55:07 pm
content: If that's what you want to do, I'd say the 65C02 is the completely wrong part.A bit like using a school bus for a gokart race.

author: wayfarer.technologies
author_rank: Contributor
timestamp: April 16, 2023, 07:31:57 pm
content: Quote from: Benta on April 16, 2023, 05:55:07 pmI am working on the support hardware for a 6502, right now,Im looking at a battery, a switch, a button, an LED and a... what do I need to make the LED stay on, until I push the button with the switch off?

author: mariush
author_rank: Super Contributor
timestamp: April 16, 2023, 07:41:13 pm
content: Quote from: wayfarer.technologies on April 16, 2023, 07:31:57 pmAn 8-10 pin PIC12F or a ATTiny microcontrollerLike others says 65c02 is overkill for something like that.for 65c02 I'd suggest watching this series from Ben Eater :https://www.youtube.com/playlist?list=PLowKtXNTBypFbtuVMUVXNR0z1mu7dp7eH

author: wayfarer.technologies
author_rank: Contributor
timestamp: April 16, 2023, 07:46:13 pm
content: how do you latch a button to keep an LED on?

author: mariush
author_rank: Super Contributor
timestamp: April 16, 2023, 07:50:28 pm
content: You don't ... the microcontroller can have in its program a loop and constantly check if button is pressed or not , or you can use an interrupt on change to detect when button is pressed.when button is detected as pressed, the microcontroller can do stuff like turning on or off the led.May be preferable to read input multiple times to do software debouncing of the button.A microcontroller is powerful enough to drive a plain led from an IO pin, if not a simple "jellybean" transistor can be used, or a mosfet.

author: wayfarer.technologies
author_rank: Contributor
timestamp: April 16, 2023, 08:01:51 pm
content: ok you seemed to have missed a level of abstraction here, and I you are directing me to do something that is not helpful to what I am trying to do.I am interested in working on a button debouncing circuit, or using something like a MAX6816 or LS118 or doing it from discrete components,I will need to do this a whole bunch for my device, with multiple buttons pressed later...I do plan at some point to use a PIC or similar, and a 6502, these things are far from now. I am working on basic external support circuitry.debouncing switches, latching an LED so it doesnt blink 500K times per second... things like this.I am trying to use the very basics of a latch circuit to turn a momentary switch into an on switch that doesnt turn off until cleared.

author: mariush
author_rank: Super Contributor
timestamp: April 16, 2023, 08:31:34 pm
content: you can do a rudimentary hardware debouncing with a resistor and a capacitor.A very brief press / bounce would not charge up the capacitor with enough energy for the voltage to raise above the threshold (or discharge enough to be seen as a 0)or you could use an inverting schmitt trigger ic (see third video below)seehttps://www.digikey.ee/en/articles/how-to-implement-hardware-debounce-for-switches-and-relayswhich also shows using NAND as SR latch and LS18or seehttps://digilent.com/reference/learn/microprocessor/tutorials/debouncing-via-rc-filter/startwith schmitt triggershttps://mansfield-devine.com/speculatrix/2018/04/debouncing-fun-with-schmitt-triggers-and-capacitors/You can also watch the videos below

author: Benta
author_rank: Super Contributor
timestamp: April 16, 2023, 09:02:21 pm
content: Well, to go back to basics:If you insist on using a 6502, that's not a microcontroller. It's a microprocessor.A microprocessor is just the data processing unit and has no interfaces to the real world. It only has access to memory (parallel 8-bit RAM/ROM/EPROM/Flash etc.).If you want to connect to the outside world, you need to add an I/O chip somewhere in your memory. Historically, that was the 6522 VIA or the Motorola 6820/21 PIA, both behave as memory locations.Thenyou can start adding switches and LEDs etc. Not before.

author: MarkS
author_rank: Unknown
timestamp: April 16, 2023, 09:03:29 pm
content: A 6502 is NOT a MCU(microcontroller). It's a CPU. You can build a MCU from the 6502, but unless this is being done for educational purposes, it would be far better to get an actual MCU. You'll save yourself a massive headache!

author: wayfarer.technologies
author_rank: Contributor
timestamp: April 16, 2023, 10:20:00 pm
content: Hey thank you both for getting back with me, I think there might be some language or culture barrier (and even in my own country no one understands me)so let me clear up:Im not using a 6502 for several weeks, maybe a month or so, I have all these little experiments to do first!!my purpose, is to work in 65xx, a long term goal. I do not feel ready to do much with one, and as stated you need a few chips around it to do much, latches, shift registers and such depending on what you are doing. Before I put a 6502 in a board a let the magic smoke out, I want to get more familiar with those logic 'glue' and support chips. some circuitry basics I forgot or never learned when making a noisemaker.I made a little picture, I hope this helps where words do not.so I labeled things a bit:1* Switch 1, or 'the button', this is symbolic and represents a 'write' operation to a memory location taking place.2* Switch 2, or 'the switch', this is symbolic and represents the contents of a single bit in the accumulator.3* AND gate, this is also symbolic and represents the 'write signal and the clock pulse with the chip select and address controller and...'? this is the thing Im not sure on, I think its a Latch?the rest is a generic LED, resistor and V+here is what I want to do, at power on, I want the LED off.if I put the switch to contact, and then push the button, I want the LED to turn on and stay on.If I put the switch to open, and then push the button, I want the LED to turn off and stay off.so the LED is independent of the switch, it stores the state last "written" to it by pushing the buttononce this is working, there will be 8 of them in a row. once i have a 6502, in a few weeks, I will write the contents of a register to a memory location, this is that memory location. so I can visually see the register, or status register etc on a bank of LEDs, this is a ways away. Right now, I just want to get the above circuit working.I did read that digikey article, those are really great. After reading, I think I want to use an RC debounce circuit instead of an IC, I have several keys to press in the long run, a D-Pad, buttons, numeric keys and a keyboard later. it gets expensive to use ICs, a 9 bank debounce IC is $10 and on devices intended to be inexpensive, this wont work.thankfully debouncing is not too crucial right now and RC is easy enough to do, its getting the 'latch' working on the banks of LEDs to write to so I can see whats in memory without a screen.

author: Benta
author_rank: Super Contributor
timestamp: April 16, 2023, 10:32:36 pm
content: "Ich verstehe nur Bahnhof."

author: Kim Christensen
author_rank: Super Contributor
timestamp: April 16, 2023, 11:10:09 pm
content: QuoteYou can modify that DigiKey circuit to do what you want:

author: wayfarer.technologies
author_rank: Contributor
timestamp: April 17, 2023, 03:20:10 am
content: Quote from: Benta on April 16, 2023, 10:32:36 pmIch gelent deutsch in seibten klassemein deutsch is sehr... fehlerhaftQuote from: Kim Christensen on April 16, 2023, 11:10:09 pmok, I will give those a look, just getting the very basics going is enough for nowin that diagram, you have two buttons, to be clear, SW1 should be able to be pushed on or off and do nothing, SW2 however should "write" the state of SW1 to the LED whenever pushed.so SW1 = "register bit"and SW2 = "write operation of SW1 state to LED"the LED needs to stay in whichever one its put it.I'll give the videos a watch and read up in the morning.thanks again

author: Kim Christensen
author_rank: Super Contributor
timestamp: April 17, 2023, 03:59:01 am
content: QuoteIf you wanted to do that with a 6502, you'd use a tristate buffer, like a 74LS244, connected to the data-bus. Then you'd use an address decoder to enable the outputs of the 74LS244 when the 6502 addresses and reads from that specific address. Then the buffer would put that 8bit data (8 switches connected to the 74LS244) on the bus for the 6502 to use. No need to latch anything because the 6502/program will read the data, store it, and deal with it.For lighting LEDs, you could have an octal latch, like a 74LS373 connected to the data-bus, via a decoder that the 6502 could write data to and light up to 8 LEDs in any combo. (Perhaps this is circuit you wanted to see)The 6502 could do all the switch sensing ,debouncing, etc in software, and decide exactly which LED got lit by which switch, for how long, LED state on power up, etc... No need to design hardware to do this.EDIT:More details on using TTL chips as general purpose IO

author: barshatriplee
author_rank: Regular Contributor
timestamp: April 17, 2023, 10:25:00 am
content: I think you can do this project easily with an Arduino or any AVR microcontroller easily. You have to make a latch switch. If you make a momentary switch. The LED will be ON as long as you press the switch. If you make a latch switch, the LED will stay ON even after you move your finger after pressing the switch. To turn the LED OFF, you'll have to press the switch once again. You have to add delays inside your code to avoid the debouncing problem.

author: tggzzz
author_rank: Super Contributor
timestamp: April 17, 2023, 12:17:29 pm
content: Quote from: wayfarer.technologies on April 16, 2023, 08:01:51 pmChange your level of abstraction...Keep the hardware simple: use a switch plus pullup resistor connected to an input, then implement the debouncing in software.

author: MarkS
author_rank: Unknown
timestamp: April 17, 2023, 06:09:25 pm
content: Quote from: wayfarer.technologies on April 16, 2023, 08:01:51 pmYou've explained WHAT you want to do, but you have NOT explained WHY you're taking a difficult route for a simple project. I get the very vague hint that this is about bus indication on a 6502-based project. And that's fine. However, if you are trying to blink an LED by using a 6502, you are trying to kill an ant with a sledgehammer.Please explain to us what your FINAL end goal is.

author: abeyer
author_rank: Frequent Contributor
timestamp: April 17, 2023, 07:34:49 pm
content: Quote from: wayfarer.technologies on April 16, 2023, 10:20:00 pmhttps://xyproblem.info/

author: MarkS
author_rank: Unknown
timestamp: April 17, 2023, 09:31:11 pm
content: Quote from: abeyer on April 17, 2023, 07:34:49 pmTHAT describes this thread perfectly!

author: wayfarer.technologies
author_rank: Contributor
timestamp: April 18, 2023, 04:06:31 am
content: Quote from: MarkS on April 17, 2023, 09:31:11 pmQuote from: abeyer on April 17, 2023, 07:34:49 pmSo I am aware of this phenomena and perhaps it is a case of compensating for the compensation, or just zigging instead of zaggingWhat is it?The XY problem is asking about your attempted solution rather than your actual problem. This leads to enormous amounts of wasted time and energy, both on the part of people asking for help, and on the part of those providing help.User wants to do X.Im working on some projects with 6502s and 65816s in the future.User doesn't know how to do X, but thinks they can fumble their way to a solution if they can just manage to do Y.this is true of anything when one starts, I am neck deep in literature and waiting on parts. I am attempting to building a small piece of a bigger circuit now.User doesn't know how to do Y either.no, Ive never made a latch before, a few things in circuitry, not that. even if its not quite what I need, its still good to know aboutUser asks for help with Y.yes, though I think by including my context people were mistaken about the task at handOthers try to help user with Y, but are confused because Y seems like a strange problem to want to solve.yes they keep helping with the larger context problem and I appreciate that, its just focused in the wring scopeAfter much interaction and wasted time, it finally becomes clear that the user really wants help with X, and that Y wasn't even a suitable solution for X.no, no wasted time really, just sorting out the details, several people have been very helpfulThe problem occurs when people get stuck on what they believe is the solution and are unable step back and explain the issue in full.yes Ive been doing that.What to do about it?Always include information about a broader picture along with any attempted solution.see I tried to do this and it caused the problemIf someone asks for more information, do provide details.yes thats been the caseIf there are other solutions you've already ruled out, share why you've ruled them out. This gives more information about your requirementsusing a software microcontroller at this point means getting, studying, programming and implementing a mcu, and Im doing that at another stage with specific hardware. a simple hardware solution is best for right now, given this is very basic work. button debounce and switch latching are two separate problems related to each other.I really do appreciate the help, some very valuable resources so far

author: David Hess
author_rank: Super Contributor
timestamp: April 18, 2023, 06:00:58 am
content: The basic element to add an I/O port is an 8-bit latch or flip-flop with tri-state output capability, like the 74374/74574 octal flip-flops or 74373/74573 octal latches. There is also a TTL part which does both input and output but I do not remember the part number - some kind of register? Whatever it was, it will be expensive.These can be connected directly to the data bus and then decoding logic can drive the control signals resulting in an 8-bit input or output port.

author: retiredfeline
author_rank: Frequent Contributor
timestamp: April 18, 2023, 01:19:57 pm
content: MPU + support ICs were the way to go before integration migrated those functions onto the chip, thus creating a MCU.If you want make a functional thingy, then the get there fast with a modern MCU.If you want to learn how in the past all the parts were combined so that a MPU could deal with the outside world, then by all means continue your learning experiments.Here's somebody to did that to a 6502 + support ICs to make a familiar hardware experiment platform:https://hackaday.io/project/190260-65uinoA lot of people do this kind of project out of nostalgia or just for kicks.

author: David Hess
author_rank: Super Contributor
timestamp: April 18, 2023, 04:04:07 pm
content: Also I suspect inexpensive simple programmable logic could be used to aggregate the decoding logic with an I/O register, so one side connects to the microprocessor bus and the other wide provides input and output bits.Some microprocessors and microcontrollers had support I/O chips available which did almost everything except some of the decoding. The 68HC11 series had the 68HC24 (port expander?). Intel processors had the ubiquitous8255which is better known as providing the parallel printer port capability of early IBM PC type personal computers. The 8255 and similar chips can be adapted to other microprocessors without too much difficulty:https://www.renesas.com/us/en/products/space-harsh-environment/mil-std-883-products/mil-std-883-microprocessors-and-peripherals/82c55a-cmos-programmable-peripheral-interface

author: james_s
author_rank: Super Contributor
timestamp: April 18, 2023, 05:15:59 pm
content: Quote from: David Hess on April 18, 2023, 04:04:07 pmThat was done on at least a few PCs back in the 90s. IIRC the Mac SE was one of those, it was more or less a refined version of the earlier 68000 compact Macs with the address decoding circuitry replaced by some PALs. A modern-ish 5V CPLD would work well for this.

author: chickenHeadKnob
author_rank: Super Contributor
timestamp: April 18, 2023, 07:02:30 pm
content: Okay I would like to side-step the Y problem and offer a glimpse at one possible solution to the X problem. Have a look at the web page on the Commodore KIM-1.:https://www.commodore.ca/commodore-products/productscsg-mos-commodore-kim-1-history-pictures/It is well documented and has all the manuals and schematic. This was a well loved little starter computer of the 70's. I am not saying you need to slavishly copy the KIM-1, I am simply suggesting you could study the design and then come back here with questions on specific aspects you don't understand. While 7 segment displays look more complicated than a single led and are more involved software wise if you want to display coherent numbers in reality they are just a bunch of single leds with a common anode or common cathode connection. So lighting up one segment as an indicator is just the same as a single led.

author: David Hess
author_rank: Super Contributor
timestamp: April 19, 2023, 01:26:30 am
content: Quote from: james_s on April 18, 2023, 05:15:59 pmAt some point after the IBM PC AT came out, discrete decoding logic started to be replaced with PALs, but I was referring to making the whole I/O port including the decoding logic in a CPLD or similar for a single chip solution.

author: james_s
author_rank: Super Contributor
timestamp: April 19, 2023, 02:14:32 am
content: Well you certainly could, I've made entire computers in FPGAs, including custom decoding and IO.

author: wayfarer.technologies
author_rank: Contributor
timestamp: April 19, 2023, 01:06:58 pm
content: Quote from: retiredfeline on April 18, 2023, 01:19:57 pmso the 65816 needs demultiplexing, there are things you can do with the clock and I think a flip-flop for a "really clean edge" and some places adding a few passives can help fix a bug, I mean featuregenerally this is education, though I am planning to use the 65xx series for some projects. I have concerns with several mcu offerings out there, largely due to a constrained memory access to what is 'on-chip'. I do plan to use a modern mcu for some sort of "board controller" or "RIOT chip" (RAM/ROM, I/O and Timer). I intend to pick 1-2 architectures and stick to them, and the 65xx is as good a choice as any. For mcu, I am looking at the msp430 (which I hear is on its way out) and the PIC series, which I hear is moving to MIPS, so I might use that instead.in the near future I am most likely to just order a set of 74000 and 4000 ICs and blink LEDs while following along with youtube videos and some exercises. even watching those is helping a lot with understanding what is going on before I start getting into things like building a calculator, "gameboy" or pick up on Lee Davison's work and build a 6502 based plotter.I am trying to pick back up on the basics before I go forward.Quote from: David Hess on April 18, 2023, 04:04:07 pmQuote from: james_s on April 18, 2023, 05:15:59 pmI may get into CPLDs or PAL/PLA later. not quite ready to jump into those yet.Quote from: chickenHeadKnob on April 18, 2023, 07:02:30 pmmy long term project may involve building something like a KIM-1, though I am certainly focusing on my own design rather than that one specifically. right now, I am working on a few building blocks before I move further.