I think, I need the fundamentals...
Thanks Darrel.
I think, I just don't get what SPI is. I assume it is a "better" or "easier" way to make things communicate.
However, I don't understand what and how I do have to implement things.
Again, my goal is to simply send the universal "Hello World!" on a SPI display.
I'm using a 16F690 that has an SSP module; fine. I see, there are two registers SSPSTAT and SSPCON I'll have to define.
Well then, let's enable the SSP module: SSPCON.5=1. Great!
And now, what do I need to do to make my LCD display the famous phrase?
I'm completely lost :(
1 Attachment(s)
Basics, please....just basics
Hi Darrel,
I have several displays that support either parallel or SPI interfacing.
Since I currently use this display (see picture) in 4/8 bits mode (datasheet is here http://www.lcd-module.de/eng/pdf/doma/dog-me.pdf), I think I get the best chance to learn how to get it to work via SPI.
But let's stick on basics, please.
What is SPI all about? What do I need to know to use SPI? What are the minimum requirements to make it work? So many questions....
1 Attachment(s)
first try, first headache....
Well then,
Here is my first attempt to write the character "A" on my display via SPI.
As my code is for sure far too simplistic, it doesn't work :( ...anyway, it's not a surprise; I'm unfortunately used to this.
There is that "RS" line I don't really understand how I need to handle it but from the datasheet, I think I can tie it LOW (detail attached).
Any help or advice to get this "A" shining on my display is welcome ;)
Code:
<html><head></head><body><!--StartFragment--><pre><code><font color="#000080"><i>' PIC 16F690 Fuses
</i></font><font color="#008000">@ DEVICE FCMEN_OFF
@ DEVICE IESO_OFF
@ DEVICE BOD_OFF
@ DEVICE CPD_OFF
@ DEVICE PROTECT_OFF
@ DEVICE MCLR_OFF
@ DEVICE PWRT_OFF
@ DEVICE WDT_OFF
@ DEVICE XT_OSC
</font><font color="#000080"><i>' Registers 76543210
</i></font>OPTION_REG = %10000000 <font color="#000080"><i>'PORT A&B Pull-Ups disabled (look WPUA & WPUB)
</i></font>ANSEL = %00000000 <font color="#000080"><i>'Disable analog inputs Channels 0 to 7
</i></font>ANSELH = %00000000 <font color="#000080"><i>'Disable analog inputs Channels 8 to 11
</i></font>ADCON0 = %00000000 <font color="#000080"><i>'A/D Module is OFF
</i></font>CM1CON0 = %00000000 <font color="#000080"><i>'Comparator1 Module is OFF
</i></font>CM2CON0 = %00000000 <font color="#000080"><i>'Comparator2 Module is OFF
</i></font>INTCON = %00000000 <font color="#000080"><i>'INTerrupts CONtrol
</i></font>TRISA = %00000000 <font color="#000080"><i>'Set Input/Output (0 to 5)
</i></font>PORTA = %00000000 <font color="#000080"><i>'Ports High/Low (0 to 5)
</i></font>TRISB = %01000000 <font color="#000080"><i>'Set Input/Output (4 to 7)
</i></font>PORTB = %00000000 <font color="#000080"><i>'Ports High/Low (4 to 7)
</i></font>TRISC = %01000000 <font color="#000080"><i>'Set Input/Output (0 to 7)
</i></font>PORTC = %01000000 <font color="#000080"><i>'Ports High/Low (0 to 7)
'set up SPI master mode
</i></font>SSPSTAT = %00000000
SSPCON = %00100000
<font color="#000080"><i>'-------------------------------------------------------------------------------
' EA DOGMxxx-A SPI mode LCD circuitry (see datasheet)
' "RS" is pulled LOW = Instruction register (for write)
'-------------------------------------------------------------------------------
</i></font>INIT:
SCK <b>VAR </b>PORTB.6 <font color="#000080"><i>'Clock pin
</i></font>CSB <b>VAR </b>PORTC.6 <font color="#000080"><i>'LOW active pin
</i></font>SDO <b>VAR </b>PORTB.7 <font color="#000080"><i>'Data Out pin
' "EA-DOGM162L-A" LCD display Mandatory settings
'$39 'Function Set: 8 bits bus mode
'$1C 'Bias set
'$52 'Power control + Contrast (HiByte)
'$69 'Follower control
'$75 'Contrast (LowByte)
</i></font><b>PAUSE </b>1000 <font color="#000080"><i>'Time to settle Vdd (THIS IS VERY IMPORTANT for this display!!!)
</i></font><b>LOW </b>CSB <font color="#000080"><i>'set LCD active
</i></font><b>SHIFTOUT </b>SDO,SCK,1,[$39,$1C,$52,$69,$75] <font color="#000080"><i>'MSBFIRST
</i></font><b>HIGH </b>CSB <font color="#000080"><i>'set LCD inactive
'-------------------------------------------------------------------------------
</i></font>MAIN:
<font color="#000080"><i>' Clear display
</i></font><b>LOW </b>CSB
<b>SHIFTOUT </b>SDO,SCK,1,[$1]
<b>HIGH </b>CSB
<font color="#000080"><i>' Sent character "A" to display
</i></font><b>LOW </b>CSB
<b>SHIFTOUT </b>SDO,SCK,1,[$41]
<b>HIGH </b>CSB
<b>
END
</b></code></pre><!--EndFragment--></body>
</html>
NB: thanks Jerson, your explanation made the SPI principle get out my head's myst
maybe a light at the end of the tunnel?
Quote:
Originally Posted by
Darrel Taylor
Don't even try using the MSSP module until it's working with SHIFTOUT.
Thanks Darrel, I understand only now what you meant in a previous post ;)
SPI basics - some examples here (PIC -> LCD)
I've been working on some different projects for a while and just forgot to give some links to the projects I made with the help of this forum.
You can find two examples of simple (hopefully not too simple) software SPI (one-way) communication in BASIC language only:
http://home.citycable.ch/flotulopex/...D_Frames_e.htm
http://home.citycable.ch/flotulopex/...D_Frames_e.htm