6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Fri Nov 15, 2024 3:38 am

All times are UTC




Post new topic Reply to topic  [ 22 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Tue Nov 27, 2018 3:42 pm 
Offline
User avatar

Joined: Tue Nov 27, 2018 3:28 pm
Posts: 20
Location: Netherlands..
Hello,

just a quick question, is there a easy way to use
my sensors for the arduino/raspberry on the SXB/QBR boards of WDC ?

or put it in other words, how can i use those sensors on a W65Cxxx system.
seen a lot of ports on them, but missing the modern GPIO, SPI and I2C ...

just need a pointer, the rest i will figure out..
Thx... !


Top
 Profile  
Reply with quote  
PostPosted: Tue Nov 27, 2018 4:51 pm 
Offline

Joined: Sat Dec 13, 2003 3:37 pm
Posts: 1004
Collen wrote:
Hello,

just a quick question, is there a easy way to use
my sensors for the arduino/raspberry on the SXB/QBR boards of WDC ?

or put it in other words, how can i use those sensors on a W65Cxxx system.
seen a lot of ports on them, but missing the modern GPIO, SPI and I2C ...

just need a pointer, the rest i will figure out..
Thx... !

Well, the WDC boards DO have "GPIO", those are just the available ports from the VIA or the uControllers themselves (depending on which board and CPU you're using).

Out of the box, they don't support SPI or I2C, but there's a thread here on "bit banging" SPI (which isn't that hard to do). You can also do this for I2C, there are several examples on the 'net that could be easily adapted to 65xx.

Finally there's also dedicated chips that handle the 8 bit <-> SPI/I2C conversion.

But, natively, the boards do not support either.


Top
 Profile  
Reply with quote  
PostPosted: Tue Nov 27, 2018 5:24 pm 
Offline
User avatar

Joined: Wed Feb 14, 2018 2:33 pm
Posts: 1485
Location: Scotland
Collen wrote:
Hello,

just a quick question, is there a easy way to use
my sensors for the arduino/raspberry on the SXB/QBR boards of WDC ?

or put it in other words, how can i use those sensors on a W65Cxxx system.
seen a lot of ports on them, but missing the modern GPIO, SPI and I2C ...

just need a pointer, the rest i will figure out..
Thx... !


If your board can talk to the Pi via serial then, yes, you can use the Pi's GPIO, including SPI, I2C, etc. from - well, anything that can talk serial.

The down-side is that you have to write code on the Pi to handle the comms.

So if, for example, you wrote a C program on the Pi using the wiringPi library, then you read in a command byte - e.g. digitalWrite, read in a pin byte, then a value byte - you execute the digitalWrite() then go back and wait for more. If you used the wiringPi extensions, then you can use all the devices that wiringPi directly supports, or add your own into it using existing devices as templates.

I understand that other GPIO libraries exist for the Pi, but I write/maintain wiringPi, so it's what I'd use...

-Gordon

_________________
--
Gordon Henderson.
See my Ruby 6502 and 65816 SBC projects here: https://projects.drogon.net/ruby/


Top
 Profile  
Reply with quote  
PostPosted: Tue Nov 27, 2018 7:36 pm 
Offline
User avatar

Joined: Tue Nov 27, 2018 3:28 pm
Posts: 20
Location: Netherlands..
whartung wrote:
Well, the WDC boards DO have "GPIO", those are just the available ports from the VIA or the uControllers themselves (depending on which board and CPU you're using).

Out of the box, they don't support SPI or I2C, but there's a thread here on "bit banging" SPI (which isn't that hard to do). You can also do this for I2C, there are several examples on the 'net that could be easily adapted to 65xx.

Finally there's also dedicated chips that handle the 8 bit <-> SPI/I2C conversion.

But, natively, the boards do not support either.


Ah, thx that makes more sense to me..
so basicly i can use the via ports (j3) on the W65C02SXB and W65C816SXB for GPIO
but how about the W65C134SXB and W65C265SXB (and not to forget the mensch computer) ?
they don't have a VIA w65c22... but they do have I/O ports (j3/j4/j5)

also isn't the via only 0 or 1 ?!
you can't read (lets say) a temperature from a sensor that way...

Cheers, Collen


Top
 Profile  
Reply with quote  
PostPosted: Tue Nov 27, 2018 9:00 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8541
Location: Southern California
Collen wrote:
but how about the W65C134SXB and W65C265SXB (and not to forget the mensch computer) ?
they don't have a VIA w65c22... but they do have I/O ports (j3/j4/j5)

also isn't the via only 0 or 1 ?!
you can't read (lets say) a temperature from a sensor that way

The '134 and '265 do have a lot of I/O, but unfortunately no A/D converters. You can see what I put on my 65c02 workbench computer for A/D at http://wilsonminesco.com/6502primer/potpourri.html#ADC . This converter (the MAX153) is much faster than what's on most microcontrollers. This page (the circuit potpourri page) of the 6502 primer shows a lot more interfacing, primarily things you can do with the 65c22. Many of those things have links to sample code. These are all things I've done on my 65c02 workbench computer.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
PostPosted: Tue Nov 27, 2018 10:17 pm 
Offline

Joined: Sat Dec 13, 2003 3:37 pm
Posts: 1004
Collen wrote:
Ah, thx that makes more sense to me..
so basicly i can use the via ports (j3) on the W65C02SXB and W65C816SXB for GPIO
but how about the W65C134SXB and W65C265SXB (and not to forget the mensch computer) ?
they don't have a VIA w65c22... but they do have I/O ports (j3/j4/j5)

The W65C265SXB (I can't speak to the 134) has a LOT of ports available. 7, I think.

HOWEVER, depending on how you configure the CPU, many of those ports get used up for other things. The Pi does the same thing.

For example, some of the ports on the 256 are used for the on board UART. Also, if you wish to address external memory, a bunch of the ports get used for the Address and Data bus. It's actually a shame the 256 can't be configure to use a 16 bit address bus instead of the full 24 bit one to free up a port.

In the end, if you're using external memory, and the serial ports, there's only 1 full port, and parts of another I think, available for generic applications. It's another shame that the 256 doesn't have any on board flash, but was designed to have a ROM masked in to it at production for your "custom code". Great if that's your application, not so much for one off uses like hobbyists.

Quote:
also isn't the via only 0 or 1 ?!
you can't read (lets say) a temperature from a sensor that way...

Correct. If you have access to an analog temperature sensor, you would need an Analog to Digital (A/D) Converter. These take analog values (voltages) and turn them in to bits for something like a VIA/GPIO. Speaking of SPI, there are A/D converters that you can interface with via SPI.

We have this thread semi-dedicated to W65C265SXB.


Top
 Profile  
Reply with quote  
PostPosted: Wed Nov 28, 2018 3:54 pm 
Offline
User avatar

Joined: Tue Nov 27, 2018 3:28 pm
Posts: 20
Location: Netherlands..
Hmm... getting there.. :D

so for most sensors you'll need a ADC to convert the sensor analog data
to digital data for the SXB boards.

1 thing still confuses me, do i hook the ADC up to the data ports (J1 - Xbus134)
or do i use one of the P4X/P5X/P6X connectors (J3/J4/J5) ?

coz using the J1, Xbus makes it a lot harder, but with the PxX connectors
i can use there simple address ($DF2x range)

why is this so much harder than an ATmega or Pi where u can use 1 data wire ?
(sorry for being such a newbie)

Thx Collen.


Top
 Profile  
Reply with quote  
PostPosted: Wed Nov 28, 2018 4:17 pm 
Offline
User avatar

Joined: Wed Feb 14, 2018 2:33 pm
Posts: 1485
Location: Scotland
Collen wrote:
Hmm... getting there.. :D

so for most sensors you'll need a ADC to convert the sensor analog data
to digital data for the SXB boards.

1 thing still confuses me, do i hook the ADC up to the data ports (J1 - Xbus134)
or do i use one of the P4X/P5X/P6X connectors (J3/J4/J5) ?

coz using the J1, Xbus makes it a lot harder, but with the PxX connectors
i can use there simple address ($DF2x range)

why is this so much harder than an ATmega or Pi where u can use 1 data wire ?
(sorry for being such a newbie)

Thx Collen.


So why not use 1-wire? You just have to write the code for it. All you need is one pin and the ability to change that pin from input to output and back again.

Someone wrote the 1-wire code for the Arduino and Pi systems - you now have the opportunity to have your name set in stone as the person who wrote the 1-wire code for the 6502. Think of it as an opportunity.

The timing constraints are well inside that of a 6502 - the shortest time you need to pulse the line low for is in the order of 6µS.

I'd suggest using a Pi or Arduino to get the 1-wire devices address though - the address-tree traverse code can be somewhat complex.

(I've written 1-wire driver code from scratch in the past, but you can get the sources of the Arduino 1-wire library to give you an idea)

For a generic ADC - you need an 8-bit port and a few bits of signalling for device select and read/write. If the device is fast enough and can have direct access to the 65xx's address+data lines (I'm really not familiar with these SXB systems), then you can memory map it into the system.

Or implement SPI or I2C (SPI is easier) and use one of the many SPI ADCs that exist.

-Gordon

_________________
--
Gordon Henderson.
See my Ruby 6502 and 65816 SBC projects here: https://projects.drogon.net/ruby/


Top
 Profile  
Reply with quote  
PostPosted: Wed Nov 28, 2018 7:47 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8541
Location: Southern California
I fixed a typo in my post above, "unfortunately to A/D converters" to "unfortunately no A/D converters." Big difference.

I get the feeling that we have not been very clear so far about the simplicity and incredible options afforded SPI and I²C. There are at least hundreds, if not thousands, of ICs available with these interfaces; so it's definitely beneficial to learn to use them. I tried to make a somewhat concise description of the various serial interfaces at viewtopic.php?p=7606#p7606 . Looking at it again, I think I should go back and further improve it. Have a look though. There are quite a few links there also which will be helpful.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
PostPosted: Wed Nov 28, 2018 8:04 pm 
Offline

Joined: Sat Jun 04, 2016 10:22 pm
Posts: 483
Location: Australia
If you have a parallel ADC, I'd say use any port with 8 bits for the data pins, and then another port (but not necessarily all of it) for the rest of the control signals. You aren't required to use the special pin functions of most microcontrollers; you can usually switch them over to GPIO. I would, for this purpose. I wouldn't want to mess around with adapting that if I don't have to.

I would be more inclined to use SPI, but you will have to bit-bang that. It is possible to do, and if you do that in a subroutine or two(essentially making a small library), you can reuse it for whatever other SPI device you happen to use.


Top
 Profile  
Reply with quote  
PostPosted: Wed Nov 28, 2018 10:21 pm 
Offline

Joined: Sat Dec 13, 2003 3:37 pm
Posts: 1004
Collen wrote:
1 thing still confuses me, do i hook the ADC up to the data ports (J1 - Xbus134)
or do i use one of the P4X/P5X/P6X connectors (J3/J4/J5) ?

If you're just using the onboard, 576 bytes of RAM, and the ROM monitor, you use P0-P3 with impunity, just have to make sure they're configured properly.

As a general rule, the P4 port is pretty much universally available to be used in most any configuration, so you might want to use that one instead. You shouldn't have to do anything to configure it.

$00DF24 is the data direction register for P4, and $00DF20 is the data register.


Top
 Profile  
Reply with quote  
PostPosted: Thu Nov 29, 2018 9:35 pm 
Offline
User avatar

Joined: Tue Nov 27, 2018 3:28 pm
Posts: 20
Location: Netherlands..
Thank you all, it makes much more sense to me now.

The 1 wire explanation from Gordon, gives me a nice direction.
also the ADC clarification, Wilson and Whartung gave is clear.
Guess SPI would do the trick for more things i have in mind.

for only 1 sensor, the P4 port will do for now, but i'll try to get SPI done
(need to do some more research on that,,, on to the topic link.)

the SBX boards look good, in terms of what you can achieve with them
good thing i learned how to code the 6510 as a kid... :)

Greets, Collen's Business Machines.... :lol:


Top
 Profile  
Reply with quote  
PostPosted: Sat Dec 01, 2018 11:55 am 
Offline

Joined: Mon Sep 14, 2015 8:50 pm
Posts: 112
Location: Virginia USA
Not sure if this is any help but the 65c265 does do pulse width measurement on one pin and has two separate tone generator pins. WDC doesn't offer much help beyond a basic description of the function except to mention that it's beyond the scope of its documentation. Its intended use is (or was) in telephone communications. The pins appear to be ADC and DAC in nature.

Cheers,
Andy


Top
 Profile  
Reply with quote  
PostPosted: Wed Dec 12, 2018 10:50 am 
Offline
User avatar

Joined: Tue Nov 27, 2018 3:28 pm
Posts: 20
Location: Netherlands..
drogon wrote:

The timing constraints are well inside that of a 6502 - the shortest time you need to pulse the line low for is in the order of 6µS.

-Gordon


Still some questions, how many micro/nano seconds is 1 cycle ? (let say a NOP, the rest i can calculate)

also are the I/O ports protected or can they handle a bit bang ? (output a bit/pulse, while a bit/pulse is coming in)
if i shorten them because the timing is off, do i wreck my SXB board ?

and finally (little less important), i can't find info on power consumption off the SXB boards.
Only the standard 5V. (no watt, amps ect).

Thx.. Collen.


Top
 Profile  
Reply with quote  
PostPosted: Wed Dec 12, 2018 11:53 am 
Offline

Joined: Mon May 21, 2018 8:09 pm
Posts: 1462
If your clock speed is 1MHz, then 1 cycle is 1µs or 1000ns. At higher clock speeds, each cycle takes proportionately less time. A standard NOP ($EA opcode) takes 2 cycles.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 22 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: