CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

PIC 18LF8720 SPI interface - Crystalfontz 632 dispaly

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Guest








PIC 18LF8720 SPI interface - Crystalfontz 632 dispaly
PostPosted: Sat Jan 29, 2005 3:12 pm     Reply with quote

Im having difficulty using the SPI interface on a PIC18LF8720 to write to a CrystalFontz 632 display.

The 1st thing I notice is the Display data sheet indicates the max clock rate of the SPI_CLK to the display is 18.182 KHz. I measured the clock on PIC output PIN_C3, at approx 375KHz.

The board I'm using with the PIC has a 6 MHz crystal. It is not an option to change the crystal.

Some relavent code includes:

#include <18F8720.H>
#device ADC=10
#include <string.h>
#fuses H4,NOPUT, NOBROWNOUT, NOLVP, NOWRT, WDT
#use delay(clock=24000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)

#define SCL PIN_C3
#define SDA PIN_C4
#define DSPL_BUSY PIN_C1
#define DSPL_SELECT PIN_C2

main ()
{

setup_spi(SPI_MASTER | SPI_H_TO_L | SPI_CLK_DIV_64);

output_low(DSPL_SELECT); // enable display

delay_ms(50);
spi_write(72);
delay_ms(50);
spi_write(69);

while(1){
RESTART_WDT();
}
}

The display does not change when the above code is executed.
Is the setup_spi() function correct?
Can the clock be made to run slower?
If anyone has any experience with this I would greatly appreciate any input.

Thanks
RobS
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Jan 29, 2005 4:17 pm     Reply with quote

Can you specify the exact CrystalFontz LCD ?

I went to their web page to try to download the data sheet,
and they have at least two models called the "632".

Here's one "632" LCD:
http://www.crystalfontz.com/products/index-ser.html
Here's another one:
http://www.crystalfontz.com/products/index-usb.html

I realize you're using SPI and those listed above are not SPI,
but rather than having me search their whole website, can you
provide a link to the proper section on their web page ?
Ttelmah
Guest







PostPosted: Sat Jan 29, 2005 5:06 pm     Reply with quote

Use Timer2 to clock the SPI.
If you select the option SPI_CLK_T2, you can then program timer2, to use a prescaler of 4, which will give you operation at:

24000000/(4*256*2) = 11718.75Hz

375KHz, is correct with your 24Mhz clock, and division by 64.

Best Wishes
Kenny



Joined: 07 Sep 2003
Posts: 173
Location: Australia

View user's profile Send private message

PostPosted: Sun Jan 30, 2005 4:10 am     Reply with quote

Also, option SPI_H_TO_L is needed - the data has to be valid before
the clock falls, and the clock idle state is high.

Here is the link:
http://www.crystalfontz.com/products/632/632full.pdf
To set spi mode, solder link JPA has to be made (default is RS232)
and JPE has to be made to select 0V to +5V for DATA_IN (default +/-10V).

Here are some other things that need to be right.
From the forum:
" SPI_CS must go low before a the SPI transfer, and ideally will go
high between each byte to guarantee bit synchronization".

Also,
"In almost all cases, SPI_BUSY will stay low. If you experience
trouble and it is going high, you will need to wait for it to go
low before sending the next byte".
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group