Page 1 of 2

USB and LCD

Posted: 19 Feb 2009 10:47
by lolix69
Hi,

I want to send a text sent to the LCD via USB from the USB HID example.

The problem is that I can not send a command to the LCD, but if I turn off routines HID_enable, and lets me communicate with the USB

What can I do?

I have the EasyPic5

Bye

Posted: 19 Feb 2009 11:53
by lolix69
The code is this:

void main() {
unsigned char i, ch;

df = 0;
Delay_ms(1000); Delay_ms(1000);
Lcd_Config(&PORTB, 4, 5, 6, 3, 2, 1, 0); // Initializar LCD al PORTB
LCD_Cmd(LCD_CLEAR);
LCD_Cmd(LCD_CURSOR_OFF);
LCD_Out(1,1,"adios");
Delay_ms(1000); Delay_ms(1000);

Init_Main();

HID_Enable(&userRD_buffer, &userWR_buffer);
Delay_ms(1000); Delay_ms(1000);


while (1) {
k = HID_Read();
i = 0;
while (i < k) {
ch = userRD_buffer;
//ch= 'o';
userWR_buffer[0] = ch;
while (!HID_Write(&userWR_buffer, 1)) ;
i++;
}

}

HID_Disable();

}//~!

The functions of LCD not work

Posted: 19 Feb 2009 13:50
by fabim
Lcd_Config(&LATB, 4, 5, 6, 3, 2, 1, 0); // Initializar LCD al PORTB

Posted: 19 Feb 2009 15:29
by lolix69
still not working?
Any idea?

Posted: 19 Feb 2009 15:44
by fabim
PIC18F????

Posted: 19 Feb 2009 16:40
by lolix69
the PIC is 18F4550

Posted: 19 Feb 2009 20:15
by fabim
df = 0;
Delay_ms(1000); Delay_ms(1000);
TRISB = 0x00; // all outputs
Lcd_Config(&LATB, 4, 5, 6, 3, 2, 1, 0); // Initializar LCD al PORTB
LCD_Cmd(LCD_CLEAR);
LCD_Cmd(LCD_CURSOR_OFF);
LCD_Out(1,1,"adios");
Delay_ms(1000); Delay_ms(1000);

TRY..

Posted: 19 Feb 2009 21:36
by lolix69
dont work

if I call the function HID_enable, the LCD does not work

Posted: 19 Feb 2009 21:39
by fabim
very strange!
works fine here ..

"USTED ABLA CASTELANO ?"

Posted: 19 Feb 2009 22:02
by lolix69
Does it you work to write to the LCD and to the USB?

An yes.... i speak spanish, but my englis is very poor

Posted: 20 Feb 2009 00:28
by fabim
Hehe, no hay problema.
Uno amigo mio, teve lo mismo problema.
Quando fez la mudança de puerta, no problema se hay sanado.

Tiente acer la mudança para la purta D. Esta purta no tiene otras funciones se non escrebit e acer la letura de estado.

Esto es conocido como PORTUNHOL; una mistura de portugues con lo español.

Posted: 20 Feb 2009 10:31
by lolix69
In the EasyPic5 Board, i cant use PORTD for LCD, only PORTB, no?

jajajja.... nunca habia oido lo de Portuñol xDDDD

Posted: 20 Feb 2009 12:31
by Mike Brearley
Hi There
Have you configured PORT B as a digital port as by default most of port b is configured as analog on reset unless you have done this in the configuration word.
Mike

Posted: 23 Feb 2009 17:17
by lolix69
continuous function without....

My configuration projecti is:

PIC 18F4550

MicroC 8.2

Clock: 48 MHz

Flags Project Checked:

PLLDIV_2_1L
CPUDIV_OSC1_PLL2_1L
USBDIV_2_1L

FOSC_HSPLL_HS_1H
FCMEM_OFF_1H
IESO_OFF_1H

POWRT_ON_2L
BOR_ON_2L
BOV_43_2L
VREGEN_ON_2L

WDT_OFF_2H
WDTPS_256_2H

HCLRE_ON_3H
LPT1OSC_OFF_3H
PBADEN_OFF_3H
CEP2MX_ON_3H

STVREN_ON_AL
LVP_OFF_AL
ICPRT_OFF_AL
XINST_OFF_AL
DEBUF_OFF_AL

Posted: 23 Feb 2009 23:01
by louis, netherlands
Hi there,

I have the same problem as lolix69, with the same technical project configuration.
But ...
I thought of something, the clock-speed, so I changed the following :
- check flag _FOSC_HS_1H
- uncheck flag _FOSC_HSPLL_1H
This causes the clockspeed to change from 48 MHz to 8 MHz because the PLL will be switched off.
And now everything works fine (although the USB runs on low speed now).

So this is what I think is happening ....

I have found a description about a LCD in 'LCD16x2_TRIMODS1538.pdf'
This LCD works with a controller, called KS0070B from Samsung, this seems to be the most used controller for LCD's.
I guess the MikroElektronica-LCD has the same controller, or a similar one.
On page 11 of this description I find the following info:
Busy Flag (BF)
When BF = "1", it indicates that the internal operation is being processed. So during this time the next instruction
cannot be accepted. BF can be read, when RS = "0" and R/W = "1"
(Read Instruction Operation), through DB7 port.
Before executing the next instruction, be sure that BF is not "1".

So this means that there is a minimum time needed to do the writing of the bits to the LCD-port, this minimum time is not

determinend by a specific time, but by a bit-check (when RS = "0" and R/W = "1" DB7 must be "1"). And I cannot find this bit

-check in the assembly routines made by MikroElektronica.

Is this helpfull ?

When I am correct then MikroElektronica should rewrite there LCD-routines a bit ...