Skip to content

fix RV003_ADD_EXTI_HANDLER not being called when an interrupt arrives on the same EXTI line as USB_PIN_DP - #139

Merged
cnlohr merged 1 commit into
cnlohr:masterfrom
ChipOfTheseus:master
Sep 14, 2026
Merged

cnlohr merged 1 commit into
cnlohr:masterfrom
ChipOfTheseus:master

Conversation

@ZimM-LostPolygon

@ZimM-LostPolygon ZimM-LostPolygon commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Context:

#define USB_PORT D  
#define USB_PIN_DP 4
#define USB_PIN_DM 3

(Yes, D+/D- are swapped compared to the typical example code)

There is also another completely unrelated interrupt on pin C4. The problem is that, whenever C4 is triggered, RV003_ADD_EXTI_HANDLER never gets called. I believe it's because of this line:

c.andi a2, USB_DMASK

In this case, it checks if EXTI_INTFR has either bit 3 or bit 4 set, even though D+ has no interrupt, sees that bit 4 is active (because it was pin C4 that triggered it), and never jumps to another_interrupt_check.

The suggested fix seems to work fine for me, but I'm not sure if there's some other big reason the check is done the way it is.

@cnlohr

cnlohr commented Aug 11, 2026

Copy link
Copy Markdown
Owner

I think this is right. I always get KA / SE0 packets confused with this. Can you make sure you are still getting SE0 packets (for clock tuning), @ZimM-LostPolygon

Also, cc'ing @monte-monte for visibility.

@cnlohr

cnlohr commented Aug 11, 2026

Copy link
Copy Markdown
Owner

Err now I am thinking it's the other way around. I can never remember if it's D+ or D- that signal SE0 on low speed because it's half-backwards from USB Full Speed

@ZimM-LostPolygon

Copy link
Copy Markdown
Contributor Author

Isn't it both D+ and D- going low that signals SE0?

But regardless, the state of D+ seems irrelevant to me here - I don't think the state of D+ is even read at this point, but it's still trying to check EXTI_INTFR for an interrupt on D+, which doesn't exist

@monte-monte

Copy link
Copy Markdown
Contributor

But then it will still fail if another interrupt will be at PC3.

@ZimM-LostPolygon

Copy link
Copy Markdown
Contributor Author

Well that's normal and expected - you can't have multiple interrupts on the same EXTI line number. Or rather you can, but then you can't distinguish between them, which makes the interrupts useless in many cases, so typically you'd just carefully plan the interrupts so there's no overlap

@monte-monte

Copy link
Copy Markdown
Contributor

Ah sorry, I missed that we only set interrupt on DM pin originally. Then I agree this is an issue, and thank you for fixing it.

@ZimM-LostPolygon

Copy link
Copy Markdown
Contributor Author

Could this be merged? Is something else needs to be done?

@cnlohr
cnlohr merged commit 5524a83 into cnlohr:master Sep 14, 2026
3 checks passed
@cnlohr

cnlohr commented Sep 14, 2026

Copy link
Copy Markdown
Owner

Sorry, I missed it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants