Error in USB sample code (USBFS datasheet)

This forum is for the reporting and discussion of the PSoC documentation from Cypress (data sheet, TRM, user guide, etc).

Moderator: fsu

Error in USB sample code (USBFS datasheet)

Postby jnork » Wed May 06, 2009 9:15 pm

Document Number: 001-13629 Rev. *B Page 13 of 26

The error is in the assembly version.

Here's the C version:

//Enumeration is completed load endpoint 1. Do not toggle the first time
USBFS_LoadInEP(1, abMouseData, 3, USB_NO_TOGGLE);

...

//ACK has occurred, load the endpoint and toggle the data bit
USBFS_LoadInEP(1, abMouseData, 3, USB_TOGGLE);

Here's the assembly version:

; Enumeration is completed load endpoint 1. Do not toggle the first time
; USBFS_LoadInEP(1, abMouseData, 3, USB_TOGGLE); <==== Isn't that supposed to be USB_NO_TOGGLE?
PUSH X
MOV A,1 <==== Shouldn't that be a 0?
PUSH A
MOV A,0
PUSH A
MOV A,3
PUSH A
MOV A,0
PUSH A
MOV A,71
PUSH A
MOV A,1
PUSH A
USBFS Device
LCALL USBFS_LoadInEP

I won't bother pasting the second part, it looks the same.

Looks like a copy/paste issue.

Thanks.
Jeffrey Nonken, Firmware Engineer
Precision Flight Controls, Inc.
"Quality is designed in, not added on."
User avatar
jnork
Newbie
Newbie
 
Posts: 2
Joined: Wed May 06, 2009 8:52 pm
ICQ: 3303037
Website: http://jeffrey.nonken.net/

Re: Error in USB sample code (USBFS datasheet)

Postby graaja » Thu May 07, 2009 11:47 am

The parameters to the function are pushed to the stack from right to left. So, the 0 that is being pushed first is for the USB_NO_TOGGLE constant. The last value that is being pushed to stack is 1, which is the Endpoint number.
User avatar
graaja
PSoC Master
PSoC Master
 
Posts: 3084
Joined: Thu Dec 18, 2003 4:35 pm
Website: http://www.planetpsoc.com
Location: India

Re: Error in USB sample code (USBFS datasheet)

Postby slandrum » Thu May 07, 2009 1:43 pm

Except, as Jeff as noted, the first value being pushed isn't zero (which it should be for USB_NO_TOGGLE).

His point was that the C example differs from the asm example.
slandrum
The Big Cheese
The Big Cheese
 
Posts: 453
Joined: Fri Feb 29, 2008 11:38 am
Location: California

Re: Error in USB sample code (USBFS datasheet)

Postby graaja » Thu May 07, 2009 6:01 pm

Jeff / Slandrum,

Sorry!! It was past midnight and I should have fallen asleep while answering that :oops:

This looks like the very common mistake in the user module data sheet sample code (there is another thread with a problem in I2CHW sample code). I will write to the concerned persons in Cypress about this bug.
User avatar
graaja
PSoC Master
PSoC Master
 
Posts: 3084
Joined: Thu Dec 18, 2003 4:35 pm
Website: http://www.planetpsoc.com
Location: India

Re: Error in USB sample code (USBFS datasheet)

Postby fsu » Tue Jun 02, 2009 2:20 pm

The error will be corrected in the next service pack. Thanks!
--Steve Fouts
Technical Writer, Sr.
Cypress initials - FSU
fsu
Newbie
Newbie
 
Posts: 8
Joined: Mon Mar 24, 2008 7:54 am


Return to “%s” PSoC Documentation Feedback

Who is online

Users browsing this forum: No registered users and 1 guest