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 CCS Technical Support

EA-6 display DOGS102w About SPI control with PIC16F690

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



Joined: 07 Jan 2013
Posts: 90

View user's profile Send private message

EA-6 display DOGS102w About SPI control with PIC16F690
PostPosted: Mon Jan 07, 2013 4:43 pm     Reply with quote

Hello,
I bought the following display
http://www.lcd-module.de/deu/pdf/grafik/dogs102-6.pdf
and for days I'm trying to build a connection with PIC16F690 but it is the despair I can actually display no signs of let my code thus looks to initialize
Code:

#include <main.h>
#USE SPI (MASTER, CLK=PIN_B6, DO=PIN_C7, MODE=3, BITS=8, MSB_FIRST)

#define Reset pin_c5
#define CSO pin_c4
#define CD pin_c3


void init(void);

void main() {
setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard
setup_spi(SPI_MASTER | SPI_L_TO_H |SPI_SS_DISABLED);
delay_ms(500);
init();
while(TRUE){
int d;
int e;

d=input(pin_a0);
if (d==1)
{
init();
}
e=input(pin_a1);
if (e==1)
{
output_low(CSO);
output_high(CD);

spi_write(0x00);
spi_write(0x7F);
spi_write(0x09);
spi_write(0x09);
spi_write(0x76);
delay_ms(1);
output_high(CSO);

}

}
}


void init(void)
{
output_high(Reset);
output_low(CD);
output_high(CSO);

spi_write(0x40);
spi_read(0x40);
delay_us(75);
spi_write(0xA0);
spi_read(0xA0);
delay_us(75);
spi_write(0xC8);
spi_read(0xC8);
delay_us(75);
spi_write(0xA4);
delay_us(75);
spi_write(0xA6);
delay_us(75);
spi_write(0xA2);
delay_us(75);
spi_write(0x2F);
delay_us(75);
spi_write(0x27);
delay_us(75);
spi_write(0x81);
delay_us(75);
spi_write(0x10);
delay_us(75);
spi_write(0xFA);
delay_us(75);
spi_write(0x90);
delay_us(75);
spi_write(0xAF);
delay_us(75);

output_low(CSO);


}
 

I am looking for any advice.
I've also read that the ccs compiler this can not !? But it works when I simulate "Proteus" I clearly can not simulate display.
I use vers PCWHD. 4134 CCS compiler.
Ttelmah



Joined: 11 Mar 2010
Posts: 19537

View user's profile Send private message

PostPosted: Tue Jan 08, 2013 2:01 am     Reply with quote

Start with your SPI setup. It's wrong....
You are using SPI mode 1. This implies the clock idles low and data changes on the rising edge of the clock, and is latched on the falling edge. This is not what the device data sheet shows. It shows the clock idling _high_, with data being changed on the falling edge of the clock, and latched on the rising edge. This is SPI mode 3
Second thing is that SPI_SS_DISABLED, is a command for a _slave_ device.
Use:
Code:

#define SPI_MODE_0  (SPI_L_TO_H | SPI_XMIT_L_TO_H)
#define SPI_MODE_1  (SPI_L_TO_H)
#define SPI_MODE_2  (SPI_H_TO_L)
#define SPI_MODE_3  (SPI_H_TO_L | SPI_XMIT_L_TO_H)

setup_spi(SPI_MODE_3);

Then, why are you using SPI_READ?. The unit does not support this. It only has a SDI line, not an SDO line.

Simplify, use an array:
Code:

const int8 init_data[13]={0x40,0xA0,0xC8,0xA4,0xA6,0xA2,0x2F,0x27,0x81,0x10,0xFA,0x90,0xAF};

void init(void) {
   int8 icount;
   output_high(CS0);
   output_low(Reset); //Make sure lines are idle to start, and trigger reset
   delay_ms(1);
   output_high(Reset);
   delay_ms(5);
   output_low(CD); //Now select device
   output_low(CSO);
   for (icount=0;icount<sizeof(init_data);icount++) {
       spi_write(init_data[icount]);
   }
   output_high(CD);
   output_high(CS0);
   delay_ms(120);
}

They show CS0, going _low_ to select the device. You are raising it.

Then remember you can send data to the display RAM using printf, so:
Code:

   output_high(CD);
   output_low(CS0);
   printf(spi_write(),"Hello");
   output_high(CS0);


