Author Topic: Understanding Support ICs for MCU  (Read 2565 times)

0 Members and 1 Guest are viewing this topic.

Offline wayfarer.technologiesTopic starter

  • Contributor
  • Posts: 15
  • Country: us
Understanding Support ICs for MCU
« on: April 16, 2023, 05:33:31 pm »
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.

 

Offline Benta

  • Super Contributor
  • ***
  • Posts: 5915
  • Country: de
Re: Understanding Support ICs for MCU
« Reply #1 on: April 16, 2023, 05:55:07 pm »
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.
 

Offline wayfarer.technologiesTopic starter

  • Contributor
  • Posts: 15
  • Country: us
Re: Understanding Support ICs for MCU
« Reply #2 on: April 16, 2023, 07:31:57 pm »
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.

I 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?

 

Offline mariush

  • Super Contributor
  • ***
  • Posts: 5071
  • Country: ro
  • .
Re: Understanding Support ICs for MCU
« Reply #3 on: April 16, 2023, 07:41:13 pm »
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.

I 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?

An 8-10 pin PIC12F or a ATTiny microcontroller
Like 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

 

Offline wayfarer.technologiesTopic starter

  • Contributor
  • Posts: 15
  • Country: us
Re: Understanding Support ICs for MCU
« Reply #4 on: April 16, 2023, 07:46:13 pm »
how do you latch a button to keep an LED on?
 

Offline mariush

  • Super Contributor
  • ***
  • Posts: 5071
  • Country: ro
  • .
Re: Understanding Support ICs for MCU
« Reply #5 on: April 16, 2023, 07:50:28 pm »
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.
 

Offline wayfarer.technologiesTopic starter

  • Contributor
  • Posts: 15
  • Country: us
Re: Understanding Support ICs for MCU
« Reply #6 on: April 16, 2023, 08:01:51 pm »
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.

 

Offline mariush

  • Super Contributor
  • ***
  • Posts: 5071
  • Country: ro
  • .
Re: Understanding Support ICs for MCU
« Reply #7 on: April 16, 2023, 08:31:34 pm »
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)

see  https://www.digikey.ee/en/articles/how-to-implement-hardware-debounce-for-switches-and-relays  which also shows using NAND as SR latch and LS18
or see https://digilent.com/reference/learn/microprocessor/tutorials/debouncing-via-rc-filter/start

with schmitt triggers  https://mansfield-devine.com/speculatrix/2018/04/debouncing-fun-with-schmitt-triggers-and-capacitors/


You can also watch the videos below



 

Offline Benta

  • Super Contributor
  • ***
  • Posts: 5915
  • Country: de
Re: Understanding Support ICs for MCU
« Reply #8 on: April 16, 2023, 09:02:21 pm »
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.
Then you can start adding switches and LEDs etc. Not before.

« Last Edit: April 16, 2023, 09:05:24 pm by Benta »
 

Offline MarkS

  • Supporter
  • ****
  • Posts: 825
  • Country: us
Re: Understanding Support ICs for MCU
« Reply #9 on: April 16, 2023, 09:03:29 pm »
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!
 

Offline wayfarer.technologiesTopic starter

  • Contributor
  • Posts: 15
  • Country: us
Re: Understanding Support ICs for MCU
« Reply #10 on: April 16, 2023, 10:20:00 pm »
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.  :-X

I made a little picture, I hope this helps where words do not.

1762958-0

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 button


once 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.

 :phew:
 

Offline Benta

  • Super Contributor
  • ***
  • Posts: 5915
  • Country: de
Re: Understanding Support ICs for MCU
« Reply #11 on: April 16, 2023, 10:32:36 pm »
"Ich verstehe nur Bahnhof."
 

Offline Kim Christensen

  • Super Contributor
  • ***
  • Posts: 1368
  • Country: ca
Re: Understanding Support ICs for MCU
« Reply #12 on: April 16, 2023, 11:10:09 pm »
Quote
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 button

You can modify that DigiKey circuit to do what you want:

 

Offline wayfarer.technologiesTopic starter

  • Contributor
  • Posts: 15
  • Country: us
