// Purpose: Initialize a graphic LCD. This must be called before any // other glcd function is used. // Inputs: The initialization mode // OFF - Turns the LCD off // ON - Turns the LCD on // Date: 5/28/2003 void glcd_init(int1 mode) { // Initialze some pins output_HIGH(GLCD_RST); output_low(GLCD_E); output_low(GLCD_CS1); output_low(GLCD_CS2); output_low(GLCD_DI); // Set for instruction glcd_writeByte(GLCD_CS1, 0xC0); // Specify first RAM line at the top glcd_writeByte(GLCD_CS2, 0xC0); // of the screen glcd_writeByte(GLCD_CS1, 0x40); // Set the column address to 0 glcd_writeByte(GLCD_CS2, 0x40); glcd_writeByte(GLCD_CS1, 0xB8); // Set the page address to 0 glcd_writeByte(GLCD_CS2, 0xB8); if(mode == ON) { glcd_writeByte(GLCD_CS1, 0x3F); // Turn the display on glcd_writeByte(GLCD_CS2, 0x3F); } else { glcd_writeByte(GLCD_CS1, 0x3E); // Turn the display off glcd_writeByte(GLCD_CS2, 0x3E); } glcd_fillScreen(OFF); // Clear the display }
void write_dac(int16 data) { BYTE cmd[3]; BYTE i; cmd[0]=data; cmd[1]=(data>>8); cmd[2]=0x03; output_high(DAC_LDAC); output_low(DAC_CLK); output_low(DAC_CS); for(i=0; i<=23; ++i) { if(i<4 || (i>7 && i<12)) shift_left(cmd,3,0); else { output_bit(DAC_DI, shift_left(cmd,3,0)); output_high(DAC_CLK); output_low(DAC_CLK); } } output_high(DAC_CS); output_low(DAC_LDAC); delay_us(10); output_HIGH(DAC_LDAC); }