#include <12F675.h> #device adc=8 #FUSES NOWDT //No Watch Dog Timer #FUSES INTRC_IO //Internal RC Osc, no CLKOUT #FUSES NOCPD //No EE protection #FUSES NOPROTECT //Code not protected from reading #FUSES MCLR //Master Clear pin enabled #FUSES PUT //Power Up Timer #FUSES BROWNOUT //Reset when brownout detected #use delay(clock=4000000) // setup for internal 4mghz oscillator #define LCD_DC PIN_A0 // setup pin names for easy coding #define LCD_RST PIN_A1 #define ADC_IN PIN_A2 #define LCD_DAT PIN_A4 #define LCD_CLK PIN_A5 void writecommand(int command); // declare function names for compiler void writedata(int data); void cursorxy (byte x, byte y); void clearram(void); void initpic(void); void initlcd(void); int temp; void main() { long int lcdram; initpic(); initlcd(); clearram(); // This is where the code goes to do stuff! // here is a simple example cursorxy (3,3); // set the cursor to position x=3 and y-3 writedata(255); // write a solid byte of all 8 bits // Thats all im giving you for now! while(1); } void writecommand(int command) { output_low(LCD_DC); // byte is a command it is read with the eight SCLK pulse for (temp=8;temp>0;temp--) { output_low(LCD_CLK); if ((command&0x80)==0) { output_low(LCD_DAT); } else { output_high(LCD_DAT); } output_high(LCD_CLK); command=command<<1; } } void writedata(int data) { output_high(LCD_DC); for (temp=8;temp>0;temp--) { output_low(LCD_CLK); if ((data&0x80)==0) { output_low(LCD_DAT); } else { output_high(LCD_DAT); } output_high(LCD_CLK); data=data<<1; } } void cursorxy (byte x, byte y) // Nokia LCD Position cursor { writecommand(0x40|(y&0x07)); writecommand(0x80|(x&0x7f)); } void clearram(void) { long int lcdram; cursorxy(0,0); for (lcdram=504;lcdram>0;lcdram--) writedata(0); // write all 504 LCDRAM addresses. } VOID initpic(void) { setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); setup_timer_1(T1_DISABLED); setup_comparator(NC_NC); setup_vref(FALSE); } void initlcd(void) { output_low(LCD_RST); // reset LCD delay_ms(100); // Wait 100ms output_high(LCD_RST);// release from reset writecommand(0x21); // Activate Chip and H=1. writecommand(0xC2); // Set LCD Voltage to about 7V. writecommand(0x13); // Adjust voltage bias. writecommand(0x20); // Horizontal addressing and H=0. writecommand(0x09); // Activate all segments. clearram(); // Erase all pixel on the lcdram. writecommand(0x08); // Blank the Display. writecommand(0x0C); // Display Normal. cursorxy(0,0); // Cursor Home. }