Obviously choose what you want to send.

Best Wishes
Sterngleiter



Joined: 07 Jan 2013
Posts: 90

View user's profile Send private message

PostPosted: Tue Jan 08, 2013 6:03 am     Reply with quote

no success, it's not running.
someone perhaps a different proposal
temtronic



Joined: 01 Jul 2010
Posts: 9241
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Jan 08, 2013 6:22 am     Reply with quote

maybe obvious but.....

1) you are powering both PIC and LCD with 3 volts ?

2) have you got the '1Hz blinking LED' program to run?

3) do you supply power to backlight the LCD,is 'contrast' adjusted right?

hth
jay
Sterngleiter



Joined: 07 Jan 2013
Posts: 90

View user's profile Send private message

PostPosted: Tue Jan 08, 2013 7:00 am     Reply with quote

yes, yes and yes.
I've tried everything.
I get a single character appears.
Display is new.
There is no test mode for display.
Ttelmah



Joined: 11 Mar 2010
Posts: 19537

View user's profile Send private message

PostPosted: Tue Jan 08, 2013 8:20 am     Reply with quote

You do realise this is a _graphic_ display. You are going to have to build text line by line. Though I sent 'Hello', I said 'You'll have to choose what you want to send'. It does not have a character generator.....

Best Wishes
Sterngleiter



Joined: 07 Jan 2013
Posts: 90

View user's profile Send private message

PostPosted: Tue Jan 08, 2013 8:55 am     Reply with quote

Yes I am aware of. I had similar display with RS232 interface if I could build the connection via SPI I knew more already. also clear to me is that I can not just send a "Hello". According to the datasheet display is readable even without light. It seems to me that I am correct with the times. The timing plays a big role, I think. I have no oscilloscope which I can measure this.
greeting
temtronic



Joined: 01 Jul 2010
Posts: 9241
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Jan 08, 2013 10:08 am     Reply with quote

I did a quick google search for that display and it seems 'nut&volts' have an article about using in in the june 2011 issue.
Hopefully you can download it and figure out what's not working 'quite right'.

hth
jay
Sterngleiter



Joined: 07 Jan 2013
Posts: 90

View user's profile Send private message

PostPosted: Tue Jan 08, 2013 10:55 am     Reply with quote

The SPI interface and the graphical display are new to me because I have two no experience I can my mistake not locate so I sent no code. I simulate a connection with Proteus works there but unfortunately I do not find SPI LCD for simulation. I measure the output SDO and SCK with the virtual oscilloscope clock (SCK), and I can measure data (SDO) also come on so I guess that somehow wrong values ​​are transmitted to the display. In the data sheet values ​​for the initialization are but what I do not understand this is how the display controller know what needs to be assigned worth while because the values ​​are supposed to be sent one after another. Would not really look like the assignment so "display ==> ON" .
Examples with this display I have not found the net.
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Tue Jan 08, 2013 1:07 pm     Reply with quote

The CCS compiler introduced in version 4 the #USE SPI commands which are much more flexible than the older setup_spi() functions but you cannot use them both.
Since you are using spi_write() you have to get rid of the #USE SPI line.

The correct setup for your spi mode is:
Code:
setup_spi(SPI_MASTER | SPI_MODE_3 | SPI_CLK_DIV_4);


After so many recommended changes we have no clue as to what your current code looks like. Please post your current program again.
One suggestion, fix the formatting of your code. Now it is very difficult to read because there is no indentation at the start of the lines.
Ttelmah



Joined: 11 Mar 2010
Posts: 19537

View user's profile Send private message

PostPosted: Tue Jan 08, 2013 2:59 pm     Reply with quote

On 'how the display controller knows', it doesn't.
Study the data sheet. You fill in a small part of the display, starting where _you_ want, by setting the column/row you want (switch to command mode, set these, then back to data mode). Then write the data to this column, for as many bytes as you want, then switch back to command mode, and select the next location.
It's going to be a pig to drive because you have so little RAM. The 'easy' way would be to have a copy of the RAM in the PIC's RAM, organised as an array with the required rows/columns, modify this where (of course) you can read the existing data, and (for instance), set a required bit. then do a block transfer of the array to the display. On your chip though, you don't have the space to do this.

Best Wishes
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