• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

help with clock output using PIC16f88

Status
Not open for further replies.

facemanfacey

New Member
hi everyone,

i have a quick (and very basic!) question regarding clock output using a PIC16F88 micro controller.

i have an clock running at 20MHz and i would like to output a copy of this clock to a pin so i can connect it to an external device to sync with my USART TX data.

i am assuming i have to use the T1OSO pin in some form or another?

i know this is a very vague question, but any help would be appreciated!

thank you in advance

thomas
 

Nigel Goodwin

Super Moderator
Most Helpful Member
You can take an output directly from the crystal, as long as you use the output side of the PIC oscillator pins.

I fail to see what you're trying to do though? - the USART (by definition - ' S' ) already provides a correct clock output, which the system clock isn't.

What exactly are you trying to do?.
 

Sceadwian

Banned
You missed the A Nigel. "Universal Synchronous Asynchronous Receiver Transmitter"
If he's using SPI mode he gets a clock, if he's using general serial mode he's not.

For reference though if you come up with a good method of handling it, sending the capital letter U on a uart (decimal 85, hex 55) while using 8 bits no parity and 1 stop bit you'll get a 'clock' on the UART line equal to your baud rate. If your receiver knows this is coming it can sync to that. I don't know about the 16f88 specifically but some PIC's have the ability to output a buffered clock. (I think this may be the 18 series though)
 

facemanfacey

New Member
thanks for the replys so far.

i just want to clarify what i am doing with my circuit.

midi data (3 bytes with framing bits per byte) are being recieved via the rx pin of the USART (using a 20MHz crystal, baud rate of 3125). this information gets converted via a look up table to a format which my external device will recognise (a nintendo gameboy of all things!).

this data is sent using the tx pin and is recieved via the data in pin of the gameboy. Also, the gameboy requires a clock signal on the clock pin of the gameboy.

i haven't tried tapping off the signal from the XTAL itself due to me being worried that the signal would not be strong enough and i refuse to use an opamp to gain boost the signal due to cost issues.

the pins on the 16F88 are as follows

1 RA2/AN2/CVREF/VREFRA3/
2 AN3/VREF+/C1OUT
3 RA4/AN4/T0CKI/C2OUT
4 RA5/MCLR/VPP
5 VSS
6 RB0/INT/CCP1(1)
7 RB1/SDI/SDA
8 RB2/SDO/RX/DT
9 RB3/PGM/CCP1(1)

18 RA1/AN1
17 RA0/AN0
16 RA7/OSC1/CLKI
15 RA6/OSC2/CLKO
14 VDD
13 RB7/AN6/PGD/T1OSI
12 RB6/AN5/PGC/T1OSO/T1CKI
11 RB5/SS/TX/CK
10 RB4/SCK/SCL

thank you

thomas
 

Nigel Goodwin

Super Moderator
Most Helpful Member
What does the Gameboy require on the clock pin?, I doubt any random frequency will do?, more likely it's a syncronous serial port, and needs the USART setting to be syncronous and using that clock signal.
 

facemanfacey

New Member
the gameboy has the option of plugging in a standard ps/2 keyboard to control the program, 1 data line and 1 clock line. a standard keyboard has a clock signal between 10KHz to 17KHz.

therefore i will be recieving 3 bytes of midi data at baud rate 3125, converting this data to the hex codes a keyboard would send out (via a look up table), then spitting this data down the line to the gameboy with the aformentioned clock speed.

recieving and converting the data is the easy part, i am just very confused at how to send a clock pulse and the data at that speed.
 
Last edited:

Nigel Goodwin

Super Moderator
Most Helpful Member
So basically you're wanting to emulate a PS/2 keyboard, this isn't a simple uni-directional device, so you can't easily use the hardware USART, it's commonly done it software, leaving the USART for receiving the MIDI data.

I'm presuming the MIDI only arrives fairly slowly?, because incoming MIDI is going to be a LOT faster than the outgoing keyboard type signals.

If you google for 'PIC PS2' there are plenty of examples out on the net.
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading

 
Top