Jump to content
43oh

Code stops working with USBHID_sendReport()


Recommended Posts

Hi, I'm having a problem that the source may come from TI's USB HID API. Need USB experts.

 

I'm trying to interface my TrackPoint (PS/2 mouse) with the MSP430F5510. Without calling USBHID_sendReport(), PS/2 communication between the MSP430 and the mouse works well. When called, the communication stops. The PS/2 code is posted in the code vault: http://forum.43oh.com/topic/5124-ps2-mouse-for-any-msp430/#entry45187.

case ST_ENUM_ACTIVE:
	PS2_setMode(RESET_MODE);
	PS2_setMode(REMOTE_MODE);
	Trackpoint_setSensitivity(0xC0);

	while(1) {
		ps2Data = PS2_getData(); //ps2Data with type PS2DATA_t
		usbData.x = ps2Data.x;   //usbData with type USB_MOUSE_REPORT_t
		usbData.y = -ps2Data.y; //by default, ps/2 mouse y-value is opposite to direction moving to
		usbData.state = ps2Data.state & 0x07; //only least significant three bits are transferred

		//use middle button to scroll
		if(ps2Data.state & BIT2) {
			usbData.z = ps2Data.y;
		}

		//Problem: USBHID_sendReport() stops PS/2 connection for no reason
		//Mouse communication with MSP430 works fine with all of these delays in between....
		//				__delay_cycles(100000);
		//				__delay_cycles(100000);
		//				__delay_cycles(100000);
		//				__delay_cycles(100000);
		//				__delay_cycles(100000);
		//				__delay_cycles(100000);
		//				__delay_cycles(100000);
		//				__delay_cycles(100000);


		//.... but not with USB report line
		//USBHID_sendReport((void *) &usbData, HID_MOUSE);
	}

This problem probably explains why all the PS/2 code will work without USB connectivity. Can you debug USB without using UART? If I put send some text via UART in the PS2.c file and in the ST_ENUM_ACTIVE case, the code starts to work magically and USB works fine too. However, that creates a lot of delays between the reports and the mouse's movement is very slow.

post-32777-0-20358400-1394198918_thumb.png

post-32777-0-53399700-1394198932_thumb.png

Link to post
Share on other sites

Still not sure what the problem is but I moved the mouse reading + USB report to a 7ms timer interrupt block (about the time it takes for the PS/2 to communicate with the mouse via Remote Mode). And it just works, pretty well. I'm going to update the code vault.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...