PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Apr 10, 2007 2:51 pm |
|
|
Page 9 of the data sheet has the timing diagrams. It shows 8 clocks,
and a data line. Therefore, you can use the hardware SPI module in
the PIC.
Also on page 9, it gives a spec for the data setup before the falling
edge of SCLK. Therefore the VFD samples the data on the falling edge.
It also shows that SCLK idles at a low level. Based on that information,
you can identify the correct SPI mode from the following web page.
It's SPI mode 1.
http://www.totalphase.com/support/articles/article03/#modes
The maximum frequency of SCLK is rather low, at 500 KHz max.
So you will need to use the appropriate divisor in your setup_spi()
statement, based on your PIC's oscillator frequency. For example,
with a 4 MHz crystal, you can use the divide-by-4 divisor to get 250 KHz.
(1 MHz instruction clock / 4 = 250 KHz SCLK).
Your SPI setup would look like this:
Code: | #include <16F877.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=4000000)
//#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
#define SPI_MODE_0_0 (SPI_L_TO_H | SPI_XMIT_L_TO_H)
#define SPI_MODE_0_1 (SPI_L_TO_H)
#define SPI_MODE_1_0 (SPI_H_TO_L)
#define SPI_MODE_1_1 (SPI_H_TO_L | SPI_XMIT_L_TO_H)
//======================================
void main()
{
setup_spi(SPI_MASTER | SPI_MODE_0_1 | SPI_CLK_DIV_4);
while(1);
}
|
Now you can begin to write the driver for the VFD display. You'll need
to create the POR reset pulse (see the data sheet for the required pulse
width). You also need to wait for a required amount of time after the
reset pulse is done. Then you can use the spi_write() function to send
commands and data to the chip. Note that you must wait for the
required "command processing time" after sending a command.
You can find the delay time in the data sheet. |
|