![]() | ![]() | ![]() |
| | |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
| | LinkBack | Thread Tools | Display Modes |
| | (permalink) |
| 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! | |
| |
| | (permalink) | |
| Quote:
| ||
| |
| | (permalink) |
| 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 | |
| |
| | (permalink) | |
| Quote:
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?). | ||
| |
| | (permalink) |
| 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... | |
| |
| | (permalink) |
| 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" | |
| |
| | (permalink) |
| 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? | |
| |
| | (permalink) | ||
| Quote:
Code: RRF REGH,F
RRF REGL,F
RLF PORTA,F ; shift bit appears on PORTA, bit0 (setup as output) Quote:
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" | |||
| |
| | (permalink) |
| 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. | |
| |
| | (permalink) | |
| Quote:
| ||
| |
| | (permalink) |
| Great, similar to what I worked out. At least I know I was right. Thank you | |
| |