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

displaying with LCD

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



Joined: 28 Jul 2004
Posts: 6

View user's profile Send private message Visit poster's website

displaying with LCD
PostPosted: Wed Aug 11, 2004 6:55 am     Reply with quote

I am trying to output a variable in the LCD (using the PICDEM 2 Plus/16F877).

I understand how it is done in printf, but, having tried that to no avail I am kind of stuck. Here is my code:

Code:

#include <16F877.h>
#device adc=8
#use delay(clock=10000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,stream=RS232,bits=8)
#fuses NOWDT,RC, NOPUT, NOPROTECT, BROWNOUT
#use i2c(Master,sda=PIN_C4,scl=PIN_C3,RESTART_WDT,FORCE_HW)
#include <lcd_inc.c>
#include <stdio.h>
int outs;
int16 Temperature;

#int_TIMER1
TIMER1_isr() {  //interrupt occurs every 2 seconds
   outs = outs ^ 0x1;   //toggle output bit
   output_bit(PIN_B1, outs);
      i2c_Start();           // Set a START condition I2C Bus
      i2c_Write(0x10011010b); // Address and Write Flag
      i2c_Write(0x00);       // Temperature Register
      i2c_Start();           // Set a START condition I2C Bus
      i2c_Write(0x10011011b); // Address and Read Flag
      Temperature = i2c_Read(); // Read Teperature
      i2c_stop();
     lcd_putc("\ftemp: ");
     lcd_putc(Temperature);
     output_bit(PIN_B0,outs);
     printf("Temp: %ld",Temperature);
}

void main() {
lcd_init();
   setup_timer_1(T1_EXTERNAL|T1_DIV_BY_1|0x8); //enable T1 for external clock, divide by 1
   enable_interrupts(INT_TIMER1); //unmask timer1 overflow interrupt
   enable_interrupts(global);  //enable all unmasked interrupts
   set_tris_c(0xff);
   outs = 0x1;    //preset output
   while(1);        //main does nothing
}


thanks in advance for any help.
cbstieff



Joined: 09 Aug 2004
Posts: 7
Location: Kensington, MD

View user's profile Send private message Send e-mail

PostPosted: Wed Aug 11, 2004 8:40 am     Reply with quote

I believe that the CCS LCD driver will only work with LCDs that have a interface that is compatible with a HD44780 chip. The HD44780 interface bus has 14 pins. The LCD in the PICDEM 2 has 15 pins and I suspect that it is not compatible. You need to go to the Microchip web site and get a demo program for the PICDEM 2 that uses the LCD to see how to code the PICDEM LCD interface.
tag-eng



Joined: 28 Jul 2004
Posts: 6

View user's profile Send private message Visit poster's website

PostPosted: Wed Aug 11, 2004 9:18 am     Reply with quote

ah thanks, unfortuntly i have the code, and it is assembly code while i am working in c (and have no knowledge of assembly at all infact.)

but i am not using the CCS driver, i am using the driver that is in the code library and have been able to get the LCD to print something out, it just doesn't print out Temerature.

thanks
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Wed Aug 11, 2004 10:40 am     Reply with quote

Replace this:
Code:

     lcd_putc("\ftemp: ");
     lcd_putc(Temperature);


With this:

Code:

     printf(lcd_putc,"\fTemp: %ld",Temperature);
tag-eng



Joined: 28 Jul 2004
Posts: 6

View user's profile Send private message Visit poster's website

PostPosted: Wed Aug 11, 2004 12:35 pm     Reply with quote

thanks a lot mark, that works
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