USB with GLCD problem

General discussion on mikroC.
Post Reply
Author
Message
nish
Posts: 5
Joined: 06 Oct 2009 20:14

USB with GLCD problem

#1 Post by nish » 15 Nov 2009 11:21

Hi

I am doing a project which involves USB and GLCD. Basically both work separately but when i integrate the USB to the GLCD code the GLCD stops working. I tracked the prob to the USB interrupt. If i comment out as shown below GLCD works. But USB doesnt work!

void interrupt()
{
//HID_InterruptProc();
//return;
}

Can the USB and GLCD work together?I have included USBdsc.c,VARs.h and Definit.h to the GLCD code and initialize USB HID via :

HID_Enable(&userRD_buffer, &userWR_buffer);

Please advice someone

User avatar
anikolic
mikroElektronika team
Posts: 1775
Joined: 17 Aug 2009 16:51
Location: Belgrade
Contact:

#2 Post by anikolic » 17 Nov 2009 16:19

Hi,
What exactly did you have in mind to do? USB HID library uses interrupts to send and receive data, so if your GLCD is interrupted due to this, there are likely to be some errors. You must carefully organize your program, and maybe turn off interrupts INTCON.GIE = 0; and PIE2.USBIE = 0; during GLCD routines, and turn them on again after completion. Can you paste a piece of code for me to take a look at what were your intentions in the project?

Best regards,
Aleksandar
Web Department Manager

nish
Posts: 5
Joined: 06 Oct 2009 20:14

#3 Post by nish » 20 Nov 2009 16:25

Hi

Is it possible for me to private message you my code tree?

User avatar
anikolic
mikroElektronika team
Posts: 1775
Joined: 17 Aug 2009 16:51
Location: Belgrade
Contact:

#4 Post by anikolic » 24 Nov 2009 12:47

Hi,
I can only provide you with project files via our support ticket system, so if you are interested in this, please open the support ticket at: http://www.mikroe.com/en/support/ and refer to this post, and I will attach you some demonstration project.

Best regards,
Aleksandar
Web Department Manager

vimu
Posts: 1
Joined: 29 Nov 2011 04:27

Re: USB with GLCD problem

#5 Post by vimu » 29 Nov 2011 05:12

I had the same problem and I spent an entire day trying to figure out what the problem. I was trying to use the USB library along with the PS2 one and USB stopped working at the very moment I defined the PS2 variables:

Code: Select all

sbit PS2_Data            at RA4_bit;
sbit PS2_Clock           at RA5_bit;
sbit PS2_Data_Direction  at TRISA4_bit;
sbit PS2_Clock_Direction at TRISA5_bit;
By using the Statistics tool I figured out that my USB writebuff variable size was 56 bytes long instead of 64. When I went to the code I found that my buffer´s definition was wrong. I had written

Code: Select all

typedef union _INTPUT_CONTROLS_TYPEDEF {
   struct {
      BYTE control_code;
      BYTE pad;
      BYTE scan_code[6];
   } kbd_members;

   BYTE val[56];
} INPUT_CONTROLS;

INPUT_CONTROLS keyboard_report absolute 0x540;
Instead of the right definition

Code: Select all

typedef union _INTPUT_CONTROLS_TYPEDEF {
   struct {
      BYTE control_code;
      BYTE pad;
      BYTE scan_code[6];
   } kbd_members;
   
   BYTE val[64];
} INPUT_CONTROLS;

INPUT_CONTROLS keyboard_report absolute 0x540;
I haven’t figure out why, but everything started to run nicely after the correction. I know this is a blunder but a very difficult one to trace. Anyway, I hope this can help another fellow of the tortured souls.

Post Reply

Return to “mikroC General”