#ifndef _ST7565_H_
#define _ST7565_H_
#define GLCD_CS1 LATB0 //latb0 as in rb0 i think
#define GLCD_RESET LATB1
#define GLCD_A0 LATB2
#define GLCD_RW LATB3
#define GLCD_EN LATB4
#define SCREEN_WIDTH 132
#define SCREEN_HEIGHT 32
The hex files of mikroC and mikroPascal both are not working. The GLCD displays nothing.
#ifndef _ST7565_H_
#define _ST7565_H_
#define GLCD_CS1 LATB0
#define GLCD_RESET LATB1
#define GLCD_A0 LATB2
#define GLCD_SCL LATB3
#define GLCD_SDA LATB4
#define SCREEN_WIDTH 132
#define SCREEN_HEIGHT 32
#define GLCD_CMD_DISPLAY_ON
#define GLCD_CMD_DISPLAY_OFF
#define GLCD_CMD_ALL_NORMAL
#define GLCD_CMD_ALL_ON
#define GLCD_CMD_DISPLAY_NORMAL
#define GLCD_CMD_DISPLAY_REVERSE
#define GLCD_CMD_BIAS_9
#define GLCD_CMD_BIAS_7
#define GLCD_CMD_HORIZONTAL_NORMAL
#define GLCD_CMD_HORIZONTAL_REVERSE
#define GLCD_CMD_VERTICAL_NORMAL
#define GLCD_CMD_VERTICAL_REVERSE
#define GLCD_CMD_POWER_CONTROL
#define GLCD_CMD_RESISTOR
#define GLCD_CMD_VOLUME_MODE
#define GLCD_CMD_DISPLAY_START
#define GLCD_CMD_COLUMN_LOWER
#define GLCD_CMD_COLUMN_UPPER
#define GLCD_CMD_SET_PAGE
#define GLCD_CMD_RESET
#define GLCD_CMD_NOP 0b11100011
void glcd_init();
void glcd_command(char);
void glcd_data(char);
void glcd_refresh();
void glcd_blank();
void glcd_pixel(unsigned char x, unsigned char y, unsigned char colour);
void glcd_flip_screen(unsigned char flip);
void glcd_inverse_screen(unsigned char inverse);
void glcd_test_card();
void glcd_contrast(char resistor_ratio, char contrast);
unsigned char glcd_buffer[SCREEN_WIDTH * SCREEN_HEIGHT / 8];
unsigned char glcd_flipped = 0;
#endif
void main(){ }
i did make a code that wark on build in mikroc with no error
it looks just like the one you give post #32 in link 2
and what pic sould i ues i think PIC18F26K20 and do i need to use more then one pics or just in this pic portb street to the glcd
#ifndef _ST7565_H_
#define _ST7565_H_
#define GLCD_CS1 LATB0
#define GLCD_RESET LATB1
#define GLCD_A0 LATB2
#define GLCD_SCL LATB3
#define GLCD_SDA LATB4
#define SCREEN_WIDTH 132
#define SCREEN_HEIGHT 32
#define GLCD_CMD_DISPLAY_ON 0b10101111
#define GLCD_CMD_DISPLAY_OFF 0b10101110
#define GLCD_CMD_ALL_NORMAL 0b10100100
#define GLCD_CMD_ALL_ON 0b1010010
#define GLCD_CMD_DISPLAY_NORMAL 0b10100110
#define GLCD_CMD_DISPLAY_REVERSE 0b10100111
#define GLCD_CMD_BIAS_9 0b10100010
#define GLCD_CMD_BIAS_7 0b10100011
#define GLCD_CMD_HORIZONTAL_NORMAL 0b10100000
#define GLCD_CMD_HORIZONTAL_REVERSE 0b10100001
#define GLCD_CMD_VERTICAL_NORMAL 0b11000000
#define GLCD_CMD_VERTICAL_REVERSE 0b11001000
#define GLCD_CMD_POWER_CONTROL 0b00101000
#define GLCD_CMD_RESISTOR 0b00100000
#define GLCD_CMD_VOLUME_MODE 0b10000001
#define GLCD_CMD_DISPLAY_START 0b01000000
#define GLCD_CMD_COLUMN_LOWER 0b00000000
#define GLCD_CMD_COLUMN_UPPER 0b00010000
#define GLCD_CMD_SET_PAGE 0b10110000
#define GLCD_CMD_RESET 0b11100010
#define GLCD_CMD_NOP 0b11100011
void glcd_init(); {
GLCD_CS1 = 0;
GLCD_RESET = 0;
DelayMs(50);
GLCD_RESET = 1;
glcd_command(GLCD_CMD_BIAS_9);
glcd_command(GLCD_CMD_HORIZONTAL_NORMAL);
glcd_command(GLCD_CMD_VERTICAL_REVERSE);
glcd_flipped = 0;
glcd_command(GLCD_CMD_RESISTOR | 0x3);
glcd_command(GLCD_CMD_POWER_CONTROL | 0x7);
glcd_command(GLCD_CMD_VOLUME_MODE);
glcd_command(31);
glcd_command(GLCD_CMD_DISPLAY_START);
GLCD_CS1 = 1;
}
void glcd_data(char); {
GLCD_A0 = 1;
GLCD_CS1 = 0;
for (int n = 0; n < 8; n++) {
if (data & 0x80) {
GLCD_SDA = 1;
} else {
GLCD_SDA = 0;
}
// Pulse SCL
GLCD_SCL = 1;
GLCD_SCL = 0;
data <<= 1;
}
GLCD_CS1 = 1;
}
void glcd_command(char);
GLCD_A0 = 0;
GLCD_CS1 = 0;
for (int n = 0; n < 8; n++) {
if (command & 0x80) {
GLCD_SDA = 1;
} else {
GLCD_SDA = 0;
}
GLCD_SCL = 1;
GLCD_SCL = 0;
command <<= 1;
}
GLCD_CS1 = 1;
}
void glcd_refresh();
void glcd_blank();
void glcd_pixel(unsigned char x, unsigned char y, unsigned char colour);
void glcd_flip_screen(unsigned char flip);
if (flip) {
glcd_command(GLCD_CMD_HORIZONTAL_NORMAL);
glcd_command(GLCD_CMD_VERTICAL_REVERSE);
glcd_flipped = 0;
} else {
glcd_command(GLCD_CMD_HORIZONTAL_REVERSE);
glcd_command(GLCD_CMD_VERTICAL_NORMAL);
glcd_flipped = 1;
}
}
void glcd_inverse_screen(unsigned char inverse);
if (inverse) {
glcd_command(GLCD_CMD_DISPLAY_REVERSE);
} else {
glcd_command(GLCD_CMD_DISPLAY_NORMAL);
}
}
void glcd_test_card();
unsigned char p = 0xF0;
for (int n=1; n<=1024; n++) {
glcd_buffer[n - 1] = p;
if (n % 4 == 0) {
unsigned char q = p;
p = p << 4;
p |= q >> 4;
}
}
glcd_refresh();
}
void glcd_contrast(char resistor_ratio, char contrast);
if (resistor_ratio > 7 || contrast > 63) return;
glcd_command(GLCD_CMD_RESISTOR | resistor_ratio);
glcd_command(GLCD_CMD_VOLUME_MODE);
glcd_command(contrast);
}
unsigned char glcd_buffer[SCREEN_WIDTH * SCREEN_HEIGHT / 8];
unsigned char glcd_flipped = 0;
#endif
void main(){
}
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?