Re: Understanding Support ICs for MCU
« Reply #13 on: April 17, 2023, 03:20:10 am »
"Ich verstehe nur Bahnhof."

Ich gelent deutsch in seibten klasse

mein deutsch is sehr... fehlerhaft

Quote
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 button

You can modify that DigiKey circuit to do what you want:

ok, I will give those a look, just getting the very basics going is enough for now

in 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  :-+
 

Offline Kim Christensen

  • Super Contributor
  • ***
  • Posts: 1368
  • Country: ca
Re: Understanding Support ICs for MCU
« Reply #14 on: April 17, 2023, 03:59:01 am »
Quote
in 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.

If 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

« Last Edit: April 17, 2023, 04:50:44 am by Kim Christensen »
 

Offline barshatriplee

  • Regular Contributor
  • *
  • !
  • Posts: 130
  • Country: bd
Re: Understanding Support ICs for MCU
« Reply #15 on: April 17, 2023, 10:25:00 am »
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.
 

Offline tggzzz

  • Super Contributor
  • ***
  • Posts: 19704
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: Understanding Support ICs for MCU
« Reply #16 on: April 17, 2023, 12:17:29 pm »
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.

Change your level of abstraction...

Keep the hardware simple: use a switch plus pullup resistor connected to an input, then implement the debouncing in software.
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Offline MarkS

  • Supporter
  • ****
  • Posts: 825
  • Country: us
Re: Understanding Support ICs for MCU
« Reply #17 on: April 17, 2023, 06:09:25 pm »
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.



You'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.
« Last Edit: April 18, 2023, 03:55:57 am by MarkS »
 
The following users thanked this post: abeyer

Offline abeyer

  • Frequent Contributor
  • **
  • Posts: 305
  • Country: us
Re: Understanding Support ICs for MCU
« Reply #18 on: April 17, 2023, 07:34:49 pm »
I think there might be some language or culture barrier (and even in my own country no one understands me  :-// )
https://xyproblem.info/
 
The following users thanked this post: MarkS

Offline MarkS

  • Supporter
  • ****
  • Posts: 825
  • Country: us
Re: Understanding Support ICs for MCU
« Reply #19 on: April 17, 2023, 09:31:11 pm »
I think there might be some language or culture barrier (and even in my own country no one understands me  :-// )
https://xyproblem.info/
THAT describes this thread perfectly!
 

Offline wayfarer.technologiesTopic starter

  • Contributor
  • Posts: 15
  • Country: us
Re: Understanding Support ICs for MCU
« Reply #20 on: April 18, 2023, 04:06:31 am »
I think there might be some language or culture barrier (and even in my own country no one understands me  :-// )
https://xyproblem.info/
THAT describes this thread perfectly!

I think there might be some language or culture barrier (and even in my own country no one understands me  :-// )
https://xyproblem.info/


So I am aware of this phenomena and perhaps it is a case of compensating for the compensation, or just zigging instead of zagging


What 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 about

User asks for help with Y.
yes, though I think by including my context people were mistaken about the task at hand

Others 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 scope

After 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 helpful

The 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 problem

If someone asks for more information, do provide details.
yes thats been the case

If there are other solutions you've already ruled out, share why you've ruled them out. This gives more information about your requirements

using 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 :-+
 

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 16687
  • Country: us
  • DavidH
Re: Understanding Support ICs for MCU
« Reply #21 on: April 18, 2023, 06:00:58 am »
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.
 
The following users thanked this post: wayfarer.technologies

Offline retiredfeline

  • Frequent Contributor
  • **
  • Posts: 546
  • Country: au
Re: Understanding Support ICs for MCU
« Reply #22 on: April 18, 2023, 01:19:57 pm »
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-65uino A lot of people do this kind of project out of nostalgia or just for kicks.
 

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 16687
  • Country: us
  • DavidH
Re: Understanding Support ICs for MCU
« Reply #23 on: April 18, 2023, 04:04:07 pm »
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 ubiquitous 8255 which 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
 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: Understanding Support ICs for MCU
« Reply #24 on: April 18, 2023, 05:15:59 pm »
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.

That 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.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf