Continue to Site

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.

  • 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.

software protocol using PIC

Status
Not open for further replies.

SimonW

New Member
Dear Sir/Madam,

Does anyone know the best way to implement a serial protocol on a PIC, (Not RS232 or SPI).
I will be using CCS 'C' compiler.

In particular I am intrested how one ensures that when a '1' is outputed on a PIC it actually arrives on the pin on time.

How can one syncronise data output on a PIC output pin W,X,Y
with the rising edge of a PIC generated CLOCK output on pin Z

Hence I wish to generate a clock, data signals on a PIC


I hope you understand

Regards,

SimonW
 
I think you need to clarify your question somewhat. You can easily set any number of pins then toggle a clock output.

But if you need to do something more complicated, explain and someone will help.
 
Clarification + possible soloution

I am trying to get the PIC to communicate (serial) with an an old LED display.
I have managed to get hold of the timing diagram on how to implement comms with it.

the communication protocol not a standard one.

The LED display needs a CLK, 2 data lines (single direction)

----------------------------------
Soloution( 1)
After reading through the data sheet of the pic16f452, I discoverd that the

Master synchronus serial port (MSSP)
will somewhat suffice for my problem.

supports master/slave mode
It will output a CLK
provides 8bit serial data in/out
has edge level triggering

But this will only provide the CLK and 1 data pin.

I will carry on looking.

Regards,

SimonW
 
This seems like a standard problem and is the way that we interface with any sort of screen or external peripheral. The MSSP module is not what you need for this.

In general you need to follow a procedure similar to this:

- set the first data pin high or low
- set the second data pin high or low
- strobe (high then low) the clock pin for a brief period (this will be in the datasheet)

This is repeated until all of the data bits have been sent. You do not need to worry about timing as the display will only read from the two data pins when it sees the clock line go high.

We can be more specific if you link to the datasheet, the only question I have is whether the display module needs a fixed frequency clock (unlikely, but possible). Essentially this should be an easy problem to solve with a microcontroller if you do it all in software.
 
Sounds like you need a serial bit bang (whoops...I mean bit "switch"...sorry eric :D) routine. I can code one up for you but I would need to know either the part number for this LED display or if you have a way to post up the data sheet this would help as well.

As was mentioned previously, as soon as the transmitting device sets the receive line on the receiving device high/low, the "bit" is already at the receiving end instantaneously. But the receiving device does not shift the bit in until the master device tells it to by strobing the clock (CLK) line.
 
Last edited:
From your description is sounds like SPI with one CLK line and one DATA line.

These are very easy to synchronise and don't need any perfect timing. You change the DATA pin to the Hi or LO as needed, then make a single CLK pulse.

The only things you need to watch is that the clock pulse is long enough, and that there is a tiny delay between changing the DATA line and making the CLK pulse.

Your LCD datasheet should give you specs for the timing, the minimum times.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top