[SOLVED] PIC18F2550 USB Problem

Status
Not open for further replies.

Yosmany325

Member level 3
Joined
Oct 31, 2012
Messages
62
Helped
8
Reputation
16
Reaction score
8
Trophy points
1,298
Visit site
Activity points
1,758
HI, everyone. I´m trying to make a bootloader using PIC18F2550 and MCC18. Using the code attached and simulating with Proteus 7.9 SP1 the pic enumerates correctly. The problem arises when my device receives a request it can not process. When this happens, the firmware returns STALL as should be, but after that it continues sending that response, EVEN WHEN the request is ok. I need help to detect what´s wrong. Thanks in advance. Yosmany325

Note: Some parts in the code are in assembler to reduce final code size.
Thanks in advance.

Ahh. The program used to test HID is HidTest
 

Attachments

  • usb_stall.zip
    11.7 KB · Views: 56
Last edited by a moderator:

Hi everyone, finally I've found the reason for the problem. What happens is that after EP0 issues a STALL the UEP0.EPSTALL bit is set. If this bit is not cleared in firmware it remains set, causing EP0 continually return STALL, even when armed correctly. Normally this bit must be cleared when a Stall Interrupt is processed but the Virtual USB of Proteus don't generate this interrupt. The solution to this problem could be to clear this bit at begin of ServiceSetup() function to overcome this problem when simulating. The real solution should be to do so in the processing of Stall Interrupt.

Note: In this code the processing of Stall Interrupt is not included as simulation does not takes it in account.

Regards, Yosmany325.
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…