USB and LCD

General discussion on mikroC.
Author
Message
lolix69
Posts: 9
Joined: 19 Feb 2009 10:40

USB and LCD

#1 Post by lolix69 » 19 Feb 2009 10:47

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

lolix69
Posts: 9
Joined: 19 Feb 2009 10:40

#2 Post by lolix69 » 19 Feb 2009 11:53

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

fabim
Posts: 197
Joined: 18 Jan 2007 15:49

#3 Post by fabim » 19 Feb 2009 13:50

Lcd_Config(&LATB, 4, 5, 6, 3, 2, 1, 0); // Initializar LCD al PORTB

lolix69
Posts: 9
Joined: 19 Feb 2009 10:40

#4 Post by lolix69 » 19 Feb 2009 15:29

still not working?
Any idea?

fabim
Posts: 197
Joined: 18 Jan 2007 15:49

#5 Post by fabim » 19 Feb 2009 15:44

PIC18F????

lolix69
Posts: 9
Joined: 19 Feb 2009 10:40

#6 Post by lolix69 » 19 Feb 2009 16:40

the PIC is 18F4550

fabim
Posts: 197
Joined: 18 Jan 2007 15:49

#7 Post by fabim » 19 Feb 2009 20:15

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..

lolix69
Posts: 9
Joined: 19 Feb 2009 10:40

#8 Post by lolix69 » 19 Feb 2009 21:36

dont work

if I call the function HID_enable, the LCD does not work
Last edited by lolix69 on 19 Feb 2009 21:58, edited 2 times in total.

fabim
Posts: 197
Joined: 18 Jan 2007 15:49

#9 Post by fabim » 19 Feb 2009 21:39

very strange!
works fine here ..

"USTED ABLA CASTELANO ?"

lolix69
Posts: 9
Joined: 19 Feb 2009 10:40

#10 Post by lolix69 » 19 Feb 2009 22:02

Does it you work to write to the LCD and to the USB?

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

fabim
Posts: 197
Joined: 18 Jan 2007 15:49

#11 Post by fabim » 20 Feb 2009 00:28

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.

lolix69
Posts: 9
Joined: 19 Feb 2009 10:40

#12 Post by lolix69 » 20 Feb 2009 10:31

In the EasyPic5 Board, i cant use PORTD for LCD, only PORTB, no?

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

Mike Brearley
Posts: 173
Joined: 09 Apr 2008 12:56

#13 Post by Mike Brearley » 20 Feb 2009 12:31

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
When all else fails .... Read the fu**ing Manual.!!

lolix69
Posts: 9
Joined: 19 Feb 2009 10:40

#14 Post by lolix69 » 23 Feb 2009 17:17

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

louis, netherlands
Posts: 29
Joined: 23 Feb 2009 22:58

#15 Post by louis, netherlands » 23 Feb 2009 23:01

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 ...

Post Reply

Return to “mikroC General”