Pic interface: keyboard, mouse, i2c...
Pic interface: keyboard, mouse, i2c...
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...)
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.
-
Nightmaretony
- In Memoriam
- Posts: 618
- Joined: 27 Jun 2003
- Location: Meadowbrook
- Contact:
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....
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"
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...
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...
-
Nightmaretony
- In Memoriam
- Posts: 618
- Joined: 27 Jun 2003
- Location: Meadowbrook
- Contact:
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 will post my first schematic in a few days, so we might start some discussion...
Here is my first try on this:
(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?
6502.org wrote:
Image no longer available: http://www.iteracija.com/mupload/pici.JPG
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.
- GARTHWILSON
- Forum Moderator
- Posts: 8773
- Joined: 30 Aug 2002
- Location: Southern California
- Contact:
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?
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
- GARTHWILSON
- Forum Moderator
- Posts: 8773
- Joined: 30 Aug 2002
- Location: Southern California
- Contact:
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.
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.
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.
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.
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?
- GARTHWILSON
- Forum Moderator
- Posts: 8773
- Joined: 30 Aug 2002
- Location: Southern California
- Contact:
- GARTHWILSON
- Forum Moderator
- Posts: 8773
- Joined: 30 Aug 2002
- Location: Southern California
- Contact: