6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Sep 28, 2024 11:23 pm

All times are UTC




Post new topic Reply to topic  [ 28 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Wed Aug 17, 2011 2:48 pm 
Offline
User avatar

Joined: Mon Aug 08, 2011 2:48 pm
Posts: 808
Location: Croatia
Hello!

Since i am building a 6502 project of my own, i wanted to have keyboard interface, so i decided to build the Daryl's AVR PC Keyboard IO. I went to the shop but they didn't have any Attinys. So i asked Daryl could i use some other microcontroller, he said me i could use Atmega. So i bought Atmega8, and downloaded Avr studio. I did the proper modifications to make it work on Atmega, but when i hit compile all kind of crazy errors started popping up, and i was unable to fix it...
So since i am using the Microchip pic for a while, i decided to make my own keyboard interface, that would have more options, like switching Z and Y (in Croatia and Germany is switched). So i went to the shop, i spent a lot of money buying two 16f628 (one for later). When i finished my program(using proton ide) of course i now need to program the pic and test if it works! So i put my new 16f628 in my ebay miracle programmer(it cad program form eproms to avr pic, it can test ic...) and hit program! But something went wrong and the pic kinda got fried, ok i put the other one, it programed id, just to be sure i tried to reprogram it, but it seems my new pic didn't like my chinese miracle programmer...
That is kinda weird, because i programmed eproms eeproms atmega pic, and i never had problems with it... After that it was nearly the end of my semester, and i had to study for the final exams... So now when i am home i thought, what if i used a pic16f877 (my favorite), so i bought one from ebay at 1/3 of the price that i could find it at the electronic store.
But this is a powerful microcontroller and it is a waste to use it just as a keyboard interface, so what if i use all of its resources, and have a keyboard and mouse interface, lcd interface, i2c bus interface, a/d converters... And i started doing some schematics, but then i realized that i exactly don't know how does (for example) EhBasic (or other) handle the character input, who has to empty the register when the character is read? Does EhBasic automaticly store 00, or it must empty automaticly after reading? So when i solve this (and some other) mystery i can finally finish planning this and start soldering...
I will post my progress, and discuss my design...
(Please don't get angry if i do something horribly wrong...)


Last edited by Dajgoro on Thu Aug 18, 2011 2:20 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Aug 18, 2011 12:20 am 
Offline

Joined: Fri Jun 27, 2003 8:12 am
Posts: 618
Location: Meadowbrook
Nothing wrong with trying and sharing. Always adds to the fun.

One nice thing on the tinys, small and cheap but a nice power. Was always praying for a tiny architecture but being a 65C02.

The pic you know best, you may want too ask Darryl for the source for his keyboard encoder and write your own for the pic to interface. then share your knowledge and adventures as others may want to go the pic route as well....

_________________
"My biggest dream in life? Building black plywood Habitrails"


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Aug 18, 2011 1:10 am 
Offline
User avatar

Joined: Mon Aug 08, 2011 2:48 pm
Posts: 808
Location: Croatia
Daryl's keyboard source code is free for download at his web page.
Actually i used his scancode to ascii table in my interface(I hope he doesn't mind).
I already finished the keyboard interface(code), but i hat trouble with toes pic 628. Currently i have the pic16f877 hooked up to a lcd, and when i type something on the keyboard it shows on the lcd. But now i need a interface for the 6502 bus, and i need yet to make a mouse and i2c interface...
When i finish this, i will put all the code and schematic for download of course...


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Aug 18, 2011 2:48 pm 
Offline

Joined: Fri Jun 27, 2003 8:12 am
Posts: 618
Location: Meadowbrook
Lee Davison has a great I2C interface on his projects page which is pretty adaptable. I think it can go inside a CPLD, no problem.

_________________
"My biggest dream in life? Building black plywood Habitrails"


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Fri Aug 19, 2011 2:46 am 
Offline
User avatar

Joined: Mon Aug 08, 2011 2:48 pm
Posts: 808
Location: Croatia
Nightmaretony wrote:
Lee Davison has a great I2C interface on his projects page which is pretty adaptable. I think it can go inside a CPLD, no problem.

I don't have any CPLD, i only have microcontrollers. The Proton IDE(witch i use for the pic) has already implemented i2c and spi, and other functions, so it is not much trouble here...
I will post my first schematic in a few days, so we might start some discussion...


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun Aug 21, 2011 4:03 pm 
Offline
User avatar

Joined: Mon Aug 08, 2011 2:48 pm
Posts: 808
Location: Croatia
Here is my first try on this:
Image
(Sorry for paint schematic, ill do a proper one when discussion finishes...)

The idea is, that writes happen only on clock phase 1, and when pic wants to write something, it sets the bistable, and wait for the phase 1. When writing is done, it sets 0 on the output port, so when the 6502 reads something, it sets the bistable, and it automatically clears the latch.

I see 2 problems with this design: 1. If more data needs to be read from the 6502 will require special subroutine that would wait for the data. 2. The design gets a bit complicated and slow...

I think it would be a better solution to have something like a 64 bit ram, and communicate through it. But then how do i clear something when it is read?
Any ideas?


Last edited by Dajgoro on Sun Aug 21, 2011 5:43 pm, edited 2 times in total.

Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun Aug 21, 2011 4:22 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10938
Location: England
Hi - try saving your picture as a gif or png instead of bmp.
Cheers
Ed
(Edit: picture is showing now, as a jpg.)


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun Aug 21, 2011 7:41 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8520
Location: Southern California
How about using a parallel slave port on a PIC. The hardware should be much simpler. Edit, 10/19/18: Microchip's ap. note AN579, about using the PSP, is at http://ww1.microchip.com/downloads/en/A ... 00579b.pdf .

_________________
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  
 Post subject:
PostPosted: Sun Aug 21, 2011 7:58 pm 
Offline
User avatar

Joined: Mon Aug 08, 2011 2:48 pm
Posts: 808
Location: Croatia
Whit this i could send keyboard data, but still how do i then receive other data from mouse, i2c...


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun Aug 21, 2011 8:00 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8520
Location: Southern California
You would have to work out your protocol in software, but it can be done.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun Aug 21, 2011 9:23 pm 
Offline

Joined: Thu Jul 26, 2007 4:46 pm
Posts: 105
The PIC 877 (and successor 877A) have a builtin "parallel slave port" feature. While this is nowhere near as well featured as on more modern (PIC18, PIC24, dsPIC and PIC32), it should be feasible to implement a reasonably simple "command response" interface. For example, you might say that doing a write of $00 followed by a read would return the status register, which would contains bits such as "Character waiting" and "I2C operation complete". You might then do a write of $01 followed by a read to get the keyboard character. You just have to be careful that you never allow an interrupt to occur in the middle of one of these operations.

It requires an Intel-style bus interface, but you probably have one of these for your SRAM.

The complex bit (and one area where more modern PICs make things easier) is that you have to make sure you don't access the PIC faster than it can keep up, since there is no "in progress" output.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Aug 22, 2011 1:00 am 
Offline
User avatar

Joined: Mon Aug 08, 2011 2:48 pm
Posts: 808
Location: Croatia
OwenS wrote:
The PIC 877 (and successor 877A) have a builtin "parallel slave port" feature. While this is nowhere near as well featured as on more modern (PIC18, PIC24, dsPIC and PIC32), it should be feasible to implement a reasonably simple "command response" interface. For example, you might say that doing a write of $00 followed by a read would return the status register, which would contains bits such as "Character waiting" and "I2C operation complete". You might then do a write of $01 followed by a read to get the keyboard character. You just have to be careful that you never allow an interrupt to occur in the middle of one of these operations.

It requires an Intel-style bus interface, but you probably have one of these for your SRAM.

The complex bit (and one area where more modern PICs make things easier) is that you have to make sure you don't access the PIC faster than it can keep up, since there is no "in progress" output.


I thought about that, but then the problem is in the way keys are read, if i got it right, when a key is pressed, it appears, and when is read, it clears the register.
So if i use the method mentioned above, it would seem as a key is being pressed when i read something from the pic. I could make a bypass for the keyboard somehow... Or something?


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Aug 22, 2011 1:19 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8520
Location: Southern California
A handshake protocol implemented in software would make sure there are no overruns or repeated info. It would make sure the master knows when the slave is ready for more data (or instructions) or has new data to send, and what the data are.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Aug 22, 2011 1:21 am 
Offline
User avatar

Joined: Mon Aug 08, 2011 2:48 pm
Posts: 808
Location: Croatia
But if i use EhBasic, how do i implement such protocol in his get and put character system?


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Aug 22, 2011 1:24 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8520
Location: Southern California
I'm sure you would do that part in assembly language, probably based on interrupts so it would not even bother the BASIC system. The BASIC wouldn't even have to know you're doing it. Maybe Lee or someone who's familiar with EhBASIC will jump in here and confirm that that will work fine.


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 51 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:  
cron