Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
LinkBack Thread Tools Display Modes
Old 19th November 2005, 11:40 AM   (permalink)
Default 16F628, get a fast pulse

Hello,
I'm designing a circuit to make conversion between a Ps2 PC mouse protocol, and another protocol.
I can use a 16F628 for most things, but I need to get a 12us width pulse. I don't think I can do by software (as it is like a 3Mhz pulse width). I just need to get one of those pulses, to make PIC do some routine. Then get another pulse 16-20ms after.

I'm thinking on using a timer for this. Get the pulse, do the routine, and reset the counter. Then just wait for another pulse.

Can this be done??
Thank you!
patroclus is offline  
Old 19th November 2005, 11:45 AM   (permalink)
Default Re: 16F628, get a fast pulse

Quote:
Originally Posted by patroclus
Hello,
I'm designing a circuit to make conversion between a Ps2 PC mouse protocol, and another protocol.
I can use a 16F628 for most things, but I need to get a 12us width pulse. I don't think I can do by software (as it is like a 3Mhz pulse width). I just need to get one of those pulses, to make PIC do some routine. Then get another pulse 16-20ms after.
I don't see your problem?. A 16F628 running at 4MHz (as in the internal oscillator) takes only 1uS per instruction cycle, so simply set the pin high (1uS), ten NOP's (10uS), set the bit low (1uS), there you have a 12uS pulse. If you want to call it as a subroutine?, use only 6 NOP's, to account for the call and return instructions.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is online now  
Old 19th November 2005, 11:56 AM   (permalink)
Default

No, what I need is to detect a 6us or 12us pulse, not generate it. that would be so easy!
I need to detect a 12us period clock to output data through another pins. I suppose I nee dsome resolution to output data in low state, si it is valid when clock raises
patroclus is offline  
Old 19th November 2005, 12:45 PM   (permalink)
Default

Quote:
Originally Posted by patroclus
No, what I need is to detect a 6us or 12us pulse, not generate it. that would be so easy!
I need to detect a 12us period clock to output data through another pins. I suppose I nee dsome resolution to output data in low state, si it is valid when clock raises
Sorry!.

Are there other width pulses on this same pin?, or is the 12uF pulse the only one?. If so you could wait for the pulse in a simple loop - as long as the processor doesn't need to be doing something else at the same time. If it does need to be doing something else, you could use interrupts (interrupt on change on portb should do it?).
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is online now  
Old 20th November 2005, 11:16 AM   (permalink)
Default

Yes, I found a way to do it.
Now I need to respond yo a 12us period clock. Each time clock raises, PIC has to output a bit. It is a serie comunication.

If I store the 8 bit data in a register in PIC's ram, how can I output bit by bit when clock is low in another pin??
I can find some way to do it but I wonder if there's an efficient way...
patroclus is offline  
Old 20th November 2005, 11:27 AM   (permalink)
Default

The most common technique is to connect the keyboard clock signal to the RB0/INT pin. You then let the negative going edge initiate an interrupt. The interrupt service routine will shift-in the data bit by bit when you are receiving or shift-out when you are sending a byte to the keyboard.

Just google for "PC keyboard to PIC" to get all the info you need.
__________________
"Having to do with Motion Control"
motion is offline  
Old 20th November 2005, 11:38 AM   (permalink)
Default

thank you.
I already detect the start pulse without interrupts.
What I need to know is how to shift-out bits from a register. 2 registers contain 16 bit to output. An efficient way?
patroclus is offline  
Old 20th November 2005, 01:54 PM   (permalink)
Default

Quote:
What I need to know is how to shift-out bits from a register. 2 registers contain 16 bit to output. An efficient way?
Your question is rather vague. Are you asking a software question? In assembly language, it could be as simple as:

Code:
         RRF  REGH,F
         RRF  REGL,F
         RLF  PORTA,F     ; shift bit appears on PORTA, bit0 (setup as output)
Quote:
I already detect the start pulse without interrupts.
However, while you're shifting out bits, you could miss the center of the 12us pulse and this can make your keyboard program prone to errors. A keyboard scan code can come at anytime. That is why interrupts are recommended.

You can also use hardware like the USART to shift out bits for you but not as a contiguous stream of 16-bits. There are really many ways to do it but they might not work out with what you need.
__________________
"Having to do with Motion Control"
motion is offline  
Old 21st November 2005, 04:22 PM   (permalink)
Default

Yes, that routine is what I was asking for.
But imagine I want to output data trough another pin which is not pin 0 of port. Is there an efficient way of doing it??
thank you.
patroclus is offline  
Old 21st November 2005, 04:27 PM   (permalink)
Default

Quote:
Originally Posted by patroclus
Yes, that routine is what I was asking for.
But imagine I want to output data trough another pin which is not pin 0 of port. Is there an efficient way of doing it??
thank you.
Check my RS232 tutorials for how simple it is, the routine is very easily altered to send 16 bits instead of the ten used by RS232.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is online now  
Old 22nd November 2005, 02:53 PM   (permalink)
Default

Great, similar to what I worked out. At least I know I was right. Thank you
patroclus is offline  
Reply

Bookmarks

Thread Tools
Display Modes





All times are GMT. The time now is 05:48 PM.


Electronic Circuits  |  Learning Electronics
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

eXTReMe Tracker