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

display increasing value

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



Joined: 10 Dec 2011
Posts: 376
Location: Sofiq,Bulgariq

View user's profile Send private message

display increasing value
PostPosted: Wed Apr 18, 2012 12:51 pm     Reply with quote

Hello!
I'm using display - NHD-C0216CZ-FSW-FBW-3V3. The PIC is 16F873A.
I don't know particular driver to handle with this display, instead I use SPI communication, according datasheet.
The problem is to increasing given value. For example value = from '0' to '255'
Every time i need to combine several for cycles for every decimal digit and convert decimal to ASCII from the table where 1(dec)=49(ASCII) 2(dec)=50(ASCII).
Here is my pseudo code:

Code:

for(hundreds=0;hundreds<=9){
 for(decades=0;decades<=9;decades++){
  for(ones=0;ones<=9;ones++){
   spi_write(hundreds);DDRAM++;  //DDRAM++ mean shift_right
   spi_write(decades);DDRAM++;   //character possition
   spi_write(ones);;
   }
 }
}


If someone understand my problem, and know easier method to increase a value I would appreciate that.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Apr 18, 2012 1:57 pm     Reply with quote

Get rid of that LCD. Get a normal LCD. Then, instead of spending weeks
on a simple program, you can spend minutes on it.

By using a normal LCD, I can write and test the whole program in about
1 minute. Here, it's done. The program displays this on the LCD:
Code:

  0
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
  .
  .
  .
 98
 99
100
101
  .
  .
  .
250
251
252
253
254
255
  0
  1
  2
  3
  .
  .
  .

Here is the program to display an increasing value:
Code:

#include <18F4520.H>
#fuses INTRC_IO,NOWDT,PUT,BROWNOUT,NOLVP
#use delay(clock=4M)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

#include "flex_lcd.c"

//======================================
void main(void)
{
int8 i;

lcd_init();

i = 0;

while(1)
  {
   printf(lcd_putc, "%3u", i);
   i++;
   lcd_gotoxy(1, 1);
   delay_ms(200);
  }

}
Ttelmah



Joined: 11 Mar 2010
Posts: 19537

View user's profile Send private message

PostPosted: Wed Apr 18, 2012 3:05 pm     Reply with quote

PCM programmer is right that a standard display is much easier to drive.

However, much worse, is the fact that the display you are listing, is _not_ compatible with the PIC you are using.

The PIC you have is a 5v device. Will work down to a minimum of 4v. The display is at heart a 3v device. It supports operation up to 4.4v _max_, but only guarantees it's high level output signal to go up to 2.4v, and it's inputs are only rated to go up to it's Vdd as a maximum. The command set is basically the same as for the normal LCD's, but the data is just sent using SPI, but you will be overdriving the display inputs to feed it from this PIC.

If you switch to a low voltage PIC, and operate at 3v, then you can actually just use the flex driver, with quite small modifications. Setting it up to not use read/write, and substituting the SPI write routine for the 'write_byte' routine, with a suitable setup_spi added to the init routine. This works, and all the standard flex_lcd functions run OK (lcd_gotoxy etc..).

Best Wishes
rikotech8



Joined: 10 Dec 2011
Posts: 376
Location: Sofiq,Bulgariq

View user's profile Send private message

PostPosted: Thu Apr 19, 2012 9:16 am     Reply with quote

I use two individual voltages for both, via voltage regulators.
Thank you anyway. I keep punishing myself with that display because my job require like that.
Thank you again for the advice.!
Ttelmah



Joined: 11 Mar 2010
Posts: 19537

View user's profile Send private message

PostPosted: Thu Apr 19, 2012 9:24 am     Reply with quote

rikotech8 wrote:
I use two individual voltages for both, via voltage regulators.
Thank you anyway. I keep punishing myself with that display because my job require like that.
Thank you again for the advice.!


That doesn't solve the problem. The _output_ pins of the PIC will overdrive the _inputs_ of the display. Basically every time a pin goes high on the PIC, the only thing saving the display from destruction, will be the input protection diodes.....

Best Wishes
rikotech8



Joined: 10 Dec 2011
Posts: 376
Location: Sofiq,Bulgariq

View user's profile Send private message

PostPosted: Fri Apr 20, 2012 5:57 am     Reply with quote

Yes, you are totally right. The constructor have put resistors(2,4K) between
transmission pins of a PIC and Display. This manipulation ought to protect the device from destruction.
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