
Originally Posted by
colin mac
I don't think it's the delays, since I can send out a char by just sending an ascii value to the port and I tried just passing one char to sendChar() and it didn't work leaving me to believe it's a problem with sendChar().
I still believe it might be it .. you can check the I2C lcd controller using PIC16F690 post where there is source (in csc but easily converted to mikroc) that works ok ... (compiled in mikroC, tested in ISIS)
in particular this code works:
Code:
#define D7 PORTD.F7
#define D6 PORTD.F6
#define D5 PORTD.F5
#define D4 PORTD.F4
#define E PORTD.F3
#define RS PORTD.F2
void lcd_send_nibble( unsigned char n ) {
D7 = (n >> 3) & 1;
D6 = (n >> 2) & 1;
D5 = (n >> 1) & 1;
D4 = n & 1;
_asm nop
E=1;
delay_us(2);
E=0;
}
void lcd_send_byte( unsigned char address, unsigned char n ) {
RS = address;
_asm nop
E = 0;
lcd_send_nibble(n >> 4);
lcd_send_nibble(n & 0xf);
Delay_ms(200);
}
#define lcd_type 2 // 0=5x7, 1=5x10, 2=2 lines
unsigned char const LCD_INIT_STRING[4] = {0x20 | (lcd_type << 2), 0xc, 1, 6};
void xlcd_init() {
unsigned char i;
RS = 0;
E = 0;
Delay_ms(15);
for(i=1;i<=3;++i) {
lcd_send_nibble(3);
Delay_ms(5);
}
lcd_send_nibble(2);
for(i=0;i<=3;++i)
lcd_send_byte(0,LCD_INIT_STRING[i]);
}
void main(){
ADCON1 = 0xff;
TRISD = 0;
PORTD = 0;
TRISC = 0;
PORTC = 0;
xlcd_init();
lcd_send_byte(0,1); //clear screen
lcd_send_byte(1,'h');
lcd_send_byte(1,'e');
lcd_send_byte(1,'l');
lcd_send_byte(1,'l');
lcd_send_byte(1,'o');
}
attached pic is this code simulated in ISIS
as for the "end of string" .. when you make string as you did "blah blah" mikroC automatically add '\0' to the end of it so you do not need to take care of that, also sprintf and other functions do the correct cstring termination ..